mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#557 add Javadoc for the Accessor
This commit is contained in:
parent
f94990270f
commit
228c1f9f1b
@ -261,11 +261,13 @@ public class TypeFactory {
|
|||||||
* Get the ExecutableType for given method as part of usedMapper. Possibly parameterized types in method declaration
|
* Get the ExecutableType for given method as part of usedMapper. Possibly parameterized types in method declaration
|
||||||
* will be evaluated to concrete types then.
|
* will be evaluated to concrete types then.
|
||||||
*
|
*
|
||||||
|
* <b>IMPORTANT:</b> This should only be used from the Processors, as they are operating over executable elements.
|
||||||
|
* The internals should not be using this function and should not be using the {@link ExecutableElement} directly.
|
||||||
|
*
|
||||||
* @param includingType the type on which's scope the method type shall be evaluated
|
* @param includingType the type on which's scope the method type shall be evaluated
|
||||||
* @param method the method
|
* @param method the method
|
||||||
* @return the ExecutableType representing the method as part of usedMapper
|
* @return the ExecutableType representing the method as part of usedMapper
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public ExecutableType getMethodType(DeclaredType includingType, ExecutableElement method) {
|
public ExecutableType getMethodType(DeclaredType includingType, ExecutableElement method) {
|
||||||
TypeMirror asMemberOf = typeUtils.asMemberOf( includingType, method );
|
TypeMirror asMemberOf = typeUtils.asMemberOf( includingType, method );
|
||||||
return (ExecutableType) asMemberOf;
|
return (ExecutableType) asMemberOf;
|
||||||
@ -301,10 +303,11 @@ public class TypeFactory {
|
|||||||
|
|
||||||
public List<Parameter> getParameters(DeclaredType includingType, Accessor accessor) {
|
public List<Parameter> getParameters(DeclaredType includingType, Accessor accessor) {
|
||||||
ExecutableElement method = accessor.getExecutable();
|
ExecutableElement method = accessor.getExecutable();
|
||||||
if ( method == null ) {
|
TypeMirror methodType = getMethodType( includingType, accessor.getElement() );
|
||||||
|
if ( method == null || methodType.getKind() != TypeKind.EXECUTABLE ) {
|
||||||
return new ArrayList<Parameter>();
|
return new ArrayList<Parameter>();
|
||||||
}
|
}
|
||||||
return getParameters( getMethodType( includingType, method ), method );
|
return getParameters( (ExecutableType) methodType, method );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Parameter> getParameters(ExecutableType methodType, ExecutableElement method) {
|
public List<Parameter> getParameters(ExecutableType methodType, ExecutableElement method) {
|
||||||
@ -330,11 +333,6 @@ public class TypeFactory {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public Type getReturnType(DeclaredType includingType, ExecutableElement method) {
|
|
||||||
return getReturnType( getMethodType( includingType, method ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getReturnType(DeclaredType includingType, Accessor accessor) {
|
public Type getReturnType(DeclaredType includingType, Accessor accessor) {
|
||||||
Type type;
|
Type type;
|
||||||
TypeMirror accessorType = getMethodType( includingType, accessor.getElement() );
|
TypeMirror accessorType = getMethodType( includingType, accessor.getElement() );
|
||||||
@ -356,10 +354,6 @@ public class TypeFactory {
|
|||||||
return getType( method.getReturnType() );
|
return getType( method.getReturnType() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Type> getThrownTypes(DeclaredType includingType, ExecutableElement method) {
|
|
||||||
return getThrownTypes( getMethodType( includingType, method ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Type> getThrownTypes(ExecutableType method) {
|
public List<Type> getThrownTypes(ExecutableType method) {
|
||||||
List<Type> thrownTypes = new ArrayList<Type>();
|
List<Type> thrownTypes = new ArrayList<Type>();
|
||||||
for ( TypeMirror exceptionType : method.getThrownTypes() ) {
|
for ( TypeMirror exceptionType : method.getThrownTypes() ) {
|
||||||
|
@ -26,17 +26,39 @@ import javax.lang.model.element.Name;
|
|||||||
import javax.lang.model.type.TypeMirror;
|
import javax.lang.model.type.TypeMirror;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This represents an Accessor that can be used for writing/reading a property to/from a bean.
|
||||||
|
*
|
||||||
* @author Filip Hrisafov
|
* @author Filip Hrisafov
|
||||||
*/
|
*/
|
||||||
public interface Accessor {
|
public interface Accessor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the type that this accessor gives as a return.
|
||||||
|
*
|
||||||
|
* e.g. The {@link ExecutableElement#getReturnType()} if this is a method accessor,
|
||||||
|
* or {@link javax.lang.model.element.VariableElement#asType()} for field accessors.
|
||||||
|
*
|
||||||
|
* @return the type that the accessor gives as a return
|
||||||
|
*/
|
||||||
TypeMirror getAccessedType();
|
TypeMirror getAccessedType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the simple name of the accessor
|
||||||
|
*/
|
||||||
Name getSimpleName();
|
Name getSimpleName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the set of modifiers that the accessor has
|
||||||
|
*/
|
||||||
Set<Modifier> getModifiers();
|
Set<Modifier> getModifiers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the {@link ExecutableElement}, or {@code null} if the accessor does not have one
|
||||||
|
*/
|
||||||
ExecutableElement getExecutable();
|
ExecutableElement getExecutable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the underlying {@link Element}
|
||||||
|
*/
|
||||||
Element getElement();
|
Element getElement();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user