java.lang.reflect.Member类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中java.lang.reflect.Member类的一些代码示例,展示了Member类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Member类的具体详情如下:
包路径:java.lang.reflect.Member
类名称:Member

Member介绍

[英]Common interface providing access to reflective information on class members.
[中]提供对类成员的反射信息的访问的公共接口。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public boolean isCompilable() {
  return (Modifier.isPublic(this.member.getModifiers()) &&
      Modifier.isPublic(this.member.getDeclaringClass().getModifiers()));
}

代码示例来源:origin: google/guava

@Override
public final String getName() {
 return member.getName();
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Returns whether a {@link Member} is accessible.
 * @param m Member to check
 * @return {@code true} if <code>m</code> is accessible
 */
static boolean isAccessible(final Member m) {
  return m != null && Modifier.isPublic(m.getModifiers()) && !m.isSynthetic();
}

代码示例来源:origin: JakeWharton/butterknife

private static <T extends AccessibleObject & Member> void validateMember(T object) {
 int modifiers = object.getModifiers();
 if ((modifiers & (PRIVATE | STATIC)) != 0) {
  throw new IllegalStateException(object.getDeclaringClass().getName()
    + "."
    + object.getName()
    + " must not be private or static");
 }
 if ((modifiers & PUBLIC) == 0) {
  object.setAccessible(true);
 }
}

代码示例来源:origin: google/guava

@Override
public final int getModifiers() {
 return member.getModifiers();
}

代码示例来源:origin: google/guava

@Override
public Class<?> getDeclaringClass() {
 return member.getDeclaringClass();
}

代码示例来源:origin: hibernate/hibernate-orm

public String determineMemberDescription(Member member) {
  return member.getDeclaringClass().getName() + '#' + member.getName();
}

代码示例来源:origin: google/guava

@Override
public final boolean isSynthetic() {
 return member.isSynthetic();
}

代码示例来源:origin: prestodb/presto

public static boolean isConcrete(Member member)
{
  int mod = member.getModifiers();
  return (mod & (Modifier.INTERFACE | Modifier.ABSTRACT)) == 0;
}

代码示例来源:origin: prestodb/presto

@Override
public Class<?> getDeclaringClass() {
 return member.getDeclaringClass();
}

代码示例来源:origin: spring-projects/spring-framework

@Override
  public void generateCode(String propertyName, MethodVisitor mv, CodeFlow cf) {
    boolean isStatic = Modifier.isStatic(this.member.getModifiers());
    String descriptor = cf.lastDescriptor();
    String classDesc = this.member.getDeclaringClass().getName().replace('.', '/');
    if (!isStatic) {
      if (descriptor == null) {
        cf.loadTarget(mv);
      }
      if (descriptor == null || !classDesc.equals(descriptor.substring(1))) {
        mv.visitTypeInsn(CHECKCAST, classDesc);
      }
    }
    else {
      if (descriptor != null) {
        // A static field/method call will not consume what is on the stack,
        // it needs to be popped off.
        mv.visitInsn(POP);
      }
    }
    if (this.member instanceof Method) {
      mv.visitMethodInsn((isStatic ? INVOKESTATIC : INVOKEVIRTUAL), classDesc, this.member.getName(),
          CodeFlow.createSignatureDescriptor((Method) this.member), false);
    }
    else {
      mv.visitFieldInsn((isStatic ? GETSTATIC : GETFIELD), classDesc, this.member.getName(),
          CodeFlow.toJvmDescriptor(((Field) this.member).getType()));
    }
  }
}

代码示例来源:origin: com.google.inject/guice

/**
 * Formats a member as concise string, such as {@code java.util.ArrayList.size}, {@code
 * java.util.ArrayList<init>()} or {@code java.util.List.remove()}.
 */
public static String toString(Member member) {
 Class<? extends Member> memberType = Classes.memberType(member);
 if (memberType == Method.class) {
  return member.getDeclaringClass().getName() + "." + member.getName() + "()";
 } else if (memberType == Field.class) {
  return member.getDeclaringClass().getName() + "." + member.getName();
 } else if (memberType == Constructor.class) {
  return member.getDeclaringClass().getName() + ".<init>()";
 } else {
  throw new AssertionError();
 }
}

代码示例来源:origin: prestodb/presto

@Override
public final boolean isSynthetic() {
 return member.isSynthetic();
}

代码示例来源:origin: redisson/redisson

/**
 * Returns <code>true</code> if class member is public and if its declaring class is also public.
 */
public static boolean isPublicPublic(Member member) {
  if (Modifier.isPublic(member.getModifiers())) {
    if (Modifier.isPublic(member.getDeclaringClass().getModifiers())) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: redisson/redisson

public static boolean isConcrete(Member member)
{
  int mod = member.getModifiers();
  return (mod & (Modifier.INTERFACE | Modifier.ABSTRACT)) == 0;
}

代码示例来源:origin: prestodb/presto

@Override
public final String getName() {
 return member.getName();
}

代码示例来源:origin: google/j2objc

@Override
public Class<?> getDeclaringClass() {
 return member.getDeclaringClass();
}

代码示例来源:origin: hibernate/hibernate-orm

/**
   * Used by JDK serialization...
   *
   * @param oos The output stream to which we are being written...
   * @throws IOException Indicates a general IO stream exception
   */
  protected void writeObject(ObjectOutputStream oos) throws IOException {
    oos.defaultWriteObject();
    oos.writeObject( getJavaMember().getDeclaringClass().getName() );
    oos.writeObject( getJavaMember().getName() );
    // should only ever be a field or the getter-method...
    oos.writeObject( Method.class.isInstance( getJavaMember() ) ? "method" : "field" );
  }
}

代码示例来源:origin: org.assertj/assertj-core

/**
 * Returns whether a Member is accessible.
 * @param m Member to check
 * @return true if <code>m</code> is accessible
 */
static boolean isAccessible(Member m) {
  return m != null && Modifier.isPublic(m.getModifiers()) && !m.isSynthetic();
}

代码示例来源:origin: google/j2objc

@Override
public final boolean isSynthetic() {
 return member.isSynthetic();
}

相关文章