Clover icon

sunshower-core

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

File Graph.java

 

Coverage histogram

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

Code metrics

10
16
9
1
75
60
14
0.88
1.78
9
1.56

Classes

Class Line # Actions
Graph 14 16 14
0.657142965.7%
 

Contributing tests

This file is covered by 7 tests. .

Source view

1    package io.sunshower.service.hal.core;
2   
3    import io.sunshower.common.Identifier;
4    import io.sunshower.common.rs.MapAdapter;
5    import io.sunshower.persist.Sequence;
6    import io.sunshower.persistence.core.DistributableEntity;
7    import io.sunshower.service.model.PropertyAwareObject;
8    import java.util.*;
9    import javax.xml.bind.annotation.XmlElement;
10    import javax.xml.bind.annotation.XmlRootElement;
11    import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
12   
13    @XmlRootElement(name = "graph")
 
14    public class Graph extends PropertyAwareObject<Graph> {
15   
16    @XmlElement(name = "edges", type = Edge.class)
17    private Set<Edge> edges;
18   
19    @XmlElement(name = "vertices", type = Vertex.class)
20    private Set<Vertex> vertices;
21   
22    @XmlElement(name = "layout")
23    private GlobalLayout layout;
24   
25    @XmlElement(name = "styles")
26    @XmlJavaTypeAdapter(MapAdapter.class)
27    private Map<String, Stylesheet> styles;
28   
 
29  14 toggle public Graph() {
30  14 super(Graph.class);
31  14 setId(DistributableEntity.sequence.next());
32    }
33   
 
34  2 toggle public Set<Edge> getEdges() {
35  2 return edges == null ? Collections.emptySet() : edges;
36    }
37   
 
38  0 toggle public void setEdges(Set<Edge> edges) {
39  0 this.edges = edges;
40    }
41   
 
42  1 toggle public Set<Vertex> getVertices() {
43  1 return vertices == null ? Collections.emptySet() : vertices;
44    }
45   
 
46  0 toggle public void setVertices(Set<Vertex> vertices) {
47  0 this.vertices = vertices;
48    }
49   
 
50  6 toggle public void addEdge(Edge e) {
51  6 if (edges == null) {
52  4 edges = new HashSet<>();
53    }
54  6 edges.add(e);
55    }
56   
 
57  11 toggle public void addVertex(Vertex v) {
58  11 if (vertices == null) {
59  5 vertices = new HashSet<>();
60    }
61  11 vertices.add(v);
62    }
63   
 
64  0 toggle public void addStyle(String key, Stylesheet stylesheet) {
65  0 if (styles == null) {
66  0 styles = new HashMap<>();
67    }
68  0 styles.put(key, stylesheet);
69    }
70   
 
71  14 toggle @Override
72    public Sequence<Identifier> getSequence() {
73  14 return DistributableEntity.sequence;
74    }
75    }