package com.apehat.algalon.event;

import com.apehat.algalon.common.AttributeFactory;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;

/**
 * @author cflygoo
 */
public final class BodyAttributeFactory {

  private BodyAttributeFactory() {
  }

  public static BodyAttribute getAttribute(Member member) {
    if (member instanceof Method) {
      return new MethodBodyAttribute(
          AttributeFactory.getAttribute((Method) member));
    }
    return new FieldBodyAttribute(
        AttributeFactory.getAttribute((Field) member));
  }

  public static BodyAttribute getAttribute(String name, Member member) {
    if (member instanceof Method) {
      return new MethodBodyAttribute(
          AttributeFactory.getAttribute((Method) member, name));
    }
    return new FieldBodyAttribute(
        AttributeFactory.getAttribute((Field) member, name));
  }
}
