mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#52 Moving Mappers class to package org.mapstruct.factory
This commit is contained in:
parent
c093e09c82
commit
c2a7853e4c
@ -23,6 +23,8 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks an interface as mapper interface and activates the generation of a
|
* Marks an interface as mapper interface and activates the generation of a
|
||||||
* mapper implementation for that interface.
|
* mapper implementation for that interface.
|
||||||
|
@ -16,10 +16,30 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.mapstruct;
|
package org.mapstruct.factory;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory for getting mapper instances.
|
* Factory for obtaining mapper instances if no explicit component model such as CDI is configured via
|
||||||
|
* {@link Mapper#componentModel()}.
|
||||||
|
* <p>
|
||||||
|
* Mapper implementation types are expected to have the same fully qualified name as their interface type, with the
|
||||||
|
* suffix {@code Impl} appended. When using this factory, mapper types - and any mappers they use - are instantiated by
|
||||||
|
* invoking their public no-args constructor.
|
||||||
|
* <p>
|
||||||
|
* By convention, a single instance of each mapper is retrieved from the factory and exposed on the mapper interface
|
||||||
|
* type by declaring a member named {@code INSTANCE} like this:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* @Mapper
|
||||||
|
* public interface CustomerMapper {
|
||||||
|
*
|
||||||
|
* CustomerMapper INSTANCE = Mappers.getMapper( CustomerMapper.class );
|
||||||
|
*
|
||||||
|
* // mapping methods...
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author Gunnar Morling
|
* @author Gunnar Morling
|
||||||
*/
|
*/
|
26
core/src/main/java/org/mapstruct/factory/package-info.java
Normal file
26
core/src/main/java/org/mapstruct/factory/package-info.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2012-2013 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||||
|
* and/or other contributors as indicated by the @authors tag. See the
|
||||||
|
* copyright.txt file in the distribution for a full listing of all
|
||||||
|
* contributors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Provides the {@link org.mapstruct.factory.Mappers} factory class for the retrieval of mapper instances if no
|
||||||
|
* explicit component model such as CDI is configured via {@link org.mapstruct.Mapper#componentModel()}.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.mapstruct.factory;
|
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct;
|
package org.mapstruct;
|
||||||
|
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
import org.mapstruct.test.model.Foo;
|
import org.mapstruct.test.model.Foo;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
package org.mapstruct.itest;
|
package org.mapstruct.itest;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.Mappings;
|
import org.mapstruct.Mappings;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.conversion;
|
package org.mapstruct.ap.conversion;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.mapstruct.ap.model.Type;
|
import org.mapstruct.ap.model.Type;
|
||||||
import org.mapstruct.ap.model.TypeConversion;
|
import org.mapstruct.ap.model.TypeConversion;
|
||||||
import org.mapstruct.ap.util.TypeFactory;
|
import org.mapstruct.ap.util.TypeFactory;
|
||||||
|
@ -21,9 +21,9 @@ package org.mapstruct.ap.test.collection;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.Mappings;
|
import org.mapstruct.Mappings;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -30,8 +30,8 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
import java.util.concurrent.ConcurrentNavigableMap;
|
import java.util.concurrent.ConcurrentNavigableMap;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
|
||||||
import org.mapstruct.MappingTarget;
|
import org.mapstruct.MappingTarget;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.mapstruct.ap.test.collection.iterabletononiterable;
|
package org.mapstruct.ap.test.collection.iterabletononiterable;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper(uses = StringListMapper.class)
|
@Mapper(uses = StringListMapper.class)
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -23,8 +23,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.mapstruct.MapMapping;
|
import org.mapstruct.MapMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
|
||||||
import org.mapstruct.MappingTarget;
|
import org.mapstruct.MappingTarget;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper(uses = CustomNumberMapper.class)
|
@Mapper(uses = CustomNumberMapper.class)
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -21,7 +21,6 @@ package org.mapstruct.ap.test.complex;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.Mappings;
|
import org.mapstruct.Mappings;
|
||||||
import org.mapstruct.ap.test.complex.other.DateMapper;
|
import org.mapstruct.ap.test.complex.other.DateMapper;
|
||||||
@ -29,6 +28,7 @@ import org.mapstruct.ap.test.complex.source.Car;
|
|||||||
import org.mapstruct.ap.test.complex.source.Person;
|
import org.mapstruct.ap.test.complex.source.Person;
|
||||||
import org.mapstruct.ap.test.complex.target.CarDto;
|
import org.mapstruct.ap.test.complex.target.CarDto;
|
||||||
import org.mapstruct.ap.test.complex.target.PersonDto;
|
import org.mapstruct.ap.test.complex.target.PersonDto;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper(uses = DateMapper.class)
|
@Mapper(uses = DateMapper.class)
|
||||||
public interface CarMapper {
|
public interface CarMapper {
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
package org.mapstruct.ap.test.conversion;
|
package org.mapstruct.ap.test.conversion;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.Mappings;
|
import org.mapstruct.Mappings;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.mapstruct.ap.test.conversion.bignumbers;
|
package org.mapstruct.ap.test.conversion.bignumbers;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -23,8 +23,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.mapstruct.IterableMapping;
|
import org.mapstruct.IterableMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.mapstruct.ap.test.conversion.nativetypes;
|
package org.mapstruct.ap.test.conversion.nativetypes;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface BooleanMapper {
|
public interface BooleanMapper {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.mapstruct.ap.test.conversion.nativetypes;
|
package org.mapstruct.ap.test.conversion.nativetypes;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface CharMapper {
|
public interface CharMapper {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.mapstruct.ap.test.conversion.nativetypes;
|
package org.mapstruct.ap.test.conversion.nativetypes;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.mapstruct.ap.test.conversion.precedence;
|
package org.mapstruct.ap.test.conversion.precedence;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper(uses = IntegerStringMapper.class)
|
@Mapper(uses = IntegerStringMapper.class)
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.mapstruct.ap.test.conversion.string;
|
package org.mapstruct.ap.test.conversion.string;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
package org.mapstruct.ap.test.inheritance;
|
package org.mapstruct.ap.test.inheritance;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
|
||||||
import org.mapstruct.MappingTarget;
|
import org.mapstruct.MappingTarget;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.mapstruct.ap.test.inheritance.attribute;
|
package org.mapstruct.ap.test.inheritance.attribute;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.mapstruct.ap.test.inheritance.attribute;
|
package org.mapstruct.ap.test.inheritance.attribute;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TargetSourceMapper {
|
public interface TargetSourceMapper {
|
||||||
|
@ -24,7 +24,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.mapstruct.MapMapping;
|
import org.mapstruct.MapMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper(uses = While.class)
|
@Mapper(uses = While.class)
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.mapstruct.ap.test.oneway;
|
package org.mapstruct.ap.test.oneway;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.mapstruct.ap.test.severalsources;
|
package org.mapstruct.ap.test.severalsources;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ErroneousSourceTargetMapper {
|
public interface ErroneousSourceTargetMapper {
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
package org.mapstruct.ap.test.severalsources;
|
package org.mapstruct.ap.test.severalsources;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.MappingTarget;
|
import org.mapstruct.MappingTarget;
|
||||||
import org.mapstruct.Mappings;
|
import org.mapstruct.Mappings;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package org.mapstruct.ap.test.unmappedtarget;
|
package org.mapstruct.ap.test.unmappedtarget;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
package org.mapstruct.ap.test.unmappedtarget;
|
package org.mapstruct.ap.test.unmappedtarget;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mappers;
|
|
||||||
import org.mapstruct.ReportingPolicy;
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR)
|
@Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR)
|
||||||
public interface StrictSourceTargetMapper {
|
public interface StrictSourceTargetMapper {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user