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?