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

com.hltech.pact.gen.domain.client.annotation.MappingHandlerFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 17
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findClasses() 0 2 1
A createAll() 0 5 2
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