Field.isAnnotationPresent
Code IndexAdd Codota to your IDE (free)

Best Java code snippets using java.lang.reflect.Field.isAnnotationPresent (Showing top 20 results out of 9,315)

  • Common ways to obtain Field
private void myMethod () {
Field f =
  • Class clazz;String name;clazz.getDeclaredField(name)
  • Class clazz;String name;clazz.getField(name)
  • Object object;String name;object.getClass().getDeclaredField(name)
  • Smart code suggestions by Codota
}
origin: libgdx/libgdx

/** Returns true if the field includes an annotation of the provided class type. */
public boolean isAnnotationPresent (Class<? extends java.lang.annotation.Annotation> annotationType) {
  return field.isAnnotationPresent(annotationType);
}
origin: libgdx/libgdx

/** Returns true if the field includes an annotation of the provided class type. */
public boolean isAnnotationPresent (Class<? extends java.lang.annotation.Annotation> annotationType) {
  return field.isAnnotationPresent(annotationType);
}
origin: org.mockito/mockito-core

/**
 * Check if the field is annotated by the given annotation.
 *
 * @param annotationClass The annotation type to check.
 * @return <code>true</code> if the field is annotated by this annotation, else <code>false</code>.
 */
public boolean isAnnotatedBy(Class<? extends Annotation> annotationClass) {
  return field.isAnnotationPresent(annotationClass);
}
origin: org.mockito/mockito-core

private boolean isAnnotatedByMockOrSpy(Field field) {
  return field.isAnnotationPresent(Spy.class) || field.isAnnotationPresent(Mock.class);
}
origin: google/j2objc

/**
 * Check if the field is annotated by the given annotation.
 *
 * @param annotationClass The annotation type to check.
 * @return <code>true</code> if the field is annotated by this annotation, else <code>false</code>.
 */
public boolean isAnnotatedBy(Class<? extends Annotation> annotationClass) {
  return field.isAnnotationPresent(annotationClass);
}
origin: Atmosphere/atmosphere

protected boolean pathParams(Object o) {
  for (Field field : o.getClass().getDeclaredFields()) {
    if (field.isAnnotationPresent(PathParam.class)) {
      return true;
    }
  }
  return false;
}
origin: org.mockito/mockito-core

  private static void assertNoIncompatibleAnnotations(Class<? extends Annotation> annotation,
                            Field field,
                            Class<? extends Annotation>... undesiredAnnotations) {
    for (Class<? extends Annotation> u : undesiredAnnotations) {
      if (field.isAnnotationPresent(u)) {
        throw unsupportedCombinationOfAnnotations(annotation.getSimpleName(),
                             u.getSimpleName());
      }
    }
  }
}
origin: org.mockito/mockito-core

  private static void assertNoAnnotations(Field field, Class<? extends Annotation>... annotations) {
    for (Class<? extends Annotation> annotation : annotations) {
      if (field.isAnnotationPresent(annotation)) {
        throw unsupportedCombinationOfAnnotations(annotation.getSimpleName(), InjectMocks.class.getSimpleName());
      }
    }
  }
}
origin: Atmosphere/atmosphere

  @Override
  public void introspectField(Class clazz, Field f) {
    if (f.isAnnotationPresent(Named.class)) {
      String name = f.getAnnotation(Named.class).value();

      if (name.isEmpty()) {
        name = f.getName();
      }
      nameLocal.set(name);
    }
  }
}
origin: square/dagger

 public static StaticInjection create(Class<?> injectedClass) {
  List<Field> fields = new ArrayList<Field>();
  for (Field field : injectedClass.getDeclaredFields()) {
   if (Modifier.isStatic(field.getModifiers()) && field.isAnnotationPresent(Inject.class)) {
    field.setAccessible(true);
    fields.add(field);
   }
  }
  if (fields.isEmpty()) {
   throw new IllegalArgumentException("No static injections: " + injectedClass.getName());
  }
  return new ReflectiveStaticInjection(injectedClass.getClassLoader(),
    fields.toArray(new Field[fields.size()]));
 }
}
origin: Atmosphere/atmosphere

@Override
public void introspectField(Class clazz, Field f) {
  if (f.isAnnotationPresent(PathParam.class)) {
    String name = f.getAnnotation(PathParam.class).value();
    if (name.isEmpty()) {
      name = f.getName();
    }
    pathLocal.set(name);
  }
}
origin: google/j2objc

  void assertNoIncompatibleAnnotations(Class annotation, Field field, Class... undesiredAnnotations) {
    for (Class u : undesiredAnnotations) {
      if (field.isAnnotationPresent(u)) {
        new Reporter().unsupportedCombinationOfAnnotations(annotation.getSimpleName(), annotation.getClass().getSimpleName());
      }
    }        
  }    
}
origin: google/j2objc

  void assertNoAnnotations(final Field field, final Class... annotations) {
    for (Class annotation : annotations) {
      if (field.isAnnotationPresent(annotation)) {
        new Reporter().unsupportedCombinationOfAnnotations(annotation.getSimpleName(), InjectMocks.class.getSimpleName());
      }
    }
  }
}
origin: baomidou/mybatis-plus

private List<EntityField> getFieldsFromClazz(Class<?> parameterClass) {
  return ReflectionKit.getFieldList(parameterClass).stream().map(field -> {
    field.setAccessible(true);
    return field.isAnnotationPresent(Version.class) ? new EntityField(field, true) : new EntityField(field, false);
  }).collect(Collectors.toList());
}
origin: baomidou/mybatis-plus

/**
 * 反射检查参数类是否启动乐观锁
 *
 * @param parameterClass 实体类
 * @param tableInfo      实体数据库反射信息
 * @return ignore
 */
private EntityField getVersionFieldRegular(Class<?> parameterClass, TableInfo tableInfo) {
  return Object.class.equals(parameterClass) ? null : ReflectionKit.getFieldList(parameterClass).stream().filter(e -> e.isAnnotationPresent(Version.class)).map(field -> {
    field.setAccessible(true);
    return new EntityField(field, true, tableInfo.getFieldList().stream().filter(e -> field.getName().equals(e.getProperty())).map(TableFieldInfo::getColumn).findFirst().orElse(null));
  }).findFirst().orElseGet(() -> this.getVersionFieldRegular(parameterClass.getSuperclass(), tableInfo));
}
origin: gocd/gocd

private void walkFields(Object current, ConfigSaveValidationContext ctx, Handler handler) {
  for (Field field : getAllFields(current.getClass())) {
    field.setAccessible(true);
    try {
      Object o = field.get(current);
      if (o == null || isAConstantField(field) || field.isAnnotationPresent(IgnoreTraversal.class)) {
        continue;
      }
      walkSubtree(o, ctx, handler);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }
  }
}
origin: redisson/redisson

/**
 * WARNING: rEntity has to be the class of @This object.
 */
private Codec getFieldCodec(Class<?> rEntity, Class<? extends RObject> rObjectClass, String fieldName) throws Exception {
  Field field = ClassUtils.getDeclaredField(rEntity, fieldName);
  if (field.isAnnotationPresent(RObjectField.class)) {
    RObjectField anno = field.getAnnotation(RObjectField.class);
    return codecProvider.getCodec(anno, rEntity, rObjectClass, fieldName, config);
  } else {
    REntity anno = ClassUtils.getAnnotation(rEntity, REntity.class);
    return codecProvider.getCodec(anno, (Class<?>) rEntity, config);
  }
}

origin: redisson/redisson

/**
 * WARNING: rEntity has to be the class of @This object.
 */
private Codec getFieldCodec(Class<?> rEntity, Class<? extends RObject> rObjectClass, String fieldName) throws Exception {
  Field field = ClassUtils.getDeclaredField(rEntity, fieldName);
  if (field.isAnnotationPresent(RObjectField.class)) {
    RObjectField anno = field.getAnnotation(RObjectField.class);
    return codecProvider.getCodec(anno, rEntity, rObjectClass, fieldName, config);
  } else {
    REntity anno = ClassUtils.getAnnotation(rEntity, REntity.class);
    return codecProvider.getCodec(anno, (Class<?>) rEntity, config);
  }
}

origin: google/guava

@GwtIncompatible // reflection
public void testGetField() {
 Field foo = Enums.getField(AnEnum.FOO);
 assertEquals("FOO", foo.getName());
 assertTrue(foo.isAnnotationPresent(ExampleAnnotation.class));
 Field bar = Enums.getField(AnEnum.BAR);
 assertEquals("BAR", bar.getName());
 assertFalse(bar.isAnnotationPresent(ExampleAnnotation.class));
}
origin: neo4j/neo4j

@Override
public void postProcessTestInstance( Object testInstance, ExtensionContext context ) throws Exception
{
  Class<?> clazz = testInstance.getClass();
  Object instance = createInstance( context );
  List<Field> declaredFields = getAllFields( clazz );
  for ( Field declaredField : declaredFields )
  {
    if ( declaredField.isAnnotationPresent( Inject.class ) &&
        getFieldType().equals( declaredField.getType() ) )
    {
      declaredField.setAccessible( true );
      declaredField.set( testInstance, instance );
    }
  }
}
java.lang.reflectFieldisAnnotationPresent

Popular methods of Field

  • get
    Returns the value of the field in the specified object. This reproduces the effect of object.fieldNa
  • setAccessible
  • getName
  • set
    Sets the value of the field in the specified object to the value. This reproduces the effect of obje
  • getType
  • getModifiers
  • getAnnotation
  • getGenericType
    Returns the generic type of this field.
  • getDeclaringClass
  • isAccessible
  • getInt
  • setInt
  • getInt,
  • setInt,
  • getAnnotations,
  • isSynthetic,
  • setBoolean,
  • getLong,
  • getBoolean,
  • getDeclaredAnnotations,
  • toString

Popular in Java

  • Start an intent from android
  • setRequestProperty (URLConnection)
  • requestLocationUpdates (LocationManager)
  • startActivity (Activity)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Kernel (java.awt.image)
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • JPanel (javax.swing)

For IntelliJ IDEA,
Android Studio or Eclipse

  • Search for JavaScript code betaCodota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutBlogContact Us
  • Plugin user guideTerms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)