001         package com.croftsoft.core.util.id;
002    
003         import com.croftsoft.core.lang.NullArgumentException;
004    
005         /*********************************************************************
006         * An Id implementation that uses a Long object as its value.
007         *
008         * @version
009         *   $Id: LongId.java,v 1.3 2008/09/20 05:11:34 croft Exp $
010         * @since
011         *   2000-04-20
012         * @author
013         *   <a href="https://www.croftsoft.com/">David Wallace Croft</a>
014         *********************************************************************/
015    
016         public class  LongId
017           implements Id
018         //////////////////////////////////////////////////////////////////////
019         //////////////////////////////////////////////////////////////////////
020         {
021    
022         private static final long  serialVersionUID = 0L;
023    
024         //
025    
026         private final Long  l;
027    
028         //////////////////////////////////////////////////////////////////////
029         // Constructor methods
030         //////////////////////////////////////////////////////////////////////
031    
032         /*********************************************************************
033         * Main constructor.
034         *
035         * @throws NullArgumentException
036         *
037         *   If argument is null.
038         *********************************************************************/
039         public  LongId ( Long  l )
040         //////////////////////////////////////////////////////////////////////
041         {
042           NullArgumentException.check ( this.l = l );
043         }
044    
045         public  LongId ( long  l )
046         //////////////////////////////////////////////////////////////////////
047         {
048           this ( new Long ( l ) );
049         }
050    
051         public  LongId ( String  s )
052         //////////////////////////////////////////////////////////////////////
053         {
054           this ( new Long ( s ) );
055         }
056    
057         //////////////////////////////////////////////////////////////////////
058         // accessor method
059         //////////////////////////////////////////////////////////////////////
060    
061         public Long  getL ( ) { return l; }
062    
063         //////////////////////////////////////////////////////////////////////
064         // Id interface methods
065         //////////////////////////////////////////////////////////////////////
066    
067         @Override
068         public Object  clone ( )
069         //////////////////////////////////////////////////////////////////////
070         {
071           try
072           {
073             return super.clone ( );
074           }
075           catch ( CloneNotSupportedException  ex )
076           {
077             // This will never happen.
078    
079             throw new RuntimeException ( );
080           }
081         }
082    
083         @Override
084         public boolean  equals ( Object  other )
085         //////////////////////////////////////////////////////////////////////
086         {
087           if ( ( other == null )
088             || !getClass ( ).equals ( other.getClass ( ) ) )
089    
090           {
091             return false;
092           }
093    
094           return l.equals ( ( ( LongId ) other ).l );
095         }
096    
097         @Override
098         public int  hashCode ( )
099         //////////////////////////////////////////////////////////////////////
100         {
101           return l.hashCode ( );
102         }
103    
104         @Override
105         public String  toString ( )
106         //////////////////////////////////////////////////////////////////////
107         {
108           return l.toString ( );
109         }
110    
111         //////////////////////////////////////////////////////////////////////
112         //////////////////////////////////////////////////////////////////////
113         }