Search in sources :

Example 1 with Mapper

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));
}
Also used : Mapper(com.cognifide.apm.api.actions.annotations.Mapper) InvalidActionMapperException(com.cognifide.apm.api.exceptions.InvalidActionMapperException) ApmString(com.cognifide.apm.core.grammar.ApmString) Method(java.lang.reflect.Method)

Aggregations

Mapper (com.cognifide.apm.api.actions.annotations.Mapper)1 InvalidActionMapperException (com.cognifide.apm.api.exceptions.InvalidActionMapperException)1 ApmString (com.cognifide.apm.core.grammar.ApmString)1 Method (java.lang.reflect.Method)1