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) 2016 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 boolean isReadOnly() {
73: // TODO
74: return false;
75: }
76:
77: @Override
78: public String getName() {
79: return javaField.getName();
80: }
81:
82: @Override
83: public Class<K> getPropertyIdentifierType() {
84: return propertyIdType;
85: }
86:
87: @Override
88: public Class<V> getPropertyValueType() {
89: return propertyValueType;
90: }
91:
92: public static <X, Y, K, V> PropertiesSpecificationBuilder declaringType(ManagedType<X> declaringType) {
93: return new PropertiesSpecificationBuilder<X, Y, K, V>().declaringType(declaringType);
94: }
95:
96: public static class PropertiesSpecificationBuilder<X, Y, K, V> {
97: private ManagedType<X> declaringType;
98: private FetchType fetchType;
99: private Field javaField;
100: private Class<Y> javaType;
101: private boolean inferred;
102: private Class<K> propertyIdType;
103: private Class<V> propertyValueType;
104:
105: public PropertiesSpecificationBuilder<X, Y, K, V> declaringType(ManagedType<X> declaringType) {
106: this.declaringType = declaringType;
107: return this;
108: }
109:
110: public PropertiesSpecificationBuilder<X, Y, K, V> fetchType(FetchType fetchType) {
111: this.fetchType = fetchType;
112: return this;
113: }
114:
115: public PropertiesSpecificationBuilder<X, Y, K, V> javaField(Field javaField) {
116: this.javaField = javaField;
117: return this;
118: }
119:
120: public PropertiesSpecificationBuilder<X, Y, K, V> javaType(Class<Y> javaType) {
121: this.javaType = javaType;
122: return this;
123: }
124:
125: public PropertiesSpecificationBuilder<X, Y, K, V> inferred(boolean inferred) {
126: this.inferred = inferred;
127: return this;
128: }
129:
130: public PropertiesSpecificationBuilder<X, Y, K, V> propertyIdType(Class<K> propertyIdType) {
131: this.propertyIdType = propertyIdType;
132: return this;
133: }
134:
135: public PropertiesSpecificationBuilder<X, Y, K, V> propertyValueType(Class<V> propertyValueType) {
136: this.propertyValueType = propertyValueType;
137: return this;
138: }
139:
140: public PropertiesSpecificationImpl<X, Y, K, V> build() {
141: return new PropertiesSpecificationImpl<>(this);
142: }
143: }
144: }