Skip to content

Method: equals(Object)

1: /**
2: * Copyright (C) 2016 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.sessions;
16:
17: import cz.cvut.kbss.jopa.model.descriptors.Descriptor;
18:
19: import java.net.URI;
20:
21: /**
22: * Created by ledvima1 on 11.2.15.
23: */
24: public final class LoadingParameters<T> {
25:
26: private final Class<T> cls;
27: private final URI identifier;
28: private final Descriptor descriptor;
29: private final boolean forceLoad;
30:
31: public LoadingParameters(Class<T> cls, URI identifier, Descriptor descriptor) {
32: this.cls = cls;
33: this.identifier = identifier;
34: this.descriptor = descriptor;
35: this.forceLoad = false;
36: assert paramsLoaded();
37: }
38:
39: private boolean paramsLoaded() {
40: return cls != null && identifier != null && descriptor != null;
41: }
42:
43: public LoadingParameters(Class<T> cls, URI identifier, Descriptor descriptor, boolean forceLoad) {
44: this.cls = cls;
45: this.identifier = identifier;
46: this.descriptor = descriptor;
47: this.forceLoad = forceLoad;
48: assert paramsLoaded();
49: }
50:
51: public Class<T> getEntityType() {
52: return cls;
53: }
54:
55: public URI getIdentifier() {
56: return identifier;
57: }
58:
59: public Descriptor getDescriptor() {
60: return descriptor;
61: }
62:
63: public boolean isForceLoad() {
64: return forceLoad;
65: }
66:
67: @Override
68: public boolean equals(Object o) {
69:• if (this == o) return true;
70:• if (o == null || getClass() != o.getClass()) return false;
71:
72: LoadingParameters that = (LoadingParameters) o;
73:
74:• if (forceLoad != that.forceLoad) return false;
75:• if (!cls.equals(that.cls)) return false;
76:• if (!descriptor.equals(that.descriptor)) return false;
77: return identifier.equals(that.identifier);
78:
79: }
80:
81: @Override
82: public int hashCode() {
83: int result = cls.hashCode();
84: result = 31 * result + identifier.hashCode();
85: result = 31 * result + descriptor.hashCode();
86: result = 31 * result + (forceLoad ? 1 : 0);
87: return result;
88: }
89: }