aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckConverter.java
blob: ed06018e7b59ff1a1939da9385ab60bc2685778a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package org.onap.so.apihandlerinfra;

import java.net.URI;
import javax.ws.rs.core.UriBuilder;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.stereotype.Component;

@Component
public class HealthCheckConverter {


    public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
        if (sourceType.getType() == String.class && targetType.getType() == Subsystem.class) {
            return SoSubsystems.valueOf(((String) source).toUpperCase());
        } else if (sourceType.getType() == String.class && targetType.getType() == URI.class) {
            return UriBuilder.fromUri((String) source).build();
        } else {
            return source;
        }
    }

}