Skip to content

Method: getLanguage()

1: /*
2: * JOPA
3: * Copyright (C) 2023 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.test.environment;
19:
20: import java.net.URI;
21: import java.util.Objects;
22:
23: public class Quad {
24:
25: private final URI subject;
26: private final URI property;
27: private final Object value;
28: private final URI context;
29: private final String language;
30:
31: public Quad(URI subject, URI property, Object value) {
32: this.subject = Objects.requireNonNull(subject);
33: this.property = Objects.requireNonNull(property);
34: this.value = Objects.requireNonNull(value);
35: this.context = null;
36: this.language = "en";
37: }
38:
39: public Quad(URI subject, URI property, Object value, URI context) {
40: this.subject = Objects.requireNonNull(subject);
41: this.property = Objects.requireNonNull(property);
42: this.value = Objects.requireNonNull(value);
43: this.context = context;
44: this.language = "en";
45: }
46:
47: public Quad(URI subject, URI property, Object value, String language) {
48: this.subject = Objects.requireNonNull(subject);
49: this.property = Objects.requireNonNull(property);
50: this.value = Objects.requireNonNull(value);
51: this.context = null;
52: this.language = language;
53: }
54:
55: public Quad(URI subject, URI property, Object value, String language, URI context) {
56: this.subject = Objects.requireNonNull(subject);
57: this.property = Objects.requireNonNull(property);
58: this.value = Objects.requireNonNull(value);
59: this.context = context;
60: this.language = language;
61: }
62:
63: public URI getSubject() {
64: return subject;
65: }
66:
67: public URI getProperty() {
68: return property;
69: }
70:
71: public Object getValue() {
72: return value;
73: }
74:
75: public URI getContext() {
76: return context;
77: }
78:
79: public String getLanguage() {
80: return language;
81: }
82:
83: @Override
84: public boolean equals(Object o) {
85: if (this == o) {
86: return true;
87: }
88: if (!(o instanceof Quad)) {
89: return false;
90: }
91: Quad quad = (Quad) o;
92: return subject.equals(quad.subject) &&
93: property.equals(quad.property) &&
94: value.equals(quad.value) &&
95: Objects.equals(context, quad.context) &&
96: Objects.equals(language, quad.language);
97: }
98:
99: @Override
100: public int hashCode() {
101: return Objects.hash(subject, property, value, context, language);
102: }
103:
104: @Override
105: public String toString() {
106: return "{" + subject + " " + property + " " + value +
107: (language != null ? "@" + language : "") +
108: (context != null ? " " + context : "") + "}";
109: }
110: }