Clover icon

sunshower-sdk

  1. Project Clover database Wed Apr 4 2018 21:39:43 UTC
  2. Package io.sunshower.sdk.core.jaxrs

File IdentifierParameterConverter.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart0.png
34% of files have more coverage

Code metrics

6
9
3
2
41
34
6
0.67
3
1.5
2

Classes

Class Line # Actions
IdentifierParameterConverter 12 3 2
0.00%
IdentifierParameterConverter.IdentifierParamConverter 23 6 4
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package io.sunshower.sdk.core.jaxrs;
2   
3    import io.sunshower.common.Identifier;
4   
5    import javax.ws.rs.ext.ParamConverter;
6    import javax.ws.rs.ext.ParamConverterProvider;
7    import javax.ws.rs.ext.Provider;
8    import java.lang.annotation.Annotation;
9    import java.lang.reflect.Type;
10   
11    @Provider
 
12    public class IdentifierParameterConverter implements ParamConverterProvider {
13   
 
14  0 toggle @Override
15    @SuppressWarnings("unchecked")
16    public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) {
17  0 if(Identifier.class.equals(rawType)) {
18  0 return (ParamConverter<T>) new IdentifierParamConverter();
19    }
20  0 return null;
21    }
22   
 
23    private static class IdentifierParamConverter implements ParamConverter<Identifier> {
24   
 
25  0 toggle @Override
26    public Identifier fromString(String value) {
27  0 if(value == null) {
28  0 return null;
29    }
30  0 return Identifier.valueOf(value);
31    }
32   
 
33  0 toggle @Override
34    public String toString(Identifier value) {
35  0 if(value == null) {
36  0 return null;
37    }
38  0 return value.toString();
39    }
40    }
41    }