use of java.lang.annotation.ElementType in project querydsl by querydsl.
the class ScalaWriterTest method Annotation_With_ArrayMethod.
@Test
public void Annotation_With_ArrayMethod() throws IOException {
Target annotation = new Target() {
@Override
public ElementType[] value() {
return new ElementType[] { ElementType.FIELD, ElementType.METHOD };
}
@Override
public Class<? extends Annotation> annotationType() {
return Target.class;
}
};
writer.imports(Target.class.getPackage());
writer.annotation(annotation);
assertTrue(w.toString().contains("@Target(Array(FIELD, METHOD))"));
}
use of java.lang.annotation.ElementType in project querydsl by querydsl.
the class JavaWriterTest method Annotation_With_ArrayMethod.
@Test
public void Annotation_With_ArrayMethod() throws IOException {
Target annotation = new Target() {
@Override
public ElementType[] value() {
return new ElementType[] { ElementType.FIELD, ElementType.METHOD };
}
@Override
public Class<? extends Annotation> annotationType() {
return Target.class;
}
};
writer.imports(Target.class.getPackage());
writer.annotation(annotation);
assertTrue(w.toString().contains("@Target({FIELD, METHOD})"));
}
use of java.lang.annotation.ElementType in project groovy-core by groovy.
the class Java5 method configureAnnotationFromDefinition.
public static void configureAnnotationFromDefinition(AnnotationNode definition, AnnotationNode root) {
ClassNode type = definition.getClassNode();
if ("java.lang.annotation.Retention".equals(type.getName())) {
Expression exp = definition.getMember("value");
if (!(exp instanceof PropertyExpression))
return;
PropertyExpression pe = (PropertyExpression) exp;
String name = pe.getPropertyAsString();
RetentionPolicy policy = RetentionPolicy.valueOf(name);
setRetentionPolicy(policy, root);
} else if ("java.lang.annotation.Target".equals(type.getName())) {
Expression exp = definition.getMember("value");
if (!(exp instanceof ListExpression))
return;
ListExpression le = (ListExpression) exp;
int bitmap = 0;
for (Expression e : le.getExpressions()) {
if (!(e instanceof PropertyExpression))
return;
PropertyExpression element = (PropertyExpression) e;
String name = element.getPropertyAsString();
ElementType value = ElementType.valueOf(name);
bitmap |= getElementCode(value);
}
root.setAllowedTargets(bitmap);
}
}
use of java.lang.annotation.ElementType in project dolphin-platform by canoo.
the class ActionTestControllerTest method callPublicMethodWithElementTypeParam.
/**
* End UUID Type Related Action Test
*/
/**
* Start ElementType Type Related Action Test
*/
@Test
public void callPublicMethodWithElementTypeParam() {
Assert.assertNull(controller.getModel().getEnumValue());
final ElementType value = ElementType.FIELD;
controller.invoke(PUBLIC_WITH_ELEMENT_TYPE_PARAM_ACTION, new Param(PARAM_NAME, value));
Assert.assertEquals(controller.getModel().getEnumValue(), value);
}
use of java.lang.annotation.ElementType in project dolphin-platform by canoo.
the class ActionControllerTest method testCallPrivateMethodWithElementTypeParams.
@Test(dataProvider = ENDPOINTS_DATAPROVIDER, description = "Tests if an private action method with ElementType param can be called")
public void testCallPrivateMethodWithElementTypeParams(String containerType, String endpoint) {
final ElementType value = ElementType.METHOD;
performActionForElementType(containerType, endpoint, PRIVATE_WITH_ELEMENT_TYPE_PARAM_ACTION, value, new Param(PARAM_NAME, value));
}
Aggregations