#52 Moving Mappers class to package org.mapstruct.factory

This commit is contained in:
Gunnar Morling 2013-08-16 19:11:46 +02:00
parent c093e09c82
commit c2a7853e4c
28 changed files with 76 additions and 25 deletions

View File

@ -23,6 +23,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.mapstruct.factory.Mappers;
/**
* Marks an interface as mapper interface and activates the generation of a
* mapper implementation for that interface.

View File

@ -16,10 +16,30 @@
* See the License for the specific language governing permissions and
* 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>
* &#064;Mapper
* public interface CustomerMapper {
*
* CustomerMapper INSTANCE = Mappers.getMapper( CustomerMapper.class );
*
* // mapping methods...
* }
* </pre>
*
* @author Gunnar Morling
*/

View 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;

View File

@ -18,6 +18,7 @@
*/
package org.mapstruct;
import org.mapstruct.factory.Mappers;
import org.mapstruct.test.model.Foo;
import org.testng.annotations.Test;

View File

@ -19,9 +19,9 @@
package org.mapstruct.itest;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SourceTargetMapper {

View File

@ -18,6 +18,8 @@
*/
package org.mapstruct.ap.conversion;
import java.util.Date;
import org.mapstruct.ap.model.Type;
import org.mapstruct.ap.model.TypeConversion;
import org.mapstruct.ap.util.TypeFactory;

View File

@ -21,9 +21,9 @@ package org.mapstruct.ap.test.collection;
import java.util.Set;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SourceTargetMapper {

View File

@ -30,8 +30,8 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentNavigableMap;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SourceTargetMapper {

View File

@ -19,7 +19,7 @@
package org.mapstruct.ap.test.collection.iterabletononiterable;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.factory.Mappers;
@Mapper(uses = StringListMapper.class)
public interface SourceTargetMapper {

View File

@ -23,8 +23,8 @@ import java.util.Map;
import org.mapstruct.MapMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;
@Mapper(uses = CustomNumberMapper.class)
public interface SourceTargetMapper {

View File

@ -21,7 +21,6 @@ package org.mapstruct.ap.test.complex;
import java.util.List;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
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.target.CarDto;
import org.mapstruct.ap.test.complex.target.PersonDto;
import org.mapstruct.factory.Mappers;
@Mapper(uses = DateMapper.class)
public interface CarMapper {

View File

@ -19,9 +19,9 @@
package org.mapstruct.ap.test.conversion;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SourceTargetMapper {

View File

@ -19,7 +19,7 @@
package org.mapstruct.ap.test.conversion.bignumbers;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SourceTargetMapper {

View File

@ -23,8 +23,8 @@ import java.util.List;
import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SourceTargetMapper {

View File

@ -19,7 +19,7 @@
package org.mapstruct.ap.test.conversion.nativetypes;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.factory.Mappers;
@Mapper
public interface BooleanMapper {

View File

@ -19,7 +19,7 @@
package org.mapstruct.ap.test.conversion.nativetypes;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.factory.Mappers;
@Mapper
public interface CharMapper {

View File

@ -19,7 +19,7 @@
package org.mapstruct.ap.test.conversion.nativetypes;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SourceTargetMapper {

View File

@ -19,7 +19,7 @@
package org.mapstruct.ap.test.conversion.precedence;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.factory.Mappers;
@Mapper(uses = IntegerStringMapper.class)
public interface SourceTargetMapper {

View File

@ -19,7 +19,7 @@
package org.mapstruct.ap.test.conversion.string;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SourceTargetMapper {

View File

@ -19,8 +19,8 @@
package org.mapstruct.ap.test.inheritance;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SourceTargetMapper {

View File

@ -19,7 +19,7 @@
package org.mapstruct.ap.test.inheritance.attribute;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SourceTargetMapper {

View File

@ -19,7 +19,7 @@
package org.mapstruct.ap.test.inheritance.attribute;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.factory.Mappers;
@Mapper
public interface TargetSourceMapper {

View File

@ -24,7 +24,7 @@ import java.util.Map;
import org.mapstruct.MapMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.factory.Mappers;
@Mapper(uses = While.class)
public interface SourceTargetMapper {

View File

@ -19,7 +19,7 @@
package org.mapstruct.ap.test.oneway;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SourceTargetMapper {

View File

@ -19,7 +19,7 @@
package org.mapstruct.ap.test.severalsources;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.factory.Mappers;
@Mapper
public interface ErroneousSourceTargetMapper {

View File

@ -19,10 +19,10 @@
package org.mapstruct.ap.test.severalsources;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SourceTargetMapper {

View File

@ -19,7 +19,7 @@
package org.mapstruct.ap.test.unmappedtarget;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SourceTargetMapper {

View File

@ -19,8 +19,8 @@
package org.mapstruct.ap.test.unmappedtarget;
import org.mapstruct.Mapper;
import org.mapstruct.Mappers;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;
@Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR)
public interface StrictSourceTargetMapper {