Package jfun.yan

Source Code of jfun.yan.FloatingFieldFunction

package jfun.yan;

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


/**
* For an instance field with the receiver object not fixed.
* <p>
* Zephyr Business Solution
*
* @author Ben Yu
*
*/
final class FloatingFieldFunction implements Function {
  private final Class type;
  private final SerializableField fld;
  public boolean isConcrete(){
    return false;
  }
  FloatingFieldFunction(final Class type,
      final java.lang.reflect.Field fld) {
    this.type = type;
    this.fld = new SerializableField(fld);
  }
  public Class getReturnType() {
    return fld.getField().getType();
  }
  public Class[] getParameterTypes() {
    return new Class[]{type};
  }
  public Object call(Object[] args)
  throws IllegalAccessException{
    return fld.getField().get(args[0]);
  }

  public boolean equals(Object obj) {
    if(obj instanceof FloatingFieldFunction){
      final FloatingFieldFunction other = (FloatingFieldFunction)obj;
      return type.equals(other.type) && fld.equals(other.fld);
    }
    else return false;
  }
  public int hashCode() {
    return type.hashCode()*31+fld.hashCode();
  }
  public String toString() {
    return jfun.util.Misc.getTypeName(type)
      + "::" + fld.getField().getName();
  }
  public String getName(){
    return fld.getField().getName();
  }
}
TOP

Related Classes of jfun.yan.FloatingFieldFunction

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.