View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      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, Serializable
28  {
29      private Long oid;
30      
31      public JetspeedLongObjectID(long oid)
32      {
33          this.oid = new Long(oid);
34      }
35  
36      public JetspeedLongObjectID(Long oid)
37      {
38          this.oid = oid;
39          if ( oid == null )
40          {
41              // really cannot have a null here
42              throw new NullPointerException();
43          }
44      }
45  
46      public long getOID()
47      {
48          return oid.longValue();
49      }
50      
51      public Long getLong()
52      {
53          return oid;
54      }
55      
56      public boolean equals(Object object)
57      {
58          if (object instanceof PortalObjectID)
59          {
60              return ((PortalObjectID)object).getOID() == oid.longValue();
61          }
62          else if (object instanceof Long)
63          {
64              return ((Long)object).longValue() == oid.longValue();
65          }
66          else if (object instanceof Integer)
67          {
68              return ((Integer)object).longValue() == oid.longValue();
69          }
70          return false;
71      }
72  
73      public int hashCode()
74      {
75          return oid.hashCode();
76      }
77      
78      public String toString()
79      {
80          return oid.toString();
81      }
82  }