Passed
Pull Request — master (#33)
by
unknown
07:29
created

createAll()   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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