Skip to contentMethod: getWithConverter()
1: /**
2: * Copyright (C) 2022 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.test;
14:
15: import cz.cvut.kbss.jopa.model.annotations.*;
16: import cz.cvut.kbss.jopa.test.environment.Generators;
17: import cz.cvut.kbss.jopa.test.environment.TestEnvironment;
18: import cz.cvut.kbss.ontodriver.model.LangString;
19:
20: import java.time.ZoneOffset;
21: import java.util.*;
22: import java.util.stream.Collectors;
23: import java.util.stream.IntStream;
24:
25: /**
26: * Contains a generated string URI and data property attributes of primitive wrapper types
27: * - boolean, int, long, double and date.
28: */
29: @OWLClass(iri = Vocabulary.C_OWL_CLASS_M)
30: public class OWLClassM {
31:
32: @Id(generated = true)
33: private String key;
34:
35: @OWLDataProperty(iri = Vocabulary.p_m_booleanAttribute)
36: private Boolean booleanAttribute;
37:
38: @OWLDataProperty(iri = Vocabulary.p_m_intAttribute)
39: private Integer intAttribute;
40:
41: @OWLDataProperty(iri = Vocabulary.p_m_longAttribute)
42: private Long longAttribute;
43:
44: @OWLDataProperty(iri = Vocabulary.p_m_floatAttribute)
45: private Float floatAttribute;
46:
47: @OWLDataProperty(iri = Vocabulary.p_m_doubleAttribute)
48: private Double doubleAttribute;
49:
50: @OWLDataProperty(iri = Vocabulary.p_m_dateAttribute)
51: private Date dateAttribute;
52:
53: @OWLDataProperty(iri = Vocabulary.p_m_enumAttribute)
54: private Severity enumAttribute;
55:
56: @Enumerated(EnumType.ORDINAL)
57: @OWLDataProperty(iri = Vocabulary.p_m_ordinalEnumAttribute)
58: private Severity ordinalEnumAttribute;
59:
60: @OWLDataProperty(iri = Vocabulary.p_m_IntegerSet)
61: private Set<Integer> integerSet;
62:
63: @OWLDataProperty(iri = Vocabulary.p_m_lexicalForm, lexicalForm = true)
64: private String lexicalForm;
65:
66: @OWLDataProperty(iri = Vocabulary.p_m_simpleLiteral, simpleLiteral = true)
67: private String simpleLiteral;
68:
69: @OWLDataProperty(iri = Vocabulary.p_m_StringCollection)
70: private Collection<String> stringCollection;
71:
72: @OWLDataProperty(iri = Vocabulary.p_m_explicitDatatype, datatype = TestEnvironment.EXPLICIT_DATATYPE)
73: private String explicitDatatype;
74:
75: @OWLDataProperty(iri = Vocabulary.p_m_langString)
76: private LangString langString;
77:
78: @OWLDataProperty(iri = Vocabulary.p_m_enumSimpleLiteralAttribute, simpleLiteral = true)
79: private Severity enumSimpleLiteral;
80:
81: @Convert(converter = ZoneOffsetConverter.class)
82: @OWLDataProperty(iri = Vocabulary.p_m_withConverter, simpleLiteral = true)
83: private ZoneOffset withConverter;
84:
85: public enum Severity {
86: LOW, MEDIUM, HIGH
87: }
88:
89: public String getKey() {
90: return key;
91: }
92:
93: public void setKey(String key) {
94: this.key = key;
95: }
96:
97: public Boolean getBooleanAttribute() {
98: return booleanAttribute;
99: }
100:
101: public void setBooleanAttribute(Boolean booleanAttribute) {
102: this.booleanAttribute = booleanAttribute;
103: }
104:
105: public Integer getIntAttribute() {
106: return intAttribute;
107: }
108:
109: public void setIntAttribute(Integer intAttribute) {
110: this.intAttribute = intAttribute;
111: }
112:
113: public Long getLongAttribute() {
114: return longAttribute;
115: }
116:
117: public void setLongAttribute(Long longAttribute) {
118: this.longAttribute = longAttribute;
119: }
120:
121: public Float getFloatAttribute() {
122: return floatAttribute;
123: }
124:
125: public void setFloatAttribute(Float floatAttribute) {
126: this.floatAttribute = floatAttribute;
127: }
128:
129: public Double getDoubleAttribute() {
130: return doubleAttribute;
131: }
132:
133: public void setDoubleAttribute(Double doubleAttribute) {
134: this.doubleAttribute = doubleAttribute;
135: }
136:
137: public Date getDateAttribute() {
138: return dateAttribute;
139: }
140:
141: public void setDateAttribute(Date dateAttribute) {
142: this.dateAttribute = dateAttribute;
143: }
144:
145: public Severity getEnumAttribute() {
146: return enumAttribute;
147: }
148:
149: public void setEnumAttribute(Severity enumAttribute) {
150: this.enumAttribute = enumAttribute;
151: }
152:
153: public Severity getOrdinalEnumAttribute() {
154: return ordinalEnumAttribute;
155: }
156:
157: public void setOrdinalEnumAttribute(Severity ordinalEnumAttribute) {
158: this.ordinalEnumAttribute = ordinalEnumAttribute;
159: }
160:
161: public Set<Integer> getIntegerSet() {
162: return integerSet;
163: }
164:
165: public void setIntegerSet(Set<Integer> integerSet) {
166: this.integerSet = integerSet;
167: }
168:
169: public String getLexicalForm() {
170: return lexicalForm;
171: }
172:
173: public void setLexicalForm(String lexicalForm) {
174: this.lexicalForm = lexicalForm;
175: }
176:
177: public String getSimpleLiteral() {
178: return simpleLiteral;
179: }
180:
181: public void setSimpleLiteral(String simpleLiteral) {
182: this.simpleLiteral = simpleLiteral;
183: }
184:
185: public Collection<String> getStringCollection() {
186: return stringCollection;
187: }
188:
189: public void setStringCollection(Collection<String> stringCollection) {
190: this.stringCollection = stringCollection;
191: }
192:
193: public String getExplicitDatatype() {
194: return explicitDatatype;
195: }
196:
197: public void setExplicitDatatype(String explicitDatatype) {
198: this.explicitDatatype = explicitDatatype;
199: }
200:
201: public LangString getLangString() {
202: return langString;
203: }
204:
205: public void setLangString(LangString langString) {
206: this.langString = langString;
207: }
208:
209: public Severity getEnumSimpleLiteral() {
210: return enumSimpleLiteral;
211: }
212:
213: public void setEnumSimpleLiteral(Severity enumSimpleLiteral) {
214: this.enumSimpleLiteral = enumSimpleLiteral;
215: }
216:
217: public ZoneOffset getWithConverter() {
218: return withConverter;
219: }
220:
221: public void setWithConverter(ZoneOffset withConverter) {
222: this.withConverter = withConverter;
223: }
224:
225: @Override
226: public String toString() {
227: return "OWLCLassM{" +
228: "key='" + key + '\'' +
229: ", booleanAttribute=" + booleanAttribute +
230: ", intAttribute=" + intAttribute +
231: ", longAttribute=" + longAttribute +
232: ", floatAttribute=" + floatAttribute +
233: ", doubleAttribute=" + doubleAttribute +
234: ", enumAttribute=" + enumAttribute +
235: ", ordinalEnumAttribute=" + ordinalEnumAttribute +
236: ", integerSet=" + integerSet +
237: ", lexicalForm=" + lexicalForm +
238: ", simpleLiteral=" + simpleLiteral +
239: ", stringCollection=" + stringCollection +
240: ", explicitDatatype=" + explicitDatatype +
241: ", langString=" + langString +
242: ", enumSimpleLiteral=" + enumSimpleLiteral +
243: ", withConverter=" + withConverter +
244: '}';
245: }
246:
247: public void initializeTestValues(boolean includingKey) {
248: if (includingKey) {
249: this.key = "http://krizik.felk.cvut.cz/ontologies/entityM";
250: }
251: this.booleanAttribute = true;
252: this.intAttribute = 117;
253: this.longAttribute = 365L;
254: this.floatAttribute = 3.14F;
255: this.doubleAttribute = 3.14D;
256: this.dateAttribute = new Date();
257: this.enumAttribute = Severity.MEDIUM;
258: this.ordinalEnumAttribute = enumAttribute;
259: this.integerSet = IntStream.generate(Generators::randomInt).limit(10).boxed().collect(Collectors.toSet());
260: this.stringCollection = new HashSet<>(Arrays.asList("test-one", "test-two", "test-three"));
261: this.enumSimpleLiteral = Severity.HIGH;
262: this.withConverter = ZoneOffset.UTC;
263: }
264: }