1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
package org.springframework.ldap.odm.tools;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* Simple value class to hold the schema of an object class
* <p>
* It is public only to allow Freemarker access.
*
* @author Paul Harvey <paul.at.pauls-place.me.uk>
*/
public final class ObjectSchema {
private final Set<AttributeSchema> must = new HashSet<AttributeSchema>();
private final Set<AttributeSchema> may = new HashSet<AttributeSchema>();
private final Set<String> objectClass = new HashSet<String>();
public void addMust(AttributeSchema must) {
this.must.add(must);
}
public void addMay(AttributeSchema may) {
this.may.add(may);
}
public void addObjectClass(String objectClass) {
this.objectClass.add(objectClass);
}
public Set<AttributeSchema> getMust() {
return Collections.unmodifiableSet(must);
}
public Set<AttributeSchema> getMay() {
return Collections.unmodifiableSet(may);
}
public Set<String> getObjectClass() {
return Collections.unmodifiableSet(objectClass);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return String.format("objectClass=%1$s | must=%2$s | may=%3$s", objectClass, must, may);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((may == null) ? 0 : may.hashCode());
result = prime * result + ((must == null) ? 0 : must.hashCode());
result = prime * result + ((objectClass == null) ? 0 : objectClass.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ObjectSchema other = (ObjectSchema) obj;
if (may == null) {
if (other.may != null)
return false;
} else if (!may.equals(other.may))
return false;
if (must == null) {
if (other.must != null)
return false;
} else if (!must.equals(other.must))
return false;
if (objectClass == null) {
if (other.objectClass != null)
return false;
} else if (!objectClass.equals(other.objectClass))
return false;
return true;
}
}
|