mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#28 Updating JavaDocs for API classes
This commit is contained in:
parent
2694b6e8f9
commit
5eafdb4970
@ -32,5 +32,11 @@ import java.lang.annotation.Target;
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface Mapper {
|
||||
|
||||
/**
|
||||
* The mapper types used by this mapper.
|
||||
*
|
||||
* @return The mapper types used by this mapper.
|
||||
*/
|
||||
Class<?>[] uses() default { };
|
||||
}
|
||||
|
@ -18,30 +18,43 @@
|
||||
*/
|
||||
package org.mapstruct;
|
||||
|
||||
|
||||
/**
|
||||
* Factory for getting mapper instances.
|
||||
*
|
||||
* @author Gunnar Morling
|
||||
*/
|
||||
public class Mappers {
|
||||
|
||||
private final static String IMPLEMENTATION_SUFFIX = "Impl";
|
||||
|
||||
/**
|
||||
* TODO: Check that
|
||||
* - clazz is an interface
|
||||
* - the implementation type implements clazz
|
||||
* - clazz is annotated with @Mapper
|
||||
* Returns an instance of the given mapper type.
|
||||
*
|
||||
* TODO: Use privileged action
|
||||
* @param clazz The type of the mapper to return.
|
||||
*
|
||||
* @return An instance of the given mapper type.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getMapper(Class<T> clazz) {
|
||||
try {
|
||||
|
||||
// ClassLoader classLoader = clazz.getClassLoader();
|
||||
// Check that
|
||||
// - clazz is an interface
|
||||
// - the implementation type implements clazz
|
||||
// - clazz is annotated with @Mapper
|
||||
//
|
||||
// Use privileged action
|
||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||
|
||||
return (T) classLoader.loadClass( clazz.getName() + IMPLEMENTATION_SUFFIX ).newInstance();
|
||||
if ( classLoader == null ) {
|
||||
classLoader = Mappers.class.getClassLoader();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
T mapper = (T) classLoader.loadClass( clazz.getName() + IMPLEMENTATION_SUFFIX ).newInstance();
|
||||
|
||||
return mapper;
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,24 @@
|
||||
*/
|
||||
package org.mapstruct;
|
||||
|
||||
/**
|
||||
* Configures the mapping of one bean attribute.
|
||||
*
|
||||
* @author Gunnar Morling
|
||||
*/
|
||||
public @interface Mapping {
|
||||
|
||||
/**
|
||||
* The source name of the configured property as defined by the JavaBeans specification.
|
||||
*
|
||||
* @return The source name of the configured property.
|
||||
*/
|
||||
String source();
|
||||
|
||||
/**
|
||||
* The target name of the configured property as defined by the JavaBeans specification.
|
||||
*
|
||||
* @return The target name of the configured property.
|
||||
*/
|
||||
String target();
|
||||
}
|
||||
|
@ -18,8 +18,17 @@
|
||||
*/
|
||||
package org.mapstruct;
|
||||
|
||||
|
||||
/**
|
||||
* Configures the mappings of several bean attributes.
|
||||
*
|
||||
* @author Gunnar Morling
|
||||
*/
|
||||
public @interface Mappings {
|
||||
|
||||
/**
|
||||
* The onfiguration of the bean attributes.
|
||||
*
|
||||
* @return The configuration of the bean attributes.
|
||||
*/
|
||||
Mapping[] value();
|
||||
}
|
||||
|
@ -64,8 +64,8 @@
|
||||
<processor>org.mapstruct.ap.MappingProcessor</processor>
|
||||
</processors>
|
||||
<options>
|
||||
<!-- suppressGeneratorTimestamp=false is the default -->
|
||||
<suppressGeneratorTimestamp>false</suppressGeneratorTimestamp>
|
||||
<!-- suppressGeneratorTimestamp=false is the default -->
|
||||
<suppressGeneratorTimestamp>false</suppressGeneratorTimestamp>
|
||||
</options>
|
||||
</configuration>
|
||||
<executions>
|
||||
|
Loading…
x
Reference in New Issue
Block a user