Skip to contentMethod: BasicTypeImpl(Class)
1: /**
2: * Copyright (C) 2020 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.model.metamodel;
16:
17: public class BasicTypeImpl<X> implements BasicType<X> {
18:
19: private Class<X> c;
20:
21: BasicTypeImpl(Class<X> c) {
22: this.c = c;
23: }
24:
25: @Override
26: public Class<X> getJavaType() {
27: return c;
28: }
29:
30: @Override
31: public cz.cvut.kbss.jopa.model.metamodel.Type.PersistenceType getPersistenceType() {
32: return PersistenceType.BASIC;
33: }
34:
35: public static <X> BasicType<X> get(final Class<X> c) {
36: return new BasicTypeImpl<>(c);
37: }
38:
39: @Override
40: public int hashCode() {
41: final int prime = 31;
42: int result = 1;
43: result = prime * result + ((c == null) ? 0 : c.hashCode());
44: return result;
45: }
46:
47: @Override
48: public boolean equals(Object obj) {
49: if (this == obj)
50: return true;
51: if (obj == null)
52: return false;
53: if (getClass() != obj.getClass())
54: return false;
55: BasicTypeImpl<?> other = (BasicTypeImpl<?>) obj;
56: if (c == null) {
57: return other.c == null;
58: } else return c.equals(other.c);
59: }
60: }