Clover icon

sunshower-core

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

File Property.java

 

Coverage histogram

../../../../img/srcFileCovDistChart7.png
24% of files have more coverage

Code metrics

2
23
12
2
109
89
15
0.65
1.92
6
1.25

Classes

Class Line # Actions
Property 19 23 15
0.648648664.9%
Property.Type 21 0 0
-1.0 -
 

Contributing tests

This file is covered by 7 tests. .

Source view

1    package io.sunshower.service.model;
2   
3    import io.sunshower.common.rs.TypeAttributeClassExtractor;
4    import io.sunshower.persistence.core.DistributableEntity;
5    import javax.persistence.*;
6    import javax.xml.bind.annotation.XmlAttribute;
7    import javax.xml.bind.annotation.XmlElement;
8    import javax.xml.bind.annotation.XmlRootElement;
9    import lombok.Getter;
10    import lombok.Setter;
11    import org.eclipse.persistence.oxm.annotations.XmlClassExtractor;
12   
13    @Entity
14    @Getter
15    @Setter
16    @XmlRootElement(name = "property")
17    @Table(name = "PROPERTY", schema = "SUNSHOWER")
18    @XmlClassExtractor(TypeAttributeClassExtractor.class)
 
19    public class Property extends DistributableEntity {
20   
 
21    public enum Type implements PropertyType {
22    Integer,
23    String,
24    Boolean,
25    Secret,
26    Class
27    }
28   
29    @Basic
30    @XmlElement
31    @Column(name = "property_key")
32    private String key;
33   
34    @Basic
35    @XmlElement
36    @Column(name = "name")
37    private String name;
38   
39    @Basic @XmlElement private String value;
40   
41    @Enumerated
42    @Column(name = "type")
43    @XmlAttribute(name = "property-type")
44    private Type propertyType = Type.String;
45   
46    @Transient
47    @XmlAttribute(name = "type")
48    private Class<?> type = Property.class;
49   
 
50  17 toggle public Property() {}
51   
 
52  18 toggle public static Property string(String key, String name, String value) {
53  18 return new Property(Type.String, key, name, value);
54    }
55   
 
56  1 toggle public static Property integer(String key, String name, String value) {
57  1 return new Property(Type.Integer, key, name, value);
58    }
59   
 
60  0 toggle public static Property secret(String key, String name, String value) {
61  0 return new Property(Type.Secret, key, name, value);
62    }
63   
 
64  0 toggle public static Property bool(String key, String name, String value) {
65  0 return new Property(Type.Secret, key, name, value);
66    }
67   
 
68  22 toggle public Property(Type type, String key, String name, String value) {
69  22 setPropertyType(type);
70  22 setKey(key);
71  22 setName(name);
72  22 setValue(value);
73    }
74   
 
75  22 toggle public void setValue(String value) {
76  22 if (value == null) {
77  0 return;
78    }
79  22 switch (propertyType) {
80  1 case Integer:
81  1 Long.parseLong(value);
82  1 break;
83  0 case Boolean:
84  0 Boolean.parseBoolean(value);
85  0 break;
86    }
87  22 this.value = value;
88    }
89   
 
90  0 toggle public boolean isResolved() {
91  0 return getValue() != null;
92    }
93   
 
94  22 toggle public String getKey() {
95  22 return key;
96    }
97   
 
98  22 toggle public void setKey(String key) {
99  22 this.key = key;
100    }
101   
 
102  0 toggle public String getName() {
103  0 return name;
104    }
105   
 
106  22 toggle public void setName(String name) {
107  22 this.name = name;
108    }
109    }