Clover icon

sunshower-sdk

  1. Project Clover database Sat May 12 2018 05:15:40 UTC
  2. Package io.sunshower.sdk.v1.model.core.converters

File ClassConverter.java

 

Coverage histogram

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

Code metrics

4
6
2
1
32
25
5
0.83
3
2
2.5

Classes

Class Line # Actions
ClassConverter 11 6 5
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package io.sunshower.sdk.v1.model.core.converters;
2   
3    import io.sunshower.sdk.v1.model.core.faults.InvalidElementException;
4    import io.sunshower.sdk.v1.model.core.faults.NullElementException;
5   
6    import javax.xml.bind.annotation.adapters.XmlAdapter;
7   
8    /**
9    * Created by haswell on 3/17/17.
10    */
 
11    public class ClassConverter extends XmlAdapter<String, Class<?>> {
 
12  0 toggle @Override
13    public String marshal(Class<?> v) throws Exception {
14  0 return v == null ? void.class.getName() : v.getName();
15    }
16   
 
17  0 toggle @Override
18    public Class<?> unmarshal(String v) throws Exception {
19  0 if(v == null) {
20  0 throw new NullElementException(void.class);
21    }
22  0 try {
23  0 return Class.forName(v);
24    } catch(Exception ex) {
25  0 throw new InvalidElementException(
26    "%s is not a valid type",
27    void.class,
28    v
29    );
30    }
31    }
32    }