01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.openjpa.util;
20:
21: import java.math.BigInteger;
22:
23: /**
24: * @author <a href="mailto:mnachev@gmail.com">Miroslav Nachev</a>
25: * @since 1.1.0
26: */
27: public class BigIntegerId extends OpenJPAId {
28:
29: private final BigInteger key;
30:
31: public BigIntegerId(Class cls, String key) {
32: this (cls, (key == null) ? null : new BigInteger(key));
33: }
34:
35: public BigIntegerId(Class cls, BigInteger key) {
36: super (cls);
37: this .key = key;
38: }
39:
40: public BigIntegerId(Class cls, BigInteger key, boolean subs) {
41: super (cls, subs);
42: this .key = key;
43: }
44:
45: public BigInteger getId() {
46: return key;
47: }
48:
49: public Object getIdObject() {
50: return key;
51: }
52:
53: public String toString() {
54: if (key == null)
55: return "NULL";
56:
57: return key.toString();
58: }
59:
60: protected int idHash() {
61: if (key != null)
62: return key.hashCode();
63:
64: return 0;
65: }
66:
67: protected boolean idEquals(OpenJPAId other) {
68: if (key == null)
69: return false;
70:
71: return key.equals(other);
72: }
73:
74: }
|