Example usage for java.lang Class getAnnotation

List of usage examples for java.lang Class getAnnotation

Introduction

In this page you can find the example usage for java.lang Class getAnnotation.

Prototype

@SuppressWarnings("unchecked")
public <A extends Annotation> A getAnnotation(Class<A> annotationClass) 

Source Link

Usage

From source file:egov.data.hibernate.repository.support.HibernateEntityInformationSupport.java

public String getEntityName() {
    Class<?> domainClass = getJavaType();
    Entity entity = domainClass.getAnnotation(Entity.class);
    boolean hasName = null != entity && StringUtils.hasText(entity.name());

    return hasName ? entity.name() : domainClass.getSimpleName();
}

From source file:com.orchestra.portale.persistence.mongo.documents.AbstractPoiComponent.java

/**
 * Return the slug of the component, identified by the tag @TypeALias.
 * @return Component's slug, or null if @TypeAlias was not defined. 
 *//*from  w  ww .  j ava  2 s.c  o  m*/
public String slug() {
    String res;

    Class<? extends AbstractPoiComponent> c = this.getClass();
    TypeAlias a = c.getAnnotation(TypeAlias.class);
    res = (a != null) ? a.value() : null;

    return res;
}

From source file:com.consol.citrus.admin.service.spring.filter.GetSpringBeansFilter.java

/**
 * Constructor using bean definition type as field.
 *///w ww.jav a 2  s . c  o m
public GetSpringBeansFilter(Class<?> type) {
    this.elementName = type.getAnnotation(XmlRootElement.class).name();
    this.elementNamespace = type.getPackage().getAnnotation(XmlSchema.class).namespace();
}

From source file:core.commonapp.server.service.CommonAppServiceInstantiator.java

@Override
public Object instantiateService(Class serviceInterface) {
    InformationBean service = (InformationBean) serviceInterface.getAnnotation(InformationBean.class);
    if (service == null) {
        throw new IllegalArgumentException("No bean found  for interface " + serviceInterface.getName());
    }/*from  w  w  w. ja  va  2 s  .  c  o  m*/
    return getInformationContext().getBean(service.beanName());
}

From source file:org.apache.usergrid.chop.runner.drivers.TimeTracker.java

public TimeTracker(Class<?> testClass) {
    super(testClass);
    this.timeChop = testClass.getAnnotation(TimeChop.class);
}

From source file:org.jsonschema2pojo.integration.PolymorphicIT.java

@Test
public void extendsWithPolymorphicDeserialization() throws ClassNotFoundException {

    ClassLoader resultsClassLoader = schemaRule.generateAndCompile("/schema/polymorphic/extendsSchema.json",
            "com.example");

    Class<?> subtype = resultsClassLoader.loadClass("com.example.ExtendsSchema");
    Class<?> supertype = subtype.getSuperclass();

    assertNotNull(supertype.getAnnotation(JsonTypeInfo.class));

}

From source file:com.jim.im.offline.repo.OfflineMessageRepo.java

@PostConstruct
public void init() {
    Class<ImMessage> messageClass = ImMessage.class;
    Document annotation = messageClass.getAnnotation(Document.class);
    collectionName = annotation == null ? messageClass.getSimpleName() : annotation.collection();
    messageCollection = messageDb.getCollection(collectionName);
}

From source file:cz.datalite.dao.support.JpaEntityInformationSupport.java

public String getEntityName() {

    Class<?> domainClass = getJavaType();
    Entity entity = domainClass.getAnnotation(Entity.class);
    boolean hasName = !StringHelper.isNull(entity.name());

    return hasName ? entity.name() : domainClass.getSimpleName();
}

From source file:capital.scalable.restdocs.constraints.MethodParameterValidatorConstraintResolver.java

@Override
public List<Constraint> resolveForParameter(MethodParameter param) {
    List<Constraint> constraints = new ArrayList<>();
    for (Annotation annot : param.getParameterAnnotations()) {
        Class<? extends Annotation> type = annot.annotationType();
        if (type.getAnnotation(javax.validation.Constraint.class) != null) {
            Constraint constraint = createConstraint(annot, type);
            constraints.add(constraint);
        }//from w  w w  . j a  va  2  s.c o m
    }
    return constraints;
}

From source file:org.apache.usergrid.chop.runner.drivers.IterationTracker.java

public IterationTracker(final Class<?> testClass) {
    super(testClass);
    this.iterationChop = testClass.getAnnotation(IterationChop.class);
}