01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jetspeed.util;
18:
19: import java.io.Serializable;
20:
21: /**
22: * JetspeedLongObjectID
23: *
24: * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
25: * @version $Id$
26: */
27: public class JetspeedLongObjectID implements PortalObjectID,
28: Serializable {
29: private Long oid;
30:
31: public JetspeedLongObjectID(long oid) {
32: this .oid = new Long(oid);
33: }
34:
35: public JetspeedLongObjectID(Long oid) {
36: this .oid = oid;
37: if (oid == null) {
38: // really cannot have a null here
39: throw new NullPointerException();
40: }
41: }
42:
43: public long getOID() {
44: return oid.longValue();
45: }
46:
47: public Long getLong() {
48: return oid;
49: }
50:
51: public boolean equals(Object object) {
52: if (object instanceof PortalObjectID) {
53: return ((PortalObjectID) object).getOID() == oid
54: .longValue();
55: } else if (object instanceof Long) {
56: return ((Long) object).longValue() == oid.longValue();
57: } else if (object instanceof Integer) {
58: return ((Integer) object).longValue() == oid.longValue();
59: }
60: return false;
61: }
62:
63: public int hashCode() {
64: return oid.hashCode();
65: }
66:
67: public String toString() {
68: return oid.toString();
69: }
70: }
|