Passed
Push — master ( 9be3b9...480662 )
by
unknown
08:13
created

findClasses()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
dl 0
loc 2
rs 10
1
package com.hltech.pact.gen.domain.client.annotation;
2
3
import com.google.common.collect.Lists;
4
import com.hltech.pact.gen.domain.client.annotation.handlers.AnnotatedMethodHandler;
5
import lombok.RequiredArgsConstructor;
6
import org.reflections.Reflections;
7
8
import java.util.List;
9
10
@RequiredArgsConstructor
11
public class MappingHandlerFactory {
12
13
    private static final String PACKAGE = "com.hltech.pact.gen";
14
15
    private final HandlersFactory handlersFactory;
16
17
    public List<AnnotatedMethodHandler> createAll() {
18
        try {
19
            return handlersFactory.createHandlers(findClasses());
20
        } catch (IllegalAccessException | InstantiationException exception) {
21
            throw new MappingMethodCreationException("Cannot create mapping handler", exception);
22
        }
23
    }
24
25
    private List<Class<?>> findClasses() {
26
        return Lists.newArrayList(new Reflections(PACKAGE).getTypesAnnotatedWith(MappingMethodHandler.class));
27
    }
28
}
29