directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r1037549 - in /directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value: LastRequestType.java SamType.java
Date Sun, 21 Nov 2010 20:14:14 GMT
Author: felixk
Date: Sun Nov 21 20:14:14 2010
New Revision: 1037549

URL: http://svn.apache.org/viewvc?rev=1037549&view=rev
Log:
Transform to enum

Modified:
    directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/LastRequestType.java
    directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/SamType.java

Modified: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/LastRequestType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/LastRequestType.java?rev=1037549&r1=1037548&r2=1037549&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/LastRequestType.java
(original)
+++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/LastRequestType.java
Sun Nov 21 20:14:14 2010
@@ -20,74 +20,58 @@
 package org.apache.directory.server.kerberos.shared.messages.value;
 
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 
 
 /**
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class LastRequestType implements Comparable<LastRequestType>
+public enum LastRequestType
 {
     /**
      * Constant for the "none" last request type.
      */
-    public static final LastRequestType NONE = new LastRequestType( 0, AuthenticationLevel.NONE.toString()
);
+    NONE ( 0, AuthenticationLevel.NONE.toString() ),
 
     /**
      * Constant for the "time of initial ticket" last request type.
      */
-    public static final LastRequestType TIME_OF_INITIAL_TGT = new LastRequestType( 1, "time
of initial ticket" );
+    TIME_OF_INITIAL_TGT ( 1, "time of initial ticket" ),
 
     /**
      * Constant for the "time of initial request" last request type.
      */
-    public static final LastRequestType TIME_OF_INITIAL_REQ = new LastRequestType( 2, "time
of initial request" );
+    TIME_OF_INITIAL_REQ ( 2, "time of initial request" ),
 
     /**
      * Constant for the "time of newest ticket" last request type.
      */
-    public static final LastRequestType TIME_OF_NEWEST_TGT = new LastRequestType( 3, "time
of newest ticket" );
+    TIME_OF_NEWEST_TGT ( 3, "time of newest ticket" ),
 
     /**
      * Constant for the "time of last renewal" last request type.
      */
-    public static final LastRequestType TIME_OF_LAST_RENEWAL = new LastRequestType( 4, "time
of last renewal" );
+    TIME_OF_LAST_RENEWAL ( 4, "time of last renewal" ),
 
     /**
      * Constant for the "time of last request" last request type.
      */
-    public static final LastRequestType TIME_OF_LAST_REQ = new LastRequestType( 5, "time
of last request" );
+    TIME_OF_LAST_REQ ( 5, "time of last request" ),
 
     /**
      * Constant for the "time of password expiration" last request type.
      */
-    public static final LastRequestType TIME_OF_PASSWORD_EXP = new LastRequestType( 6, "time
of password expiration" );
-
-    /**
-     * Array for building a List of VALUES.
-     */
-    private static final LastRequestType[] values =
-        { NONE, TIME_OF_INITIAL_TGT, TIME_OF_INITIAL_REQ, TIME_OF_NEWEST_TGT, TIME_OF_LAST_RENEWAL,
TIME_OF_LAST_REQ,
-            TIME_OF_PASSWORD_EXP };
-
-    /**
-     * A List of all the last request type constants.
-     */
-    public static final List<LastRequestType> VALUES = Collections.unmodifiableList(
Arrays.asList( values ) );
+    TIME_OF_PASSWORD_EXP ( 6, "time of password expiration" );
 
     /**
      * The name of the checksum type.
      */
-    private final String name;
+    private String name;
 
     /**
      * The value/code for the checksum type.
      */
-    private final int ordinal;
+    private int ordinal;
 
 
     /**
@@ -108,11 +92,11 @@ public final class LastRequestType imple
      */
     public static LastRequestType getTypeByOrdinal( int type )
     {
-        for ( int ii = 0; ii < values.length; ii++ )
+        for ( LastRequestType lrt : LastRequestType.values() )
         {
-            if ( values[ii].ordinal == type )
+            if ( type == lrt.getOrdinal() )
             {
-                return values[ii];
+                return lrt;
             }
         }
 
@@ -131,12 +115,6 @@ public final class LastRequestType imple
     }
 
 
-    public int compareTo( LastRequestType that )
-    {
-        return ordinal - that.ordinal;
-    }
-
-
     public String toString()
     {
         return name + " (" + ordinal + ")";

Modified: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/SamType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/SamType.java?rev=1037549&r1=1037548&r2=1037549&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/SamType.java
(original)
+++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/SamType.java
Sun Nov 21 20:14:14 2010
@@ -20,9 +20,6 @@
 package org.apache.directory.server.kerberos.shared.messages.value;
 
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
 
 
 /**
@@ -30,7 +27,7 @@ import java.util.List;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public final class SamType implements Comparable<SamType>
+public enum SamType
 {
     /*
      * Enumeration elements are constructed once upon class loading.
@@ -38,39 +35,31 @@ public final class SamType implements Co
      */
 
     /** safe SAM type enum for Enigma Logic */
-    public static final SamType PA_SAM_TYPE_ENIGMA = new SamType( 1, "Enigma Logic" );
+    PA_SAM_TYPE_ENIGMA ( 1, "Enigma Logic" ),
 
     /** safe SAM type enum for Digital Pathways */
-    public static final SamType PA_SAM_TYPE_DIGI_PATH = new SamType( 2, "Digital Pathways"
);
+    PA_SAM_TYPE_DIGI_PATH ( 2, "Digital Pathways" ),
 
     /** safe SAM type enum for S/key where KDC has key 0 */
-    public static final SamType PA_SAM_TYPE_SKEY_K0 = new SamType( 3, "S/key where KDC has
key 0" );
+    PA_SAM_TYPE_SKEY_K0 ( 3, "S/key where KDC has key 0" ),
 
     /** safe SAM type enum for Traditional S/Key */
-    public static final SamType PA_SAM_TYPE_SKEY = new SamType( 4, "Traditional S/Key" );
+    PA_SAM_TYPE_SKEY ( 4, "Traditional S/Key" ),
 
     /** safe SAM type enum for Security Dynamics */
-    public static final SamType PA_SAM_TYPE_SECURID = new SamType( 5, "Security Dynamics"
);
+    PA_SAM_TYPE_SECURID ( 5, "Security Dynamics" ),
 
     /** safe SAM type enum for CRYPTOCard */
-    public static final SamType PA_SAM_TYPE_CRYPTOCARD = new SamType( 6, "CRYPTOCard" );
+    PA_SAM_TYPE_CRYPTOCARD ( 6, "CRYPTOCard" ),
 
     /** safe SAM type enum for Apache Software Foundation */
-    public static final SamType PA_SAM_TYPE_APACHE = new SamType( 7, "Apache Software Foundation"
);
-
-    /** Array for building a List of VALUES. */
-    private static final SamType[] values =
-        { PA_SAM_TYPE_ENIGMA, PA_SAM_TYPE_DIGI_PATH, PA_SAM_TYPE_SKEY_K0, PA_SAM_TYPE_SKEY,
PA_SAM_TYPE_SECURID,
-            PA_SAM_TYPE_CRYPTOCARD, PA_SAM_TYPE_APACHE };
-
-    /** a list of all the sam type constants */
-    public static final List<SamType> VALUES = Collections.unmodifiableList( Arrays.asList(
values ) );
+    PA_SAM_TYPE_APACHE ( 7, "Apache Software Foundation" );
 
     /** the name of the sam type */
-    private final String name;
+    private String name;
 
     /** the value/code for the sam type */
-    private final int ordinal;
+    private int ordinal;
 
 
     /**
@@ -95,19 +84,6 @@ public final class SamType implements Co
 
 
     /**
-     * Compares this type to another object hopefully one that is of the same
-     * type.
-     *
-     * @param that the object to compare this SamType to
-     * @return ordinal - ( ( SamType ) that ).ordinal;
-     */
-    public int compareTo( SamType that )
-    {
-        return ordinal - that.ordinal;
-    }
-
-
-    /**
      * Gets the ordinal by its ordinal value.
      *
      * @param ordinal the ordinal value of the ordinal
@@ -115,11 +91,11 @@ public final class SamType implements Co
      */
     public static SamType getTypeByOrdinal( int ordinal )
     {
-        for ( int ii = 0; ii < values.length; ii++ )
+        for ( SamType st : SamType.values())
         {
-            if ( values[ii].ordinal == ordinal )
+            if ( ordinal == st.getOrdinal() )
             {
-                return values[ii];
+                return st;
             }
         }
 



Mime
View raw message