本文整理汇总了Java中com.google.gwt.core.ext.typeinfo.JField.getAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java JField.getAnnotation方法的具体用法?Java JField.getAnnotation怎么用?Java JField.getAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.core.ext.typeinfo.JField
的用法示例。
在下文中一共展示了JField.getAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAnnotation
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
private Annotation getAnnotation(final PropertyDescriptor ppropertyDescription,
final boolean useField, final Class<? extends Annotation> expectedAnnotationClass) {
Annotation annotation = null;
if (useField) {
final JField field = this.beanType.findField(ppropertyDescription.getPropertyName());
if (field.getEnclosingType().equals(this.beanType)) {
annotation = field.getAnnotation(expectedAnnotationClass);
}
} else {
final JMethod method = this.beanType.findMethod(asGetter(ppropertyDescription), NO_ARGS);
if (method.getEnclosingType().equals(this.beanType)) {
annotation = method.getAnnotation(expectedAnnotationClass);
}
}
return annotation;
}
示例2: InitializeFormCreator
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
public InitializeFormCreator(JField modelField) {
this.modelField = modelField;
this.fieldType = modelField.getType();
Initialize initializeAnnotation = modelField.getAnnotation(Initialize.class);
this.constantClassName = initializeAnnotation.constantsClass();
if (ConstantsWithLookup.class.equals(this.constantClassName)) {
this.constantClassName = null;
}
if (this.fieldType instanceof JParameterizedType) {
JParameterizedType paramType = (JParameterizedType) this.fieldType;
this.beanType = paramType.getTypeArgs()[0];
} else {
throw new RuntimeException("modelField can not be injected as Model");
}
}
示例3: listFields
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
public static Collection<JField> listFields(JClassType type, Class<? extends Annotation> annotationClass) {
Collection<JField> methodAnnoted = Lists.newArrayList();
JField[] fields = type.getFields();
for (JField field : fields) {
Annotation annotation = field.getAnnotation(annotationClass);
if (annotation != null) {
methodAnnoted.add(field);
}
}
// Recurse to superclass
JClassType superclass = type.getSuperclass();
if (superclass != null) {
methodAnnoted.addAll(InjectCreatorUtil.listFields(superclass, annotationClass));
}
return methodAnnoted;
}
示例4: getAllAnnotations
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
/**
* Get All annotations from classType
* NOTE: This is ordered by ParentClass to DevidedClass
* The parentclass's annotation comes first
* @param <T>
* @param classType
* @param annotationClass
* @return
*/
public static <T extends Annotation> Map<Object, T> getAllAnnotations(JClassType classType, Class<T> annotationClass){
Map<Object, T> results = new HashMap<Object, T>();
JClassType parent = classType.getSuperclass();
if (parent != null){
results.putAll(getAllAnnotations(parent, annotationClass));
}
T a = classType.getAnnotation(annotationClass);
if (a != null){
results.put(classType, a);
}
for (JField field : classType.getFields()){
a = field.getAnnotation(annotationClass);
if (a != null)
results.put(field, a);
}
for (JMethod method : classType.getMethods()){
a = method.getAnnotation(annotationClass);
if (a != null)
results.put(method, a);
}
return results;
}
示例5: appendSizeValidator
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
private void appendSizeValidator(SourceWriter w, JField field) {
Size sizeAnnotation = field.getAnnotation(Size.class);
if (sizeAnnotation != null) {
w.println(", new SizeValidator(\"%s\", %s, %s)", sizeAnnotation.message(), sizeAnnotation.min(),
sizeAnnotation.max());
}
}
示例6: appendPatternValidator
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
private void appendPatternValidator(SourceWriter w, JField field) {
Pattern patternAnnotation = field.getAnnotation(Pattern.class);
if (patternAnnotation != null) {
w.println(", new PatternValidator(\"%s\", \"%s\")", patternAnnotation.message(), patternAnnotation.regexp()
.replace("\\", "\\\\"), patternAnnotation.flags());
}
}
示例7: generate
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
@Override
public String generate(TreeLogger logger, GeneratorContext context, String qualifiedClassName) throws UnableToCompleteException {
JClassType classType = getClassType(context, qualifiedClassName);
String packageName = classType.getPackage().getName();
String className = classType.getSimpleSourceName();
JClassType supportedRootClassType = getSupportedRootClassType(context, classType);
List<JClassType> supportedClassTypes = getSupportedClassTypes(supportedRootClassType);
VelocityGenerator velocity = new VelocityGenerator(getFilename());
velocity.put("classType", classType);
velocity.put("packageName", packageName);
velocity.put("className", className);
velocity.put("supportedRootClassType", supportedRootClassType.getQualifiedSourceName());
velocity.put("supportedClassTypes", supportedClassTypes);
velocity.put("JMethodUtils", JMethodUtils.class);
ClassTypeFields classTypeFields = new ClassTypeFields();
for (JClassType supportedClassType : supportedClassTypes) {
List<Field> fieldList = new ArrayList<Field>();
for (JClassType supportedSuperClassType : supportedClassType.getFlattenedSupertypeHierarchy()) {
JField[] fields = supportedSuperClassType.getFields();
if (fields == null) {
continue;
}
for (JField field : fields) {
String cname = supportedSuperClassType.getQualifiedSourceName();
String dependency = null;
Injector.Inject inject = field.getAnnotation(Injector.Inject.class);
if (inject != null) {
dependency = inject.value();
if (dependency == null || dependency.length() == 0) {
Injector.Bind bind = field.getType().isClass().getAnnotation(Injector.Bind.class);
dependency = bind == null ? null : bind.value();
if (dependency == null || dependency.length() == 0) {
dependency = field.getType().getQualifiedSourceName();
}
}
}
String name = field.getName();
fieldList.add(new Field(field, cname, dependency, name));
}
}
classTypeFields.put(supportedClassType, fieldList);
}
velocity.put("classTypeFields", classTypeFields);
return generate(logger, context, velocity, packageName, className);
}
示例8: appendPastValidator
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
private void appendPastValidator(SourceWriter w, JField field) {
Past pastAnnotation = field.getAnnotation(Past.class);
if (pastAnnotation != null) {
w.println(", new PastValidator(\"%s\")", pastAnnotation.message());
}
}
示例9: appendNullValidator
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
private void appendNullValidator(SourceWriter w, JField field) {
Null nullAnnotation = field.getAnnotation(Null.class);
if (nullAnnotation != null) {
w.println(", new NullValidator(\"%s\")", nullAnnotation.message());
}
}
示例10: appendNotNullValidator
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
private void appendNotNullValidator(SourceWriter w, JField field) {
NotNull notNullAnnotation = field.getAnnotation(NotNull.class);
if (notNullAnnotation != null) {
w.println(", new NotNullValidator(\"%s\")", notNullAnnotation.message());
}
}
示例11: appendMinValidator
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
private void appendMinValidator(SourceWriter w, JField field) {
Min minAnnotation = field.getAnnotation(Min.class);
if (minAnnotation != null) {
w.println(", new MinValidator(\"%s\", %s)", minAnnotation.message(), minAnnotation.value());
}
}
示例12: appendMaxValidator
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
private void appendMaxValidator(SourceWriter w, JField field) {
Max maxAnnotation = field.getAnnotation(Max.class);
if (maxAnnotation != null) {
w.println(", new MaxValidator(\"%s\", %s)", maxAnnotation.message(), maxAnnotation.value());
}
}
示例13: appendFutureValidator
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
private void appendFutureValidator(SourceWriter w, JField field) {
Future futureAnnotation = field.getAnnotation(Future.class);
if (futureAnnotation != null) {
w.println(", new FutureValidator(\"%s\")", futureAnnotation.message());
}
}
示例14: appendFalseValidator
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
private void appendFalseValidator(SourceWriter w, JField field) {
AssertFalse falseAnnotation = field.getAnnotation(AssertFalse.class);
if (falseAnnotation != null) {
w.println(", new AssertFalseValidator(\"%s\")", falseAnnotation.message());
}
}
示例15: appendTrueValidator
import com.google.gwt.core.ext.typeinfo.JField; //导入方法依赖的package包/类
private void appendTrueValidator(SourceWriter w, JField field) {
AssertTrue trueAnnotation = field.getAnnotation(AssertTrue.class);
if (trueAnnotation != null) {
w.println(", new AssertTrueValidator(\"%s\")", trueAnnotation.message());
}
}