Platform SDK Java 8.5 API Reference

com.genesyslab.platform.commons
Class GEnum

java.lang.Object
  extended by com.genesyslab.platform.commons.GEnum
Direct Known Subclasses:
AbstractLogger.Level, Action, ActionDataType, ActionType, ActorType, AddressInfoType, AddressStatusInfoType, AddressType, AgentStateChangeOperation, AgentWorkMode, AlarmCause, AlarmStatus, ApplicationExecutionMode, ApplicationStatus, CallbackType, CallInfoType, CallResult, CallState, CallType, CallType, CampaignActions, CampaignMode, CampaignStatus, Cause, CfgAccessGroupType, CfgActionCodeType, CfgAlarmCategory, CfgAppComponentType, CfgAppType, CfgBorErrorType, CfgCallActionCode, CfgCallMode, CfgChargeType, CfgClassType, CfgCTILinkType, CfgDataType, CfgDialMode, CfgDIDGroupType, CfgDNGroupType, CfgDNRegisterFlag, CfgDNType, CfgEnumeratorObjectType, CfgEnumeratorType, CfgEnumType, CfgErrorType, CfgFieldType, CfgFlag, CfgFolderClass, CfgGroupType, CfgHAType, CfgHostType, CfgIVRProfileType, CfgIVRType, CfgLanguage, CfgLanguageLCID, CfgLinkType, CfgMediaType, CfgObjectiveTableType, CfgObjectProperty, CfgObjectState, CfgObjectType, CfgOperationalMode, CfgOperationMode, CfgOptimizationMethod, CfgOSType, CfgPackCodeType, CfgPermissions, CfgPersonType, CfgRank, CfgRecActionCode, CfgResourceType, CfgRouteType, CfgScriptType, CfgSelectionMode, CfgSolutionType, CfgStartupType, CfgStatDayType, CfgStatTableType, CfgStructureType, CfgSwitchType, CfgTableType, CfgTargetType, CfgTaskType, CfgTraceMode, CfgTransactionType, CfgUpdatePackageStatus, ChainAttribute, ChannelState, ClientType, ConnectionState, ControlMode, ControlObjectType, DataStreamType, DialMode, DnActions, DNRole, ErrorCode, ErrorCode, ErrorCodes, Errors, Errors, Errors, Errors, Errors, EventType, ForwardMode, GctiCallState, GctiContactType, GctiRecordStatus, GctiRecordType, GroupCampaignStatus, HostStatus, InteractionClient, InteractionOperation, InteractionState, KeyFlags, LocationInfoType, LogCategory, LogDataFormat, LogLevel, MakeCallType, MediaActions, MediaState, MediaType, MediaType, MergeType, MessagePriority, MessageTypes, MonitorNextCallType, MsgCheck, MsgCheck, NamedGEnum, NetworkCallState, NetworkDestState, NetworkPartyRole, NoticeType, NotificationMode, OptimizationMethod, PartyState, PartyType, PhoneType, ProcessingStatus, ProtocolType, RecordStatus, RecordType, RegisterMode, RegModeMask, Reliability, RequestResult, RoutePointActions, RouteType, RoutingPointStatus, ServerRole, SessionStatus, SetOpType, SolutionStatus, StatisticCategory, StatisticInterval, StatisticObjectType, StatisticProfile, StatisticSubject, StatisticUsage, Status, Status, Style, SubscriptionOperationType, SwitchInfoType, TargetType, TokenType, TreatAs, TreatAs, Treatment, TreatmentType, UserStatus, UserType, UserType, Visibility, VisibilityMode, WarmStandbyState, WorkbinContentOperation, WorkbinType, XRouteType

public abstract class GEnum
extends java.lang.Object

Superclass for classes that represent C-like (or JDK 1.5) enumerations. "Type safe enumeration" pattern implementation with some extensions to retrieve enumeration values by their "ordinal" integer values and names.


Field Summary
protected static java.util.Locale LOCALE_ENGLISH
           
 
Constructor Summary
protected GEnum(int ordinal, java.lang.String name, java.lang.Class enumClass)
          Creates enumeration value.
 
Method Summary
 java.lang.Integer asInteger()
          Returns Integer value of the enumeration member.
static int enumSize(java.lang.Class enumClass)
          Returns size (count of values) for the given enumeration (specified by enumClass).
 boolean equals(GEnum e1, GEnum e2)
           
 boolean equals(java.lang.Object obj)
           
protected static
<E extends GEnum>
java.util.Map<java.lang.Object,E>
getEnumMap(java.lang.Class<E> enumClass)
           
protected static
<E extends GEnum>
java.util.Set<E>
getEnumValues(java.lang.Class<E> enumClass)
           
static GEnum getValue(java.lang.Class enumClass, int ordinal)
          Returns enumeration value with specified ordinal value or null if no such value exists.
static GEnum getValue(java.lang.Class enumClass, java.lang.Integer ordinal)
          Returns enumeration value with specified ordinal value or null if no such value exists.
static GEnum getValue(java.lang.Class enumClass, java.lang.String name)
          Returns enumeration value with specified name or null if no such value exists.
 int hashCode()
           
 java.lang.String name()
          Returns name of the enumeration member.
 int ordinal()
          Returns the enumeration value as an integer.
 java.lang.String toString()
           
static
<E extends GEnum>
E
valueOf(java.lang.Class<E> enumClass, int ordinal)
          Returns enumeration value by given ordinal number.
static
<E extends GEnum>
E
valueOf(java.lang.Class<E> enumClass, java.lang.String name)
          Returns enumeration value with specified name or null if no such value exists.
static java.util.Collection values(java.lang.Class enumClass)
          Returns all values of the given (specified by enumClass) enumeration.
static
<E extends GEnum>
java.util.Collection<E>
valuesBy(java.lang.Class<E> enumClass)
          Returns all values of the given (specified by enumClass) enumeration.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCALE_ENGLISH

protected static final java.util.Locale LOCALE_ENGLISH
Constructor Detail

GEnum

protected GEnum(int ordinal,
                java.lang.String name,
                java.lang.Class enumClass)
Creates enumeration value. It is advised for inheritors to declare constructor with first two parameters (int, String) and call super() with these parameters and own class.
 class MyEnum extends GEnum {

     public static final MyEnum BLACK = new MyEnum(0, "Black");
     public static final MyEnum WHITE = new MyEnum(1, "White");

     private MyEnum(final int ordinal, final String name) {
         super(ordinal, name, MyEnum.class);
     }

 }
 
Note: This class does NOT support parallel multithreaded construction of enumeration options (It uses unsynchronized internal structures during creation and some operations). But while it's usage is similar to example above (static constants) we can rely on safe creation of static members.

Parameters:
ordinal - ordinal value of the enumeration option
name - name of the enumeration option
enumClass - class of the enumeration
Method Detail

ordinal

public int ordinal()
Returns the enumeration value as an integer.

Returns:
int value of the enumeration member

name

public java.lang.String name()
Returns name of the enumeration member.

Returns:
name of the enumeration member

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(GEnum e1,
                      GEnum e2)

values

public static java.util.Collection values(java.lang.Class enumClass)
Returns all values of the given (specified by enumClass) enumeration.

Parameters:
enumClass - actual class of the enumeration
Returns:
all enumeration values
Throws:
java.lang.NullPointerException - if given enumClass is null
java.lang.IllegalArgumentException - if enumClass is not enumeration
See Also:
valuesBy(Class)

valueOf

public static <E extends GEnum> E valueOf(java.lang.Class<E> enumClass,
                                          int ordinal)
Returns enumeration value by given ordinal number. Note that there is no guaranty for some arbitrary enumeration that order is strict.

Parameters:
enumClass - actual class of the enumeration
ordinal - ordinal number of the enumeration value
Returns:
the enumeration value with given ordinal number or null

valueOf

public static <E extends GEnum> E valueOf(java.lang.Class<E> enumClass,
                                          java.lang.String name)
Returns enumeration value with specified name or null if no such value exists.

Parameters:
enumClass - actual class of the enumeration
name - name of value in the enumeration
Returns:
enumeration value with specified name or null

valuesBy

public static <E extends GEnum> java.util.Collection<E> valuesBy(java.lang.Class<E> enumClass)
Returns all values of the given (specified by enumClass) enumeration.

Parameters:
enumClass - actual class of the enumeration
Returns:
all enumeration values

enumSize

public static int enumSize(java.lang.Class enumClass)
Returns size (count of values) for the given enumeration (specified by enumClass).

Parameters:
enumClass - actual class of the enumeration
Returns:
size of the enumeration
Throws:
java.lang.IllegalArgumentException - if enumClass is not enumeration

getValue

public static GEnum getValue(java.lang.Class enumClass,
                             java.lang.Integer ordinal)
Returns enumeration value with specified ordinal value or null if no such value exists. Note that there is no guaranty for some arbitrary enumeration that order is strict.

Parameters:
enumClass - actual class of the enumeration
ordinal - order of value in the enumeration
Returns:
enumeration value with specified ordinal or null
Throws:
java.lang.IllegalArgumentException - if enumClass is not enumeration
See Also:
valueOf(Class, int)

getValue

public static GEnum getValue(java.lang.Class enumClass,
                             int ordinal)
Returns enumeration value with specified ordinal value or null if no such value exists. Note that there is no guaranty for some arbitrary enumeration that order is strict.

Parameters:
enumClass - actual class of the enumeration
ordinal - order of value in the enumeration
Returns:
enumeration value with specified ordinal or null
Throws:
java.lang.IllegalArgumentException - if enumClass is not enumeration
See Also:
valueOf(Class, int)

getValue

public static GEnum getValue(java.lang.Class enumClass,
                             java.lang.String name)
Returns enumeration value with specified name or null if no such value exists.

Parameters:
enumClass - actual class of the enumeration
name - name of value in the enumeration
Returns:
enumeration value with specified ordinal or null
Throws:
java.lang.IllegalArgumentException - if enumClass is not enumeration
See Also:
valueOf(Class, String)

asInteger

public java.lang.Integer asInteger()
Returns Integer value of the enumeration member. Use it when you really need Integer. If you need int value use ordinal() method.

Returns:
Integer value of enumeration member
See Also:
ordinal()

getEnumMap

protected static <E extends GEnum> java.util.Map<java.lang.Object,E> getEnumMap(java.lang.Class<E> enumClass)

getEnumValues

protected static <E extends GEnum> java.util.Set<E> getEnumValues(java.lang.Class<E> enumClass)

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.