Clover icon

sunshower-sdk

  1. Project Clover database Sat May 12 2018 05:15:40 UTC
  2. Package io.sunshower.sdk.common.jaxb

File DefaultJAXBContextResolver.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart2.png
38% of files have more coverage

Code metrics

0
7
3
1
48
37
5
0.71
2.33
3
1.67

Classes

Class Line # Actions
DefaultJAXBContextResolver 17 7 5
0.220%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package io.sunshower.sdk.common.jaxb;
2   
3    import io.sunshower.common.ws.jaxb.JAXBContextResolver;
4   
5    import javax.ws.rs.core.MediaType;
6    import javax.ws.rs.core.MultivaluedHashMap;
7    import javax.xml.bind.JAXBContext;
8    import javax.xml.bind.JAXBException;
9    import java.lang.annotation.Annotation;
10    import java.util.Arrays;
11    import java.util.Collections;
12    import java.util.HashSet;
13   
14    /**
15    * Created by haswell on 6/4/17.
16    */
 
17    public class DefaultJAXBContextResolver implements JAXBContextResolver {
18   
19    private final CachingJAXBContextAwareMOxyJSONProvider provider;
20   
 
21  7 toggle public DefaultJAXBContextResolver(CachingJAXBContextAwareMOxyJSONProvider provider) {
22  7 this.provider = provider;
23    }
24   
25   
 
26  0 toggle @Override
27    public JAXBContext getContext(MediaType mediaType, Class<?>[] classes) {
28  0 try {
29  0 return provider.getJAXBContext(
30    new HashSet<>(Arrays.asList(classes)),
31    new Annotation[0],
32    mediaType,
33    new MultivaluedHashMap<>()
34    );
35    } catch (JAXBException e) {
36  0 throw new RuntimeException("Failed to resolve context", e);
37    }
38    }
39   
 
40  0 toggle @Override
41    public JAXBContext getContext(Class<?> aClass, MediaType mediaType) {
42  0 try {
43  0 return provider.getJAXBContext(Collections.singleton(aClass), new Annotation[0], mediaType, new MultivaluedHashMap<>());
44    } catch (JAXBException e) {
45  0 throw new RuntimeException("Failed to resolve context", e);
46    }
47    }
48    }