Skip to content

Package: PropertiesSpecificationImpl$PropertiesSpecificationBuilder

PropertiesSpecificationImpl$PropertiesSpecificationBuilder

nameinstructionbranchcomplexitylinemethod
PropertiesSpecificationImpl.PropertiesSpecificationBuilder()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
build()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
declaringType(ManagedType)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
fetchType(FetchType)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
inferred(boolean)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
javaField(Field)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
javaType(Class)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
propertyIdType(Class)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
propertyValueType(Class)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2020 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.model.metamodel;
16:
17: import cz.cvut.kbss.jopa.model.annotations.FetchType;
18:
19: import java.lang.reflect.Field;
20:
21: public class PropertiesSpecificationImpl<X, Y, K, V> implements PropertiesSpecification<X, Y, K, V> {
22: private final ManagedType<X> declaringType;
23: private final FetchType fetchType;
24: private final Field javaField;
25: private final Class<Y> javaType;
26: private final boolean inferred;
27: private final Class<K> propertyIdType;
28: private final Class<V> propertyValueType;
29:
30: private PropertiesSpecificationImpl(PropertiesSpecificationBuilder<X, Y, K, V> builder) {
31: this.declaringType = builder.declaringType;
32: this.fetchType = builder.fetchType;
33: this.javaField = builder.javaField;
34: this.javaType = builder.javaType;
35: this.inferred = builder.inferred;
36: this.propertyIdType = builder.propertyIdType;
37: this.propertyValueType = builder.propertyValueType;
38: }
39:
40: @Override
41: public ManagedType<X> getDeclaringType() {
42: return declaringType;
43: }
44:
45: @Override
46: public FetchType getFetchType() {
47: return fetchType;
48: }
49:
50: @Override
51: public Field getJavaField() {
52: return javaField;
53: }
54:
55: @Override
56: public Class<Y> getJavaType() {
57: return javaType;
58: }
59:
60: @Override
61: public boolean isInferred() {
62: return inferred;
63: }
64:
65: @Override
66: public boolean includeExplicit() {
67: // TODO
68: return true;
69: }
70:
71: @Override
72: public String getName() {
73: return javaField.getName();
74: }
75:
76: @Override
77: public boolean isCollection() {
78: return true;
79: }
80:
81: @Override
82: public Class<K> getPropertyIdentifierType() {
83: return propertyIdType;
84: }
85:
86: @Override
87: public Class<V> getPropertyValueType() {
88: return propertyValueType;
89: }
90:
91: public static <X, Y, K, V> PropertiesSpecificationBuilder declaringType(ManagedType<X> declaringType) {
92: return new PropertiesSpecificationBuilder<X, Y, K, V>().declaringType(declaringType);
93: }
94:
95: public static class PropertiesSpecificationBuilder<X, Y, K, V> {
96: private ManagedType<X> declaringType;
97: private FetchType fetchType;
98: private Field javaField;
99: private Class<Y> javaType;
100: private boolean inferred;
101: private Class<K> propertyIdType;
102: private Class<V> propertyValueType;
103:
104: public PropertiesSpecificationBuilder<X, Y, K, V> declaringType(ManagedType<X> declaringType) {
105: this.declaringType = declaringType;
106: return this;
107: }
108:
109: public PropertiesSpecificationBuilder<X, Y, K, V> fetchType(FetchType fetchType) {
110: this.fetchType = fetchType;
111: return this;
112: }
113:
114: public PropertiesSpecificationBuilder<X, Y, K, V> javaField(Field javaField) {
115: this.javaField = javaField;
116: return this;
117: }
118:
119: public PropertiesSpecificationBuilder<X, Y, K, V> javaType(Class<Y> javaType) {
120: this.javaType = javaType;
121: return this;
122: }
123:
124: public PropertiesSpecificationBuilder<X, Y, K, V> inferred(boolean inferred) {
125: this.inferred = inferred;
126: return this;
127: }
128:
129: public PropertiesSpecificationBuilder<X, Y, K, V> propertyIdType(Class<K> propertyIdType) {
130: this.propertyIdType = propertyIdType;
131: return this;
132: }
133:
134: public PropertiesSpecificationBuilder<X, Y, K, V> propertyValueType(Class<V> propertyValueType) {
135: this.propertyValueType = propertyValueType;
136: return this;
137: }
138:
139: public PropertiesSpecificationImpl<X, Y, K, V> build() {
140: return new PropertiesSpecificationImpl<>(this);
141: }
142: }
143: }