Package: AbstractAttribute
AbstractAttribute
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AbstractAttribute(AbstractAttribute.AbstractAttributeBuilder) |
|
|
|
|
|
||||||||||||||||||||
getCascadeTypes() |
|
|
|
|
|
||||||||||||||||||||
getConstraints() |
|
|
|
|
|
||||||||||||||||||||
getConverter() |
|
|
|
|
|
||||||||||||||||||||
getDeclaringType() |
|
|
|
|
|
||||||||||||||||||||
getFetchType() |
|
|
|
|
|
||||||||||||||||||||
getIRI() |
|
|
|
|
|
||||||||||||||||||||
getJavaField() |
|
|
|
|
|
||||||||||||||||||||
getJavaMember() |
|
|
|
|
|
||||||||||||||||||||
getName() |
|
|
|
|
|
||||||||||||||||||||
getPersistentAttributeType() |
|
|
|
|
|
||||||||||||||||||||
includeExplicit() |
|
|
|
|
|
||||||||||||||||||||
isInferred() |
|
|
|
|
|
||||||||||||||||||||
isLexicalForm() |
|
|
|
|
|
||||||||||||||||||||
isNonEmpty() |
|
|
|
|
|
||||||||||||||||||||
isSimpleLiteral() |
|
|
|
|
|
||||||||||||||||||||
toString() |
|
|
|
|
|
Coverage
1: /**
2: * Copyright (C) 2019 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.jopa.model.metamodel;
14:
15: import cz.cvut.kbss.jopa.model.IRI;
16: import cz.cvut.kbss.jopa.model.annotations.CascadeType;
17: import cz.cvut.kbss.jopa.model.annotations.FetchType;
18: import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraint;
19: import cz.cvut.kbss.jopa.oom.converter.ConverterWrapper;
20:
21: import java.lang.reflect.Field;
22: import java.lang.reflect.Member;
23:
24: public abstract class AbstractAttribute<X, Y> implements Attribute<X, Y> {
25:
26: private final Field field;
27:
28: private final ManagedType<X> declaringType;
29:
30: private final PersistentAttributeType attributeType;
31:
32: private final IRI iri;
33:
34: private final CascadeType[] cascadeTypes;
35:
36: private final FetchType fetchType;
37:
38: private final boolean inferred;
39:
40: private final boolean includeExplicit;
41:
42: private final boolean nonEmpty;
43:
44: private boolean lexicalForm;
45:
46: private boolean simpleLiteral;
47:
48: private final ParticipationConstraint[] constraints;
49:
50: private ConverterWrapper converter;
51:
52: AbstractAttribute(AbstractAttributeBuilder<X, Y> builder) {
53: this.field = builder.field;
54: this.declaringType = builder.declaringType;
55: this.attributeType = builder.attributeType;
56: this.iri = builder.iri;
57: this.cascadeTypes = builder.cascadeTypes;
58: this.fetchType = builder.fetchType;
59: this.inferred = builder.inferred;
60: this.includeExplicit = builder.includeExplicit;
61: this.constraints = builder.constraints;
62: this.nonEmpty = builder.nonEmpty;
63: this.converter = builder.converter;
64: this.lexicalForm = builder.lexicalForm;
65: this.simpleLiteral = builder.simpleLiteral;
66: }
67:
68: @Override
69: public PersistentAttributeType getPersistentAttributeType() {
70: return attributeType;
71: }
72:
73: @Override
74: public Member getJavaMember() {
75: return field;
76: }
77:
78: @Override
79: public IRI getIRI() {
80: return iri;
81: }
82:
83: @Override
84: public CascadeType[] getCascadeTypes() {
85: return cascadeTypes;
86: }
87:
88: @Override
89: public boolean isNonEmpty() {
90: return nonEmpty;
91: }
92:
93: @Override
94: public ParticipationConstraint[] getConstraints() {
95: return constraints;
96: }
97:
98: @Override
99: public ManagedType<X> getDeclaringType() {
100: return declaringType;
101: }
102:
103: @Override
104: public Field getJavaField() {
105: return field;
106: }
107:
108: @Override
109: public FetchType getFetchType() {
110: return fetchType;
111: }
112:
113: @Override
114: public boolean isInferred() {
115: return inferred;
116: }
117:
118: @Override
119: public boolean includeExplicit() {
120: return includeExplicit;
121: }
122:
123: @Override
124: public boolean isLexicalForm() {
125: return lexicalForm;
126: }
127:
128: @Override
129: public boolean isSimpleLiteral() {
130: return simpleLiteral;
131: }
132:
133: @Override
134: public String getName() {
135: return field.getName();
136: }
137:
138: public ConverterWrapper getConverter() {
139: return converter;
140: }
141:
142: @Override
143: public String toString() {
144: return declaringType.getJavaType().getSimpleName() + "." + getName();
145: }
146:
147: abstract static class AbstractAttributeBuilder<X, Y> {
148: private Field field;
149: private ManagedType<X> declaringType;
150: private PersistentAttributeType attributeType;
151: private IRI iri;
152: private CascadeType[] cascadeTypes;
153: private FetchType fetchType;
154: private boolean inferred;
155: private boolean includeExplicit;
156: private boolean nonEmpty = false;
157: private boolean lexicalForm = false;
158: private boolean simpleLiteral = false;
159: private ParticipationConstraint[] constraints;
160: private ConverterWrapper converter;
161:
162: public AbstractAttributeBuilder<X, Y> config(PropertyAttributes config) {
163: this.iri = config.getIri();
164: this.attributeType = config.getPersistentAttributeType();
165: this.cascadeTypes = config.getCascadeTypes();
166: this.constraints = config.getParticipationConstraints();
167: this.nonEmpty = config.isNonEmpty();
168: this.fetchType = config.getFetchType();
169: this.lexicalForm = config.isLexicalForm();
170: this.simpleLiteral = config.simpleLiteral;
171: return this;
172: }
173:
174: public AbstractAttributeBuilder<X, Y> field(Field field) {
175: this.field = field;
176: return this;
177: }
178:
179: public AbstractAttributeBuilder<X, Y> declaringType(ManagedType<X> declaringType) {
180: this.declaringType = declaringType;
181: return this;
182: }
183:
184: public AbstractAttributeBuilder<X, Y> inferred(boolean inferred) {
185: this.inferred = inferred;
186: return this;
187: }
188:
189: public AbstractAttributeBuilder<X, Y> includeExplicit(boolean includeExplicit) {
190: this.includeExplicit = includeExplicit;
191: return this;
192: }
193:
194: public AbstractAttributeBuilder<X, Y> converter(ConverterWrapper converter) {
195: this.converter = converter;
196: return this;
197: }
198: }
199: }