Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using an enum to represent an LDAP structure

807580Aug 6 2010 — edited Aug 6 2010
I'm trying to represent an LDAP structure with an enum. The main LDAP enum represents object classes that can have 0, 1 or many attributes. Here is what I have:
public enum LDAP {
  
  TOP_OBJECTCLASS("top"),
  AB_OBJECTCLASS("ab", Attributes.A, Attributes.B),
  CDE_OBJECTCLASS("cde", Attributes.C, Attributes.D, Attributes.E);
            
  public enum Attributes {
            
    A("a"),
    B("b"),
    C("c"),
    D("d"),
    E("e");
            
    private final String value;
            
    private Attributes(String value) {        
      this.value = value;
    }
            
    public String value() {
      return value;
    }
  }
        
  private final String value;
  private final Attributes[] attributes;
        
  private LDAP(String value, Attributes... attributes) {        
    this.value = value;
    this.attributes = attributes;
  }
        
  public String value() {
    return value;
  }
        
  public Attributes[] attributes() {
    return attributes;
  }
}
This however doesn't really work, because having attributes() return an array means it is not usable. What I want to do is:
LDAP.AB_OBJECTCLASS.A;
LDAP.CDE_OBJECTCLASS.C;
LDAP.CDE_OBJECTCLASS.D;
// etc.....
Can anyone help?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 3 2010
Added on Aug 6 2010
4 comments
216 views