当前位置: 首页>>代码示例>>Java>>正文


Java JField.getAnnotation方法代码示例

本文整理汇总了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;
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:17,代码来源:GwtSpecificValidatorCreator.java

示例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");
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:17,代码来源:InitializeFormCreator.java

示例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;
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:18,代码来源:InjectCreatorUtil.java

示例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;
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:37,代码来源:GenUtils.java

示例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());
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:8,代码来源:ModelCreator.java

示例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());
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:8,代码来源:ModelCreator.java

示例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);
}
 
开发者ID:kyoken74,项目名称:gwt-angular,代码行数:50,代码来源:AbstractFactoryGenerator.java

示例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());
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:7,代码来源:ModelCreator.java

示例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());
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:7,代码来源:ModelCreator.java

示例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());
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:7,代码来源:ModelCreator.java

示例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());
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:7,代码来源:ModelCreator.java

示例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());
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:7,代码来源:ModelCreator.java

示例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());
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:7,代码来源:ModelCreator.java

示例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());
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:7,代码来源:ModelCreator.java

示例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());
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:7,代码来源:ModelCreator.java


注:本文中的com.google.gwt.core.ext.typeinfo.JField.getAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。