Merge "add junit coverage"
[so.git] / mso-api-handlers / mso-api-handler-infra / src / main / java / org / onap / so / apihandlerinfra / GenericStringConverter.java
1 package org.onap.so.apihandlerinfra;
2
3 import java.net.URI;
4 import java.util.Set;
5 import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
7 import org.springframework.core.convert.TypeDescriptor;
8 import org.springframework.core.convert.converter.GenericConverter;
9 import org.springframework.stereotype.Component;
10 import com.google.common.collect.ImmutableSet;
11
12 @Component
13 @ConfigurationPropertiesBinding
14 public class GenericStringConverter implements GenericConverter {
15
16     @Autowired
17     private HealthCheckConverter converter;
18
19     @Override
20     public Set<ConvertiblePair> getConvertibleTypes() {
21
22         ConvertiblePair[] pairs = new ConvertiblePair[] {new ConvertiblePair(String.class, Subsystem.class),
23                 new ConvertiblePair(String.class, URI.class)};
24         return ImmutableSet.copyOf(pairs);
25     }
26
27     @Override
28     public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
29
30         return converter.convert(source, sourceType, targetType);
31
32     }
33 }