Clover icon

sunshower-core

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

File PropertyGraph.java

 

Coverage histogram

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

Code metrics

12
15
7
1
76
65
13
0.87
2.14
7
1.86

Classes

Class Line # Actions
PropertyGraph 13 15 13
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package io.sunshower.service.model;
2   
3    import java.util.Collection;
4    import java.util.Collections;
5    import java.util.HashSet;
6    import java.util.Set;
7    import javax.persistence.CascadeType;
8    import javax.persistence.FetchType;
9    import javax.persistence.MappedSuperclass;
10    import javax.persistence.OneToMany;
11   
12    @MappedSuperclass
 
13    public class PropertyGraph<
14    V extends PropertyGraphElement<G>,
15    E extends PropertyGraphElement<G>,
16    G extends PropertyGraph<V, E, G>>
17    extends PropertyAwareObject<G> {
18   
19    @OneToMany(
20    mappedBy = "graph",
21    fetch = FetchType.LAZY,
22    cascade = CascadeType.ALL,
23    orphanRemoval = true
24    )
25    private Set<E> edges;
26   
27    @OneToMany(
28    mappedBy = "graph",
29    fetch = FetchType.LAZY,
30    cascade = CascadeType.ALL,
31    orphanRemoval = true
32    )
33    private Set<V> vertices;
34   
 
35  0 toggle protected PropertyGraph(Class<G> type) {
36  0 super(type);
37    }
38   
 
39  0 toggle @SuppressWarnings("unchecked")
40    public void addEdge(E edge) {
41  0 if (edges == null) {
42  0 edges = new HashSet<>();
43    }
44  0 if (edge != null) {
45  0 edge.setGraph((G) this);
46  0 edges.add(edge);
47    }
48    }
49   
 
50  0 toggle @SuppressWarnings("unchecked")
51    public void addVertex(V vertex) {
52  0 if (vertices == null) {
53  0 vertices = new HashSet<>();
54    }
55  0 if (vertex != null) {
56  0 vertex.setGraph((G) this);
57  0 vertices.add(vertex);
58    }
59    }
60   
 
61  0 toggle public Set<E> getEdges() {
62  0 return edges == null ? Collections.emptySet() : edges;
63    }
64   
 
65  0 toggle public void setEdges(Collection<E> edges) {
66  0 this.edges = new HashSet<>(edges);
67    }
68   
 
69  0 toggle public Set<V> getVertices() {
70  0 return vertices == null ? Collections.emptySet() : vertices;
71    }
72   
 
73  0 toggle public void setVertices(Collection<V> vertices) {
74  0 this.vertices = new HashSet<>(vertices);
75    }
76    }