Package jfun.yan

Source Code of jfun.yan.FieldFunction

package jfun.yan;
import jfun.util.Misc;
import jfun.util.SerializableField;
import jfun.yan.function.Function;

/**
* Codehaus.org.
*
* @author Ben Yu
*
*/
final class FieldFunction implements Function{
  private final Object obj;
  private final jfun.util.SerializableField fld;
  private static final Class[] param_types = new Class[0];
  public Object call(Object[] args)
  throws IllegalAccessException{
    return fld.getField().get(obj);
  }
  public Class[] getParameterTypes() {
    return param_types;
  }
  public Class getReturnType() {
    return fld.getField().getType();
  }
  public boolean isConcrete(){
    return false;
  }
  FieldFunction(final Object obj, final java.lang.reflect.Field fld) {
    this.obj = obj;
    this.fld = new SerializableField(fld);
  }
 
  public boolean equals(Object other) {
    if(other instanceof FieldFunction){
      final FieldFunction m2 = (FieldFunction)other;
      return obj==m2.obj && fld.equals(m2.fld);
    }
    else return false;
  }
  public String getName() {
    return fld.getField().getName();
  }
  public int hashCode() {
    return Misc.hashcode(obj)*31+fld.hashCode();
  }
  public String toString() {
    return fld.toString();
  }
}
TOP

Related Classes of jfun.yan.FieldFunction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.