Java 8 Member - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Member class.

This code example shows how to use the following methods:getDeclaringClass, getModifiers
			throw new UnsupportedOperationException("Should not be called on an OptimalPropertyAccessor");
		} 
		 
		@Override 
		public boolean isCompilable() { 
			return (Modifier.isPublic(this.member.getModifiers()) &&
					Modifier.isPublic(this.member.getDeclaringClass().getModifiers()));
		} 
 
		@Override 
		public Class<?> getPropertyType() {
			if (this.member instanceof Field) {
				return ((Field) this.member).getType();
			} 
			else { 
				return ((Method) this.member).getReturnType();
			} 
		} 
 
		@Override 
7
CodeRank
This code example shows how to use the following methods:getName
 
    public static String getPropertyName(Member member) {
        if (member instanceof Method) {
            return getPropertyName((Method) member);
        } 
        return member.getName();
    } 
 
    public static Annotated getResourceAnnotated(InjectionPoint injectionPoint) {
 
        if(injectionPoint instanceof ParameterInjectionPoint) {
            return ((ParameterInjectionPoint<?, ?>)injectionPoint).getAnnotated().getDeclaringCallable();
        } 
        return injectionPoint.getAnnotated();
    } 
 
} 
7
CodeRank
This code example shows how to use the following methods:getDeclaringClass, getModifiers, getName
		return declaringMatcher;
	} 
 
	@Override 
	public boolean isMatch(final T value, final Object parent) {
		final int mods = value.getModifiers();
 
		// Match accessibility and name 
		return (mods & modifiersRequired) == modifiersRequired && (mods & modifiersBanned) == 0 && declaringMatcher.isMatch(value.getDeclaringClass(), value)
				&& isNameMatch(value.getName());
	} 
 
	/** 
	 * Determine if a given name matches the current member matcher. 
	 *  
	 * @param name 
	 *            - the name to match. 
	 * @return TRUE if the name matches, FALSE otherwise. 
	 */ 
	private boolean isNameMatch(final String name) {
6
CodeRank
This code example shows how to use the following methods:getModifiers
    /* 
    * checks if a class's member (method, constructor or field) has a 'static' 
    * modifier. 
    */ 
    public static boolean isStatic(Member member) {
        return (Modifier.isStatic(member.getModifiers()));
    } 
 
    /* 
    * checks if the given class is declared as static (inner classes only) 
    */ 
    public static boolean isStatic(Class c) {
        return (Modifier.isStatic(c.getModifiers()));
    } 
 
    /* 
    * checks if a class's member (method, constructor or field) has a 'final' 
    * modifier. 
    */ 
    public static boolean isFinal(Member member) {
6
CodeRank
This code example shows how to use the following methods:getDeclaringClass, getModifiers
        if (pack==null)
            return false; 
        if (member==null)
            return false; 
         
        int modifiers = member.getModifiers();
        if (Modifier.isPublic(modifiers))
            return true; 
        if (Modifier.isProtected(modifiers))
            return true; 
        if (!Modifier.isPrivate(modifiers) && pack.equals(member.getDeclaringClass().getPackage()))
            return true; 
        
        return false; 
    } 
     
    
     
     
    public static boolean checkParams (Class<?>[] formalParams, Class<?>[] actualParams, boolean strict)
6
CodeRank
This code example shows how to use the following methods:getClass, getDeclaringClass, getName
   */ 
  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();
    } 
  } 
 
  /** 
   * Returns {@code Field.class}, {@code Method.class} or {@code Constructor.class}. 
   */ 
  public static Class<? extends Member> memberType(Member member) {
    checkNotNull(member, "member");

7
CodeRank
This code example shows how to use the following methods:getModifiers
   public M getJavaMember() { 
      return javaMember;
   } 
 
   public boolean isStatic() { 
      return Modifier.isStatic(javaMember.getModifiers());
   } 
 
} 
6
CodeRank
This code example shows how to use the following methods:getName
public class ShortNameFactory implements NameFactory { 
  public String getMemberName(Member member) {
    if (member instanceof Constructor) {
      return "<init>"; 
    } else if (member instanceof Method) {
      return "#" + member.getName() + "(...)";
    } else { 
      return member.getName();      
    } 
  } 
 
  public String getAnnotationName(Key<?> key) {
    Annotation annotation = key.getAnnotation();
    Class<? extends Annotation> annotationType = key.getAnnotationType();
    if (annotation != null) {
      annotationType = annotation.annotationType();
 
      String annotationString = annotation.toString();
      String canonicalName = annotationType.getName();
      String simpleName = annotationType.getSimpleName();
6
CodeRank
This code example shows how to use the following methods:getDeclaringClass
		return new ConstraintLocation( declaringClass, null, type );
	} 
 
	public static ConstraintLocation forProperty(Member member) {
		return new ConstraintLocation( 
				member.getDeclaringClass(),
				member,
				ReflectionHelper.typeOf( member )
		); 
	} 
 
	public static ConstraintLocation forTypeArgument(Member member, Type type) {
		return new ConstraintLocation( 
				member.getDeclaringClass(),
				member,
				type
		); 
	} 
 
	public static ConstraintLocation forReturnValue(ExecutableElement executable) {
6
CodeRank
This code example shows how to use the following methods:getModifiers
   public M getJavaMember() { 
      return javaMember;
   } 
 
   public boolean isStatic() { 
      return Modifier.isStatic(javaMember.getModifiers());
   } 
 
} 
6
CodeRank

Related Java 8 Member Questions & Answers:

See Code Examples for Java 8 Member Methods: