org.pure4j.model.ClassHandle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pure4j-checker Show documentation
Show all versions of pure4j-checker Show documentation
Parses Byte-code to check the purity semantics defined using pure4j-core annotations
The newest version!
package org.pure4j.model;
import java.lang.reflect.AnnotatedElement;
public class ClassHandle extends AbstractHandle> implements AnnotatedElementHandle> {
public ClassHandle(Class> c) {
this.className = convertClassName(c);
}
public ClassHandle(String className) {
this.className = className;
}
protected String className;
public Class> hydrate(ClassLoader cl) {
return hydrateClass(className, cl);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((className == null) ? 0 : className.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;
ClassHandle other = (ClassHandle) obj;
if (className == null) {
if (other.className != null)
return false;
} else if (!className.equals(other.className))
return false;
return true;
}
public int compareTo(AnnotatedElementHandle extends AnnotatedElement> o) {
if (o instanceof ClassHandle) {
ClassHandle ch = (ClassHandle) o;
return this.className.compareTo(ch.className);
} else {
return -1;
}
}
public String getDeclaringClass() {
return className;
}
@Override
public Class> getDeclaringClass(ClassLoader cl) {
return hydrate(cl);
}
}