use of org.mapstruct.ap.internal.model.source.ParameterProvidedMethods in project mapstruct by mapstruct.
the class PresenceCheckMethodResolver method getAllAvailableMethods.
private static List<SourceMethod> getAllAvailableMethods(Method method, List<SourceMethod> sourceModelMethods) {
ParameterProvidedMethods contextProvidedMethods = method.getContextProvidedMethods();
if (contextProvidedMethods.isEmpty()) {
return sourceModelMethods;
}
List<SourceMethod> methodsProvidedByParams = contextProvidedMethods.getAllProvidedMethodsInParameterOrder(method.getContextParameters());
List<SourceMethod> availableMethods = new ArrayList<>(methodsProvidedByParams.size() + sourceModelMethods.size());
for (SourceMethod methodProvidedByParams : methodsProvidedByParams) {
// add only methods from context that do have the @Condition annotation
if (methodProvidedByParams.isPresenceCheck()) {
availableMethods.add(methodProvidedByParams);
}
}
availableMethods.addAll(sourceModelMethods);
return availableMethods;
}
use of org.mapstruct.ap.internal.model.source.ParameterProvidedMethods in project mapstruct by mapstruct.
the class LifecycleMethodResolver method getAllAvailableMethods.
private static List<SourceMethod> getAllAvailableMethods(Method method, List<SourceMethod> sourceModelMethods) {
ParameterProvidedMethods contextProvidedMethods = method.getContextProvidedMethods();
if (contextProvidedMethods.isEmpty()) {
return sourceModelMethods;
}
List<SourceMethod> methodsProvidedByParams = contextProvidedMethods.getAllProvidedMethodsInParameterOrder(method.getContextParameters());
List<SourceMethod> availableMethods = new ArrayList<>(methodsProvidedByParams.size() + sourceModelMethods.size());
availableMethods.addAll(methodsProvidedByParams);
availableMethods.addAll(sourceModelMethods);
return availableMethods;
}
use of org.mapstruct.ap.internal.model.source.ParameterProvidedMethods in project mapstruct by mapstruct.
the class MethodRetrievalProcessor method retrieveContextProvidedMethods.
private ParameterProvidedMethods retrieveContextProvidedMethods(List<Parameter> contextParameters, TypeElement mapperToImplement, MapperOptions mapperConfig) {
ParameterProvidedMethods.Builder builder = ParameterProvidedMethods.builder();
for (Parameter contextParam : contextParameters) {
if (contextParam.getType().isPrimitive() || contextParam.getType().isArrayType()) {
continue;
}
List<SourceMethod> contextParamMethods = retrieveMethods(contextParam.getType().getTypeElement(), mapperToImplement, mapperConfig, Collections.emptyList());
List<SourceMethod> contextProvidedMethods = new ArrayList<>(contextParamMethods.size());
for (SourceMethod sourceMethod : contextParamMethods) {
if (sourceMethod.isLifecycleCallbackMethod() || sourceMethod.isObjectFactory() || sourceMethod.isPresenceCheck()) {
contextProvidedMethods.add(sourceMethod);
}
}
builder.addMethodsForParameter(contextParam, contextProvidedMethods);
}
return builder.build();
}
Aggregations