use of com.cognifide.apm.api.actions.annotations.Mapper in project APM by Cognifide.
the class MapperDescriptorFactory method create.
public MapperDescriptor create(Class<?> mapperClass) {
Mapper mapperAnnotation = mapperClass.getDeclaredAnnotation(Mapper.class);
if (mapperAnnotation == null) {
throw new InvalidActionMapperException("Mapper must be annotated with " + Mapper.class.getName());
}
final Object mapper = createInstance(mapperClass);
final String name = mapperAnnotation.value();
final String group = mapperAnnotation.group();
final List<MappingDescriptor> mappingDescriptors = Lists.newArrayList();
for (Method method : mapperClass.getDeclaredMethods()) {
create(mapperAnnotation, method).ifPresent(mappingDescriptors::add);
}
return new MapperDescriptor(mapper, name, group, ImmutableList.copyOf(mappingDescriptors));
}
Aggregations