webit.script.util.bean.FieldInfo Maven / Gradle / Ivy
// Copyright (c) 2013, Webit Team. All Rights Reserved.
package webit.script.util.bean;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
/**
*
* @author Zqq
*/
public final class FieldInfo implements Comparable {
public final String name;
public final int hashCode;
public final Class parent;
private Method getterMethod;
private Field field;
private Method setterMethod;
private boolean isFinal = false;
public FieldInfo(Class parent, String name) {
this.parent = parent;
this.name = name;
this.hashCode = name.hashCode();
}
public Method getGetterMethod() {
return getterMethod;
}
public void setGetterMethod(Method getterMethod) {
this.getterMethod = getterMethod;
}
public Method getSetterMethod() {
return setterMethod;
}
public void setSetterMethod(Method setterMethod) {
this.setterMethod = setterMethod;
}
public Field getField() {
return field;
}
public void setField(Field field) {
this.field = field;
this.isFinal = Modifier.isFinal(field.getModifiers());
}
public boolean isIsFinal() {
return isFinal;
}
public int compareTo(FieldInfo o) {
return this.hashCode - o.hashCode;
}
@Override
public int hashCode() {
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final FieldInfo other = (FieldInfo) obj;
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if (this.parent != other.parent && (this.parent == null || !this.parent.equals(other.parent))) {
return false;
}
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy