Clover icon

sunshower-core

  1. Project Clover database Fri Apr 6 2018 03:27:42 UTC
  2. Package io.sunshower.service.hal.core

File Properties.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart4.png
46% of files have more coverage

Code metrics

2
12
9
1
66
52
10
0.83
1.33
9
1.11

Classes

Class Line # Actions
Properties 15 12 10
0.347826134.8%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    package io.sunshower.service.hal.core;
2   
3    import io.sunshower.common.rs.MapAdapter;
4    import java.util.HashMap;
5    import java.util.Map;
6    import java.util.Objects;
7    import javax.xml.bind.annotation.XmlAnyElement;
8    import javax.xml.bind.annotation.XmlElement;
9    import javax.xml.bind.annotation.XmlRootElement;
10    import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
11    import org.eclipse.persistence.oxm.annotations.XmlInverseReference;
12   
13    /** Created by haswell on 5/22/17. */
14    @XmlRootElement(name = "properties")
 
15    public class Properties {
16   
17    @XmlElement
18    @XmlInverseReference(mappedBy = "properties")
19    private Element element;
20   
21    @XmlElement
22    @XmlAnyElement(lax = true)
23    @XmlJavaTypeAdapter(MapAdapter.class)
24    private Map<String, Object> properties;
25   
 
26  1 toggle public Properties() {}
27   
 
28  0 toggle public Properties(Element element) {
29  0 Objects.requireNonNull(element, "Element may not be null using this constructor!");
30    }
31   
 
32  1 toggle public <T> void put(String key, T value) {
33  1 checkProperties();
34  1 properties.put(key, value);
35    }
36   
 
37  0 toggle @SuppressWarnings("unchecked")
38    public <T> T getProperty(String key, Class<T> type) {
39  0 checkProperties();
40  0 return (T) properties.get(key);
41    }
42   
 
43  0 toggle @SuppressWarnings("unchecked")
44    public <T> T getProperty(String key) {
45  0 checkProperties();
46  0 return (T) properties.get(key);
47    }
48   
 
49  0 toggle public Map<String, Object> getProperties() {
50  0 return properties;
51    }
52   
 
53  0 toggle public void setProperties(Map<String, Object> properties) {
54  0 this.properties = properties;
55    }
56   
 
57  0 toggle public boolean contains(String key) {
58  0 return properties != null && properties.containsKey(key);
59    }
60   
 
61  1 toggle private void checkProperties() {
62  1 if (properties == null) {
63  1 properties = new HashMap<>();
64    }
65    }
66    }