本文整理了Java中com.google.gwt.core.ext.typeinfo.JField.isAnnotationPresent()
方法的一些代码示例,展示了JField.isAnnotationPresent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JField.isAnnotationPresent()
方法的具体详情如下:
包路径:com.google.gwt.core.ext.typeinfo.JField
类名称:JField
方法名:isAnnotationPresent
暂无
代码示例来源:origin: hpehl/piriti
@Override
public boolean isNative()
{
return field.isAnnotationPresent(Native.class);
}
代码示例来源:origin: org.jboss.errai/errai-widgets
public String init(TypeOracle oracle, JField targetWidget, JType targetType, JField targetFieldType,
JField targetEntityField, String variable, List<JField> fields) {
StringBuilder builder = new StringBuilder(variable + ".setDefaultTitleValues(new String[] {");
Iterator<JField> iter = fields.iterator();
JField fld;
String fieldName;
while (iter.hasNext()) {
if ((fld = iter.next()).isAnnotationPresent(FriendlyName.class)) {
fieldName = fld.getAnnotation(FriendlyName.class).value();
}
else {
fieldName = fld.getName();
}
builder.append("\"").append(fieldName).append("\"");
if (iter.hasNext()) builder.append(", ");
}
return builder.append("});").toString();
}
}
代码示例来源:origin: hpehl/piriti
@Override
public Class<? extends InstanceCreator<?, ?>> getInstanceCreator()
{
Class<? extends InstanceCreator<?, ?>> instanceCreator = null;
if (field.isAnnotationPresent(CreateWith.class))
{
instanceCreator = field.getAnnotation(CreateWith.class).value();
}
return instanceCreator;
}
代码示例来源:origin: hpehl/piriti
@Override
public Class<? extends PropertyGetter<?, ?>> getGetter()
{
Class<? extends PropertyGetter<?, ?>> getter = null;
if (field.isAnnotationPresent(Getter.class))
{
getter = field.getAnnotation(Getter.class).value();
}
return getter;
}
代码示例来源:origin: hpehl/piriti
@Override
public Class<? extends Converter<?>> getConverter()
{
Class<? extends Converter<?>> converter = null;
if (field.isAnnotationPresent(Convert.class))
{
converter = field.getAnnotation(Convert.class).value();
}
return converter;
}
代码示例来源:origin: hpehl/piriti
@Override
public String getFormat()
{
String format = null;
if (field.isAnnotationPresent(Format.class))
{
format = field.getAnnotation(Format.class).value();
}
return format;
}
代码示例来源:origin: hpehl/piriti
@Override
public WhitespaceHandling getWhitespaceHandling()
{
WhitespaceHandling whitespaceHandling = REMOVE;
if (field.isAnnotationPresent(Whitespace.class))
{
whitespaceHandling = field.getAnnotation(Whitespace.class).value();
}
return whitespaceHandling;
}
代码示例来源:origin: hpehl/piriti
@Override
public Class<? extends PropertySetter<?, ?>> getSetter()
{
Class<? extends PropertySetter<?, ?>> setter = null;
if (field.isAnnotationPresent(Setter.class))
{
setter = field.getAnnotation(Setter.class).value();
}
return setter;
}
}
代码示例来源:origin: hpehl/piriti
@Override
public String getPath()
{
String path = null;
if (field.isAnnotationPresent(Id.class))
{
path = field.getAnnotation(Id.class).value();
}
else if (field.isAnnotationPresent(IdRef.class))
{
path = field.getAnnotation(IdRef.class).value();
}
else if (field.isAnnotationPresent(Path.class))
{
path = field.getAnnotation(Path.class).value();
}
return path;
}
代码示例来源:origin: hpehl/piriti
@Override
public int getOrder()
{
int order = TypeContext.nextOrder();
if (field.isAnnotationPresent(Order.class))
{
order = field.getAnnotation(Order.class).value();
}
return order;
}
代码示例来源:origin: hpehl/piriti
private boolean includeField(JField field, Set<Class<? extends Annotation>> mustHaveAnnotations)
{
if (mustHaveAnnotations.isEmpty())
{
return true;
}
for (Class<? extends Annotation> a : mustHaveAnnotations)
{
if (field.isAnnotationPresent(a))
{
return true;
}
}
logger.debug("Skipping field %s in %s as it is not annotated with any of %s", field.getName(), field
.getEnclosingType().getParameterizedQualifiedSourceName(), mustHaveAnnotations);
return false;
}
代码示例来源:origin: cromwellian/angulargwt
public static List<Injection> getInjectedFields(JClassType dType) {
List<Injection> injects = new ArrayList<Injection>();
for (JField f : dType.getFields()) {
if(f.isAnnotationPresent(NgInjected.class)) {
JClassType pType = f.getType().isClassOrInterface();
if (pType != null) {
NgInject pInject = pType.getAnnotation(NgInject.class);
if (pInject != null) {
injects.add(Injection.create(pType, f.getName(),pInject.name()));
}
}
}
}
return injects;
}
}
代码示例来源:origin: net.wetheinter/gwt-user
/**
* Scans the owner class to find all fields annotated with @UiField, and puts
* them in {@link #uiFields} and {@link #uiFieldTypes}.
*
* @param ownerType the type of the owner class
*/
private void findUiFields(JClassType ownerType)
throws UnableToCompleteException {
JField[] fields = ownerType.getFields();
for (JField field : fields) {
if (field.isAnnotationPresent(UiField.class)) {
JClassType ownerFieldType = field.getType().isClassOrInterface();
if (ownerFieldType == null) {
logger.die("Field type is not a class in field "
+ field.getName());
}
OwnerField ownerField = new OwnerField(field, logger, context);
String ownerFieldName = field.getName();
uiFields.put(ownerFieldName, ownerField);
uiFieldTypes.put(ownerFieldType, ownerField);
}
}
// Recurse to superclass
JClassType superclass = ownerType.getSuperclass();
if (superclass != null) {
findUiFields(superclass);
}
}
代码示例来源:origin: com.vaadin.external.gwt/gwt-user
/**
* Scans the owner class to find all fields annotated with @UiField, and puts
* them in {@link #uiFields} and {@link #uiFieldTypes}.
*
* @param ownerType the type of the owner class
*/
private void findUiFields(JClassType ownerType)
throws UnableToCompleteException {
JField[] fields = ownerType.getFields();
for (JField field : fields) {
if (field.isAnnotationPresent(UiField.class)) {
JClassType ownerFieldType = field.getType().isClassOrInterface();
if (ownerFieldType == null) {
logger.die("Field type is not a class in field "
+ field.getName());
}
OwnerField ownerField = new OwnerField(field, logger, context);
String ownerFieldName = field.getName();
uiFields.put(ownerFieldName, ownerField);
uiFieldTypes.put(ownerFieldType, ownerField);
}
}
// Recurse to superclass
JClassType superclass = ownerType.getSuperclass();
if (superclass != null) {
findUiFields(superclass);
}
}
代码示例来源:origin: hpehl/piriti
protected boolean skipField(JField field, Set<Class<? extends Annotation>> annotationsToSkip)
{
if (field.isTransient() || field.isStatic())
{
logger.debug("Skipping %s field %s in %s", field.isTransient() ? "transient" : "static", field.getName(),
field.getEnclosingType().getParameterizedQualifiedSourceName());
return true;
}
for (Class<? extends Annotation> a : annotationsToSkip)
{
if (field.isAnnotationPresent(a))
{
logger.debug("Skipping field %s in %s as it is annotated with @%s", field.getName(), field
.getEnclosingType().getParameterizedQualifiedSourceName(), a.getClass().getName());
return true;
}
}
return false;
}
代码示例来源:origin: org.jboss.errai/errai-widgets
if (currField.isAnnotationPresent(WidgetMapper.class) && widgetMapper.isAssignableFrom(currField.getType().isClassOrInterface())) {
WidgetMapper mf = currField.getAnnotation(WidgetMapper.class);
if (currField.isAnnotationPresent(EntityFields.class)) {
EntityFields ef = currField.getAnnotation(EntityFields.class);
for (String fieldName : ef.value()) {
else if (currField.isAnnotationPresent(EntityMapped.class)) {
EntityMapped entityMappedA = currField.getAnnotation(EntityMapped.class);
if (fld.isAnnotationPresent(MapField.class)) {
MapField mapFieldA = fld.getAnnotation(MapField.class);
toEntityField = "".equals(mapFieldA.value()) ? entityFieldName : mapFieldA.value();
else if (currField.isAnnotationPresent(AddAllTo.class)) {
String copyToField = currField.getAnnotation(AddAllTo.class).value();
String copyFromField = currField.getName();
代码示例来源:origin: net.wetheinter/gwt-user
private boolean isPropertyConstrained(PropertyDescriptor p, boolean useField) {
// cascaded counts as constrained
// we must know if the @Valid annotation is on a field or a getter
JClassType jClass = beanHelper.getJClass();
if (useField &&
jClass.findField(p.getPropertyName()).isAnnotationPresent(Valid.class)) {
return true;
} else if (!useField &&
jClass.findMethod(asGetter(p),NO_ARGS).isAnnotationPresent(Valid.class)) {
return true;
}
// for non-cascaded properties
for (ConstraintDescriptor<?> constraint : p.getConstraintDescriptors()) {
org.hibernate.validator.metadata.ConstraintDescriptorImpl<?> constraintHibernate =
(org.hibernate.validator.metadata.ConstraintDescriptorImpl<?>) constraint;
if (constraintHibernate.getElementType() ==
(useField ? ElementType.FIELD : ElementType.METHOD)) {
return true;
}
}
return false;
}
代码示例来源:origin: com.vaadin.external.gwt/gwt-user
private boolean isPropertyConstrained(PropertyDescriptor p, boolean useField) {
// cascaded counts as constrained
// we must know if the @Valid annotation is on a field or a getter
JClassType jClass = beanHelper.getJClass();
if (useField &&
jClass.findField(p.getPropertyName()).isAnnotationPresent(Valid.class)) {
return true;
} else if (!useField &&
jClass.findMethod(asGetter(p),NO_ARGS).isAnnotationPresent(Valid.class)) {
return true;
}
// for non-cascaded properties
for (ConstraintDescriptor<?> constraint : p.getConstraintDescriptors()) {
org.hibernate.validator.metadata.ConstraintDescriptorImpl<?> constraintHibernate =
(org.hibernate.validator.metadata.ConstraintDescriptorImpl<?>) constraint;
if (constraintHibernate.getElementType() ==
(useField ? ElementType.FIELD : ElementType.METHOD)) {
return true;
}
}
return false;
}
代码示例来源:origin: ManfredTremmel/gwt-bean-validators
private boolean isPropertyConstrained(final PropertyDescriptor ppropertyDescription,
final boolean useField) {
// cascaded counts as constrained
// we must know if the @Valid annotation is on a field or a getter
final JClassType jClass = beanHelper.getJClass();
if (useField && jClass.findField(ppropertyDescription.getPropertyName())
.isAnnotationPresent(Valid.class)) {
return true;
} else if (!useField && jClass.findMethod(asGetter(ppropertyDescription), NO_ARGS)
.isAnnotationPresent(Valid.class)) {
return true;
}
// for non-cascaded properties
for (final ConstraintDescriptor<?> constraint : ppropertyDescription
.getConstraintDescriptors()) {
final org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl<?> constraintHibernate =
(org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl<?>) constraint;
if (constraintHibernate
.getElementType() == (useField ? ElementType.FIELD : ElementType.METHOD)) {
return true;
}
}
return false;
}
内容来源于网络,如有侵权,请联系作者删除!