Skip to content

Package: ContainerValueDescriptor

ContainerValueDescriptor

nameinstructionbranchcomplexitylinemethod
ContainerValueDescriptor(ContainerDescriptor.Type, NamedResource, Assertion, URI)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
addValue(Object)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
altValueDescriptor(NamedResource, Assertion)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
altValueDescriptor(NamedResource, Assertion, URI)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
bagValueDescriptor(NamedResource, Assertion)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
bagValueDescriptor(NamedResource, Assertion, URI)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
equals(Object)
M: 26 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
getValues()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hashCode()
M: 15 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
seqValueDescriptor(NamedResource, Assertion)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
seqValueDescriptor(NamedResource, Assertion, URI)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: package cz.cvut.kbss.ontodriver.descriptor;
2:
3: import cz.cvut.kbss.ontodriver.model.Assertion;
4: import cz.cvut.kbss.ontodriver.model.NamedResource;
5:
6: import java.net.URI;
7: import java.util.ArrayList;
8: import java.util.Collections;
9: import java.util.List;
10: import java.util.Objects;
11:
12: /**
13: * Descriptor for saving values in an RDF container.
14: *
15: * @param <T> Value type
16: */
17: public class ContainerValueDescriptor<T> extends ContainerDescriptor {
18:
19: private final List<T> values = new ArrayList<>();
20:
21: private ContainerValueDescriptor(Type type, NamedResource owner, Assertion property, URI context) {
22: super(type, owner, property, context);
23: }
24:
25: public List<T> getValues() {
26: return Collections.unmodifiableList(values);
27: }
28:
29: public void addValue(T value) {
30: values.add(Objects.requireNonNull(value));
31: }
32:
33: /**
34: * Creates a new {@link ContainerValueDescriptor} for saving an {@literal rdf:Alt} container to the default
35: * context.
36: *
37: * @param owner Container owner
38: * @param property Property referencing the container
39: * @param <T> Value type
40: * @return Empty container value descriptor
41: */
42: public static <T> ContainerValueDescriptor<T> altValueDescriptor(NamedResource owner, Assertion property) {
43: return new ContainerValueDescriptor<>(Type.ALT, owner, property, null);
44: }
45:
46: /**
47: * Creates a new {@link ContainerValueDescriptor} for saving an {@literal rdf:Alt} container to the specified
48: * context.
49: *
50: * @param owner Container owner
51: * @param property Property referencing the container
52: * @param context Context to which the container should be saved
53: * @param <T> Value type
54: * @return Empty container value descriptor
55: */
56: public static <T> ContainerValueDescriptor<T> altValueDescriptor(NamedResource owner, Assertion property,
57: URI context) {
58: return new ContainerValueDescriptor<>(Type.ALT, owner, property, context);
59: }
60:
61: /**
62: * Creates a new {@link ContainerValueDescriptor} for saving an {@literal rdf:Bag} container to the default
63: * context.
64: *
65: * @param owner Container owner
66: * @param property Property referencing the container
67: * @param <T> Value type
68: * @return Empty container value descriptor
69: */
70: public static <T> ContainerValueDescriptor<T> bagValueDescriptor(NamedResource owner, Assertion property) {
71: return new ContainerValueDescriptor<>(Type.BAG, owner, property, null);
72: }
73:
74: /**
75: * Creates a new {@link ContainerValueDescriptor} for saving an {@literal rdf:Bag} container to the specified
76: * context.
77: *
78: * @param owner Container owner
79: * @param property Property referencing the container
80: * @param context Context to which the container should be saved
81: * @param <T> Value type
82: * @return Empty container value descriptor
83: */
84: public static <T> ContainerValueDescriptor<T> bagValueDescriptor(NamedResource owner, Assertion property,
85: URI context) {
86: return new ContainerValueDescriptor<>(Type.BAG, owner, property, context);
87: }
88:
89: /**
90: * Creates a new {@link ContainerValueDescriptor} for saving an {@literal rdf:Seq} container to the default
91: * context.
92: *
93: * @param owner Container owner
94: * @param property Property referencing the container
95: * @param <T> Value type
96: * @return Empty container value descriptor
97: */
98: public static <T> ContainerValueDescriptor<T> seqValueDescriptor(NamedResource owner, Assertion property) {
99: return new ContainerValueDescriptor<>(Type.SEQ, owner, property, null);
100: }
101:
102: /**
103: * Creates a new {@link ContainerValueDescriptor} for saving an {@literal rdf:Seq} container to the specified
104: * context.
105: *
106: * @param owner Container owner
107: * @param property Property referencing the container
108: * @param context Context to which the container should be saved
109: * @param <T> Value type
110: * @return Empty container value descriptor
111: */
112: public static <T> ContainerValueDescriptor<T> seqValueDescriptor(NamedResource owner, Assertion property,
113: URI context) {
114: return new ContainerValueDescriptor<>(Type.SEQ, owner, property, context);
115: }
116:
117: @Override
118: public boolean equals(Object o) {
119:• if (this == o) {
120: return true;
121: }
122:• if (!(o instanceof ContainerValueDescriptor<?> that)) {
123: return false;
124: }
125:• if (!super.equals(o)) {
126: return false;
127: }
128: return Objects.equals(getValues(), that.getValues());
129: }
130:
131: @Override
132: public int hashCode() {
133: return Objects.hash(super.hashCode(), getValues());
134: }
135: }