Skip to content

Method: getSubject()

1: /*
2: * JOPA
3: * Copyright (C) 2024 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.ontodriver.owlapi.change;
19:
20: import org.semanticweb.owlapi.model.OWLNamedIndividual;
21: import org.semanticweb.owlapi.model.OWLProperty;
22: import org.semanticweb.owlapi.model.OWLPropertyAssertionAxiom;
23:
24: import java.util.Objects;
25:
26: public abstract class SubjectPropertyRemove<T extends OWLProperty> implements TransactionalChange {
27:
28: protected final OWLNamedIndividual subject;
29: protected final T property;
30:
31: public SubjectPropertyRemove(OWLNamedIndividual subject, T property) {
32: this.subject = subject;
33: this.property = property;
34: }
35:
36: @Override
37: public boolean overrides(TransactionalChange existing) {
38: if (existing instanceof MutableAddAxiom) {
39: final MutableAddAxiom ax = (MutableAddAxiom) existing;
40: if (ax.getAxiom() instanceof OWLPropertyAssertionAxiom) {
41: final OWLPropertyAssertionAxiom<?, ?> assertionAxiom = (OWLPropertyAssertionAxiom<?, ?>) ax.getAxiom();
42: return subject.equals(assertionAxiom.getSubject()) && property.equals(assertionAxiom.getProperty());
43: }
44: }
45: return false;
46: }
47:
48: public OWLNamedIndividual getSubject() {
49: return subject;
50: }
51:
52: public T getProperty() {
53: return property;
54: }
55:
56: @Override
57: public boolean equals(Object o) {
58: if (this == o) {
59: return true;
60: }
61: if (!(o instanceof SubjectPropertyRemove)) {
62: return false;
63: }
64: SubjectPropertyRemove<?> that = (SubjectPropertyRemove<?>) o;
65: return subject.equals(that.subject) && property.equals(that.property);
66: }
67:
68: @Override
69: public int hashCode() {
70: return Objects.hash(subject, property);
71: }
72:
73: @Override
74: public String toString() {
75: return "SubjectPropertyRemove{" +
76: "subject=" + subject +
77: ", property=" + property +
78: '}';
79: }
80: }