Skip to content

Package: AbstractAttribute$AbstractAttributeBuilder

AbstractAttribute$AbstractAttributeBuilder

nameinstructionbranchcomplexitylinemethod
AbstractAttribute.AbstractAttributeBuilder()
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
config(PropertyAttributes)
M: 0 C: 34
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
converter(ConverterWrapper)
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%
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%
field(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%
includeExplicit(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%
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%

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.IRI;
18: import cz.cvut.kbss.jopa.model.annotations.CascadeType;
19: import cz.cvut.kbss.jopa.model.annotations.FetchType;
20: import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraint;
21: import cz.cvut.kbss.jopa.oom.converter.ConverterWrapper;
22:
23: import java.lang.reflect.Field;
24: import java.lang.reflect.Member;
25:
26: public abstract class AbstractAttribute<X, Y> implements Attribute<X, Y> {
27:
28: private final Field field;
29:
30: private final ManagedType<X> declaringType;
31:
32: private final PersistentAttributeType attributeType;
33:
34: private final IRI iri;
35:
36: private final CascadeType[] cascadeTypes;
37:
38: private final FetchType fetchType;
39:
40: private final boolean inferred;
41:
42: private final boolean includeExplicit;
43:
44: private final boolean nonEmpty;
45:
46: private boolean lexicalForm;
47:
48: private boolean simpleLiteral;
49:
50: private final ParticipationConstraint[] constraints;
51:
52: private ConverterWrapper converter;
53:
54: AbstractAttribute(AbstractAttributeBuilder<X, Y> builder) {
55: this.field = builder.field;
56: this.declaringType = builder.declaringType;
57: this.attributeType = builder.attributeType;
58: this.iri = builder.iri;
59: this.cascadeTypes = builder.cascadeTypes;
60: this.fetchType = builder.fetchType;
61: this.inferred = builder.inferred;
62: this.includeExplicit = builder.includeExplicit;
63: this.constraints = builder.constraints;
64: this.nonEmpty = builder.nonEmpty;
65: this.converter = builder.converter;
66: this.lexicalForm = builder.lexicalForm;
67: this.simpleLiteral = builder.simpleLiteral;
68: }
69:
70: @Override
71: public PersistentAttributeType getPersistentAttributeType() {
72: return attributeType;
73: }
74:
75: @Override
76: public Member getJavaMember() {
77: return field;
78: }
79:
80: @Override
81: public IRI getIRI() {
82: return iri;
83: }
84:
85: @Override
86: public CascadeType[] getCascadeTypes() {
87: return cascadeTypes;
88: }
89:
90: @Override
91: public boolean isNonEmpty() {
92: return nonEmpty;
93: }
94:
95: @Override
96: public ParticipationConstraint[] getConstraints() {
97: return constraints;
98: }
99:
100: @Override
101: public ManagedType<X> getDeclaringType() {
102: return declaringType;
103: }
104:
105: @Override
106: public Field getJavaField() {
107: return field;
108: }
109:
110: @Override
111: public FetchType getFetchType() {
112: return fetchType;
113: }
114:
115: @Override
116: public boolean isInferred() {
117: return inferred;
118: }
119:
120: @Override
121: public boolean includeExplicit() {
122: return includeExplicit;
123: }
124:
125: @Override
126: public boolean isLexicalForm() {
127: return lexicalForm;
128: }
129:
130: @Override
131: public boolean isSimpleLiteral() {
132: return simpleLiteral;
133: }
134:
135: @Override
136: public String getName() {
137: return field.getName();
138: }
139:
140: public ConverterWrapper getConverter() {
141: return converter;
142: }
143:
144: @Override
145: public String toString() {
146: return declaringType.getJavaType().getSimpleName() + "." + getName();
147: }
148:
149: abstract static class AbstractAttributeBuilder<X, Y> {
150: private Field field;
151: private ManagedType<X> declaringType;
152: private PersistentAttributeType attributeType;
153: private IRI iri;
154: private CascadeType[] cascadeTypes;
155: private FetchType fetchType;
156: private boolean inferred;
157: private boolean includeExplicit;
158: private boolean nonEmpty = false;
159: private boolean lexicalForm = false;
160: private boolean simpleLiteral = false;
161: private ParticipationConstraint[] constraints;
162: private ConverterWrapper converter;
163:
164: public AbstractAttributeBuilder<X, Y> config(PropertyAttributes config) {
165: this.iri = config.getIri();
166: this.attributeType = config.getPersistentAttributeType();
167: this.cascadeTypes = config.getCascadeTypes();
168: this.constraints = config.getParticipationConstraints();
169: this.nonEmpty = config.isNonEmpty();
170: this.fetchType = config.getFetchType();
171: this.lexicalForm = config.isLexicalForm();
172: this.simpleLiteral = config.simpleLiteral;
173: return this;
174: }
175:
176: public AbstractAttributeBuilder<X, Y> field(Field field) {
177: this.field = field;
178: return this;
179: }
180:
181: public AbstractAttributeBuilder<X, Y> declaringType(ManagedType<X> declaringType) {
182: this.declaringType = declaringType;
183: return this;
184: }
185:
186: public AbstractAttributeBuilder<X, Y> inferred(boolean inferred) {
187: this.inferred = inferred;
188: return this;
189: }
190:
191: public AbstractAttributeBuilder<X, Y> includeExplicit(boolean includeExplicit) {
192: this.includeExplicit = includeExplicit;
193: return this;
194: }
195:
196: public AbstractAttributeBuilder<X, Y> converter(ConverterWrapper converter) {
197: this.converter = converter;
198: return this;
199: }
200: }
201: }