# Class: com.pnfsoftware.jeb.util.base.DynamicEnum

Base class for dynamic enumerations. Dynamic enumerations are custom\-built enumerations supporting the addition and removal of entries. 

 A dynamic enum must adhere to a defined contract. It is recommended to use the template below:  

```

 @Ser
 static public class Something extends DynamicEnum<Something\> {
     // --- start of static fields ---
     protected static LinkedHashMap<String, Something> map = new LinkedHashMap<>();
     // built-in constants must be created here (or in the a static initializer block)
     public static final Something UNKNOWN = register(0, "UNKNOWN");
     public static final Something BLAH = register(1, "BLAH");
     public static final Something FOOBAR = register(2, "FOOBAR");
     // count of built-in constants; those cannot be unregistered!
     public static final int builtinCount = map.size();
     // --- end of static fields ---

     // non-static fields are allowed, but naturally restricted to simple types (primitives, strings, etc.)
 
     // id and name are mandatory
     protected Something(int id, String name) {
         super(id, name);
     }
 
     @Override
     public int ordinal() {
         return ordinal(map, this);
     }
 
     public static int count() {
         return map.size();
     }
 
     public static Collection<Something\> values() {
         return values(map);
     }
 
     public static Something valueOf(String name) {
         return valueOf(map, name, UNKNOWN);
     }
 
     public static Something valueOf(int id) {
         return valueOf(map, id, UNKNOWN);
     }
 
     public static Something register(int id, String name) {
         return register(map, new Something(id, name));
     }
 
     public static boolean unregister(String name) {
         return unregister(map, builtinCount, name);
     }
 }
 
```

## Protected Constructor: DynamicEnum
- parameter: `id`, type: `int`
- parameter: `name`, type: `java.lang.String`


## Protected Field: id
Type: `int`

## Protected Field: name
Type: `java.lang.String`

## Method: equals
- parameter: `obj`, type: `java.lang.Object`
- return type: `boolean`


## Method: hashCode
- return type: `int`


## Method: id
- return type: `int`


## Method: isCompatibleWith
- parameter: `other`, type: `E`
- return type: `boolean`

Description: Determine whether two dyn.enums are compatible. This default implementation performs a name\-based compatibility test, using \_ as a hierarchical separator. An enum named SOME\_THING is compatible with SOME\_THING\_ELSE, SOME, but not with SO, SOM, SOMETHING, SOME\_FOO or SOME\_THINGELSE. 

 This method may be overridden.
parameter: other: another enum
return: true if this enumerated constant is compatible with the provided enumerated constant

## Method: name
- return type: `java.lang.String`


## Method: ordinal
- return type: `int`


## Method: toString
- return type: `java.lang.String`


## Protected Static Method: isBuiltin
- parameter: `map`, type: `java.util.Map<java.lang.String,E>`
- parameter: `builtinCount`, type: `int`
- parameter: `e`, type: `E`
- return type: `boolean`


## Protected Static Method: ordinal
- parameter: `map`, type: `java.util.Map<java.lang.String,E>`
- parameter: `e`, type: `E`
- return type: `int`


## Protected Static Method: register
- parameter: `map`, type: `java.util.Map<java.lang.String,E>`
- parameter: `e`, type: `E`
- return type: `E`


## Protected Static Method: unregister
- parameter: `map`, type: `java.util.Map<java.lang.String,E>`
- parameter: `builtinCount`, type: `int`
- parameter: `name`, type: `java.lang.String`
- return type: `boolean`


## Protected Static Method: valueOf
- parameter: `map`, type: `java.util.Map<java.lang.String,E>`
- parameter: `id`, type: `int`
- parameter: `def`, type: `E`
- return type: `E`

Description: 
parameter: E: 
parameter: map: 
parameter: id: 
parameter: def: optional; useful when deserializing unknown entries / entries that have not been            re\-registered
return: an entry or the provided default entry \(which may be null\)

## Protected Static Method: valueOf
- parameter: `map`, type: `java.util.Map<java.lang.String,E>`
- parameter: `name`, type: `java.lang.String`
- parameter: `def`, type: `E`
- return type: `E`

Description: 
parameter: E: 
parameter: map: 
parameter: name: 
parameter: def: optional; useful when deserializing unknown entries / entries that have not been            re\-registered
return: an entry or the provided default entry \(which may be null\)

## Protected Static Method: values
- parameter: `map`, type: `java.util.Map<java.lang.String,E>`
- return type: `java.util.Collection<E>`


## Protected Static Method: verifyAvailability
- parameter: `map`, type: `java.util.Map<java.lang.String,E>`
- parameter: `id`, type: `int`
- parameter: `name`, type: `java.lang.String`


