net.sf.andromedaioc.model.beans.ReferenceKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of andromeda-ioc Show documentation
Show all versions of andromeda-ioc Show documentation
Inversion of Control Framework for Android
The newest version!
package net.sf.andromedaioc.model.beans;
public class ReferenceKey {
public final static ReferenceKey BY_TYPE = new ReferenceKey(null, ReferenceType.BY_TYPE);
private final String id;
private final ReferenceType type;
public static ReferenceKey newPlainReferenceKey(String id) {
return new ReferenceKey(id, ReferenceType.PLAIN);
}
public static ReferenceKey newInnerReferenceKey(String id) {
return new ReferenceKey(id, ReferenceType.INNER);
}
public static ReferenceKey newUndefinedReferenceKey(String id) {
return new ReferenceKey(id, ReferenceType.UNDEFINED);
}
private ReferenceKey(String id, ReferenceType type) {
this.id = id;
this.type = type;
}
public String getId() {
return id;
}
public ReferenceType getType() {
return type;
}
public boolean isInner() {
return ReferenceType.INNER.equals(type);
}
@Override
public boolean equals(Object o) {
if(this == o) {
return true;
}
if(o == null || getClass() != o.getClass()){
return false;
}
ReferenceKey other = (ReferenceKey) o;
if(type != null ? !type.equals(other.type) : other.type != null) {
return false;
}
if(id != null ? !id.equals(other.id) : other.id != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = id == null ? 0 : id.hashCode();
result = 31 * result + (type == null ? 0 : type.hashCode());
return result;
}
@Override
public String toString() {
return type.name() + ":" + id;
}
}