Skip to contentMethod: setUri(URI)
1: /**
2: * Copyright (C) 2022 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.test;
16:
17: import cz.cvut.kbss.jopa.model.annotations.*;
18:
19: import java.net.URI;
20: import java.util.Objects;
21: import java.util.Set;
22:
23: @SparqlResultSetMappings({@SparqlResultSetMapping(name = OWLClassA.VARIABLE_MAPPING, variables = {
24: @VariableResult(name = "x", type = String.class),
25: @VariableResult(name = "y")
26: }), @SparqlResultSetMapping(name = OWLClassA.CONSTRUCTOR_MAPPING, classes = {
27: @ConstructorResult(targetClass = OWLClassA.class, variables = {
28: @VariableResult(name = "x"),
29: @VariableResult(name = "y", type = String.class)
30:
31: })
32: }), @SparqlResultSetMapping(name = OWLClassA.ENTITY_MAPPING, entities = {
33: @EntityResult(entityClass = OWLClassA.class, fields = {
34: @FieldResult(name = "uri", variable = "x")
35: })
36: })})
37: @NamedNativeQueries({@NamedNativeQuery(name = "OWLClassA.findAll",
38: query = "SELECT ?x WHERE {?x a <" + Vocabulary.C_OWL_CLASS_A + "> . } ORDER BY ?x"),
39: @NamedNativeQuery(name = "OWLClassA.findByString", query = "SELECT ?x WHERE { ?x <" +
40: Vocabulary.P_A_STRING_ATTRIBUTE + "> ?str . }")
41: })
42: @OWLClass(iri = Vocabulary.C_OWL_CLASS_A)
43: public class OWLClassA implements HasUri {
44:
45: public static final String VARIABLE_MAPPING = "OWLClassA.testMapping";
46: public static final String CONSTRUCTOR_MAPPING = "OWLClassA.constructorMapping";
47: public static final String ENTITY_MAPPING = "OWLClassA.entityMapping";
48:
49: @Types
50: private Set<String> types;
51:
52: @Id
53: private URI uri;
54:
55: @OWLDataProperty(iri = Vocabulary.P_A_STRING_ATTRIBUTE)
56: private String stringAttribute;
57:
58: public OWLClassA() {
59: }
60:
61: public OWLClassA(URI uri) {
62: this.uri = uri;
63: }
64:
65: public OWLClassA(URI uri, String stringAttribute) {
66: this.uri = uri;
67: this.stringAttribute = stringAttribute;
68: }
69:
70: public void setUri(URI uri) {
71: this.uri = uri;
72: }
73:
74: @Override
75: public URI getUri() {
76: return uri;
77: }
78:
79: public void setStringAttribute(String stringAttribute) {
80: this.stringAttribute = stringAttribute;
81: }
82:
83: public String getStringAttribute() {
84: return stringAttribute;
85: }
86:
87: public void setTypes(Set<String> types) {
88: this.types = types;
89: }
90:
91: public Set<String> getTypes() {
92: return types;
93: }
94:
95: @Override
96: public boolean equals(Object o) {
97: if (this == o) return true;
98: if (!(o instanceof OWLClassA)) return false;
99: OWLClassA owlClassA = (OWLClassA) o;
100: return Objects.equals(getTypes(), owlClassA.getTypes()) && Objects.equals(getUri(), owlClassA.getUri()) && Objects.equals(getStringAttribute(), owlClassA.getStringAttribute());
101: }
102:
103: @Override
104: public int hashCode() {
105: return Objects.hash(getTypes(), getUri(), getStringAttribute());
106: }
107:
108: @Override
109: public String toString() {
110: String out = "OWLClassA: uri = " + uri;
111: out += ", stringAttribute = " + stringAttribute;
112: if (types != null) {
113: out += ", types = {" + types + "}";
114: }
115: return out;
116: }
117:
118: public static String getClassIri() {
119: return OWLClassA.class.getDeclaredAnnotation(OWLClass.class).iri();
120: }
121: }