当前位置: 首页>>代码示例>>Java>>正文


Java Member.getName方法代码示例

本文整理汇总了Java中java.lang.reflect.Member.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Member.getName方法的具体用法?Java Member.getName怎么用?Java Member.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.reflect.Member的用法示例。


在下文中一共展示了Member.getName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPropertyName

import java.lang.reflect.Member; //导入方法依赖的package包/类
/**
 * Process bean properties getter by applying the JavaBean naming conventions.
 *
 * @param member the member for which to get the property name.
 *
 * @return The bean method name with the "is" or "get" prefix stripped off, {@code null}
 *         the method name id not according to the JavaBeans standard.
 */
public static String getPropertyName(Member member) {
	String name = null;

	if ( member instanceof Field ) {
		name = member.getName();
	}

	if ( member instanceof Method ) {
		String methodName = member.getName();
		if ( methodName.startsWith( "is" ) ) {
			name = Introspector.decapitalize( methodName.substring( 2 ) );
		}
		else if ( methodName.startsWith( "has" ) ) {
			name = Introspector.decapitalize( methodName.substring( 3 ) );
		}
		else if ( methodName.startsWith( "get" ) ) {
			name = Introspector.decapitalize( methodName.substring( 3 ) );
		}
	}
	return name;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:ReflectionHelper.java

示例2: createDynamicMethod

import java.lang.reflect.Member; //导入方法依赖的package包/类
/**
 * Given a reflective method or a constructor, creates a dynamic method that represents it. This method will
 * distinguish between caller sensitive and ordinary methods/constructors, and create appropriate caller sensitive
 * dynamic method when needed.
 * @param m the reflective member
 * @return the single dynamic method representing the reflective member
 */
private static SingleDynamicMethod createDynamicMethod(final AccessibleObject m) {
    if(CallerSensitiveDetector.isCallerSensitive(m)) {
        // Method has @CallerSensitive annotation
        return new CallerSensitiveDynamicMethod(m);
    }
    // Method has no @CallerSensitive annotation
    final MethodHandle mh;
    try {
        mh = unreflectSafely(m);
    } catch (final IllegalAccessError e) {
        // java.lang.invoke can in some case conservatively treat as caller sensitive methods that aren't
        // marked with the annotation. In this case, we'll fall back to treating it as caller sensitive.
        return new CallerSensitiveDynamicMethod(m);
    }
    // Proceed with non-caller sensitive
    final Member member = (Member)m;
    return new SimpleDynamicMethod(mh, member.getDeclaringClass(), member.getName(), m instanceof Constructor);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:AbstractJavaLinker.java

示例3: forMember

import java.lang.reflect.Member; //导入方法依赖的package包/类
public static Object forMember(Member member) {
  if (member == null) {
    return SourceProvider.UNKNOWN_SOURCE;
  }

  Class declaringClass = member.getDeclaringClass();

  /*if[AOP]*/
  LineNumbers lineNumbers = lineNumbersCache.getUnchecked(declaringClass);
  String fileName = lineNumbers.getSource();
  Integer lineNumberOrNull = lineNumbers.getLineNumber(member);
  int lineNumber = lineNumberOrNull == null ? lineNumbers.getFirstLine() : lineNumberOrNull;
  /*end[AOP]*/
  /*if[NO_AOP]
  String fileName = null;
  int lineNumber = -1;
  end[NO_AOP]*/

  Class<? extends Member> memberType = Classes.memberType(member);
  String memberName = memberType == Constructor.class ? "<init>" : member.getName();
  return new StackTraceElement(declaringClass.getName(), memberName, fileName, lineNumber);
}
 
开发者ID:maetrive,项目名称:businessworks,代码行数:23,代码来源:StackTraceElements.java

示例4: memberKey

import java.lang.reflect.Member; //导入方法依赖的package包/类
private String memberKey(Member member) {
  checkNotNull(member, "member");

  /*if[AOP]*/
  if (member instanceof Field) {
    return member.getName();

  } else if (member instanceof Method) {
    return member.getName() + org.objectweb.asm.Type.getMethodDescriptor((Method) member);

  } else if (member instanceof Constructor) {
    StringBuilder sb = new StringBuilder().append("<init>(");
    for (Class param : ((Constructor) member).getParameterTypes()) {
        sb.append(org.objectweb.asm.Type.getDescriptor(param));
    }
    return sb.append(")V").toString();

  } else {
    throw new IllegalArgumentException(
        "Unsupported implementation class for Member, " + member.getClass());
  }
  /*end[AOP]*/
  /*if[NO_AOP]
  return "<NO_MEMBER_KEY>";
  end[NO_AOP]*/
}
 
开发者ID:maetrive,项目名称:businessworks,代码行数:27,代码来源:LineNumbers.java

示例5: createDynamicMethod

import java.lang.reflect.Member; //导入方法依赖的package包/类
/**
 * Given a reflective method or a constructor, creates a dynamic method that represents it. This method will
 * distinguish between caller sensitive and ordinary methods/constructors, and create appropriate caller sensitive
 * dynamic method when needed.
 * @param m the reflective member
 * @return the single dynamic method representing the reflective member
 */
private static SingleDynamicMethod createDynamicMethod(final AccessibleObject m) {
    if (m.isAnnotationPresent(CallerSensitive.class)) {
        // Method has @CallerSensitive annotation
        return new CallerSensitiveDynamicMethod(m);
    }
    // Method has no @CallerSensitive annotation
    final MethodHandle mh;
    try {
        mh = unreflectSafely(m);
    } catch (final IllegalAccessError e) {
        // java.lang.invoke can in some case conservatively treat as caller sensitive methods that aren't
        // marked with the annotation. In this case, we'll fall back to treating it as caller sensitive.
        return new CallerSensitiveDynamicMethod(m);
    }
    // Proceed with non-caller sensitive
    final Member member = (Member)m;
    return new SimpleDynamicMethod(mh, member.getDeclaringClass(), member.getName(), m instanceof Constructor);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:AbstractJavaLinker.java

示例6: forMember

import java.lang.reflect.Member; //导入方法依赖的package包/类
public static Object forMember(Member member) {
    if (member == null) {
        return SourceProvider.UNKNOWN_SOURCE;
    }

    Class declaringClass = member.getDeclaringClass();

    String fileName = null;
    int lineNumber = -1;

    Class<? extends Member> memberType = MoreTypes.memberType(member);
    String memberName = memberType == Constructor.class ? "<init>" : member.getName();
    return new StackTraceElement(declaringClass.getName(), memberName, fileName, lineNumber);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:StackTraceElements.java

示例7: toString

import java.lang.reflect.Member; //导入方法依赖的package包/类
/**
 * 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 = 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();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:MoreTypes.java

示例8: MemberImpl

import java.lang.reflect.Member; //导入方法依赖的package包/类
private MemberImpl(Member member) {
    this.declaringClass = member.getDeclaringClass();
    this.name = member.getName();
    this.modifiers = member.getModifiers();
    this.synthetic = member.isSynthetic();
    this.memberType = memberType(member);
    this.memberKey = memberKey(member);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:MoreTypes.java

示例9: serializedName

import java.lang.reflect.Member; //导入方法依赖的package包/类
private static String serializedName(Member member) {
    if(member instanceof AnnotatedElement) {
        SerializedName nameAnnot = ((AnnotatedElement) member).getAnnotation(SerializedName.class);
        if(nameAnnot != null) return nameAnnot.value();
    }
    return member.getName();
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:8,代码来源:DocumentRegistry.java

示例10: multilineDescription

import java.lang.reflect.Member; //导入方法依赖的package包/类
public static String multilineDescription(Member member) {
    return member.getClass().getSimpleName().toLowerCase() +
           " " + member.getName() +
           " of " + multilineDescription(member.getDeclaringClass());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:6,代码来源:ReflectionFormatting.java

示例11: error

import java.lang.reflect.Member; //导入方法依赖的package包/类
public static void error(Member member, String description) {
    throw new IllegalArgumentException(member.getDeclaringClass().getName() + "#" + member.getName() + " " + description);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:Members.java

示例12: gerQualifiedName

import java.lang.reflect.Member; //导入方法依赖的package包/类
public String gerQualifiedName() {
    Member member = getMember();
    return member.getDeclaringClass().getName() + "." + member.getName();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:5,代码来源:FieldInfo.java


注:本文中的java.lang.reflect.Member.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。