com.google.gwt.core.ext.typeinfo.JField.getAnnotation()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中com.google.gwt.core.ext.typeinfo.JField.getAnnotation()方法的一些代码示例,展示了JField.getAnnotation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JField.getAnnotation()方法的具体详情如下:
包路径:com.google.gwt.core.ext.typeinfo.JField
类名称:JField
方法名:getAnnotation

JField.getAnnotation介绍

暂无

代码示例

代码示例来源:origin: net.wetheinter/gwt-reflect

public GwtRetention getRetention(JField field) {
 GwtRetention retention = field.getAnnotation(GwtRetention.class);
 if (retention == null) {
  retention = strategy.fieldRetention();
 }
 return retention;
}

代码示例来源:origin: fr.putnami.pwt/pwt

private void appendPastValidator(SourceWriter w, JField field) {
  Past pastAnnotation = field.getAnnotation(Past.class);
  if (pastAnnotation != null) {
    w.println(", new PastValidator(\"%s\")", pastAnnotation.message());
  }
}

代码示例来源:origin: fr.putnami.pwt/pwt

private void appendNullValidator(SourceWriter w, JField field) {
  Null nullAnnotation = field.getAnnotation(Null.class);
  if (nullAnnotation != null) {
    w.println(", new NullValidator(\"%s\")", nullAnnotation.message());
  }
}

代码示例来源:origin: fr.putnami.pwt/pwt

private void appendTrueValidator(SourceWriter w, JField field) {
  AssertTrue trueAnnotation = field.getAnnotation(AssertTrue.class);
  if (trueAnnotation != null) {
    w.println(", new AssertTrueValidator(\"%s\")", trueAnnotation.message());
  }
}

代码示例来源:origin: fr.putnami.pwt/pwt

private void appendNotNullValidator(SourceWriter w, JField field) {
  NotNull notNullAnnotation = field.getAnnotation(NotNull.class);
  if (notNullAnnotation != null) {
    w.println(", new NotNullValidator(\"%s\")", notNullAnnotation.message());
  }
}

代码示例来源:origin: fr.putnami.pwt/pwt

private void appendFutureValidator(SourceWriter w, JField field) {
  Future futureAnnotation = field.getAnnotation(Future.class);
  if (futureAnnotation != null) {
    w.println(", new FutureValidator(\"%s\")", futureAnnotation.message());
  }
}

代码示例来源:origin: fr.putnami.pwt/pwt

private void appendFalseValidator(SourceWriter w, JField field) {
  AssertFalse falseAnnotation = field.getAnnotation(AssertFalse.class);
  if (falseAnnotation != null) {
    w.println(", new AssertFalseValidator(\"%s\")", falseAnnotation.message());
  }
}

代码示例来源: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: net.wetheinter/gwt-user

public static EditorAccess via(JField field) {
 String path = field.getName();
 Path pathAnnotation = field.getAnnotation(Editor.Path.class);
 if (pathAnnotation != null) {
  path = pathAnnotation.value();
 } else if (path.endsWith(EDITOR_SUFFIX)) {
  path = path.substring(0, path.length() - EDITOR_SUFFIX.length());
 }
 return new EditorAccess(path, field.getType().isClassOrInterface(),
   field.getName());
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

public static EditorAccess via(JField field) {
 String path = field.getName();
 Path pathAnnotation = field.getAnnotation(Editor.Path.class);
 if (pathAnnotation != null) {
  path = pathAnnotation.value();
 } else if (path.endsWith(EDITOR_SUFFIX)) {
  path = path.substring(0, path.length() - EDITOR_SUFFIX.length());
 }
 return new EditorAccess(path, field.getType().isClassOrInterface(),
   field.getName());
}

代码示例来源:origin: fr.putnami.pwt/pwt

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());
  }
}

代码示例来源:origin: fr.putnami.pwt/pwt

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());
  }
}

代码示例来源:origin: fr.putnami.pwt/pwt

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());
  }
}

代码示例来源:origin: net.wetheinter/gwt-user

public GwtRetention getRetention(final JField field) {
 GwtRetention retention = field.getAnnotation(GwtRetention.class);
 if (retention == null) {
  if (strategy.memberRetention().length == 0) {
   retention = strategy.fieldRetention();
  } else {
   retention = strategy.memberRetention()[0];
  }
 }
 return retention;
}

代码示例来源:origin: oVirt/ovirt-engine

void stubFieldIdAnnotation(JField field, String fieldId, boolean processType) {
  WithElementId idAnnotation = mock(WithElementId.class);
  when(field.getAnnotation(WithElementId.class)).thenReturn(idAnnotation);
  when(idAnnotation.value()).thenReturn(fieldId);
  when(idAnnotation.processType()).thenReturn(processType);
}

代码示例来源:origin: oVirt/ovirt-engine

@Test
public void processField_missingIdAnnotation() {
  when(field.getAnnotation(WithElementId.class)).thenReturn(null);
  verifyProcessFieldReturns(false);
}

代码示例来源:origin: fr.putnami.pwt/pwt

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());
  }
}

代码示例来源:origin: oVirt/ovirt-engine

boolean processField(JField field) {
  return !field.isPrivate() && !field.isStatic()
      && field.getType().isClass() != null
      && field.getAnnotation(WithElementId.class) != null;
}

代码示例来源:origin: oVirt/ovirt-engine

void stubPassingField(JField field, JClassType fieldType, String fieldName) {
  WithElementId idAnnotation = mock(WithElementId.class);
  when(field.isPrivate()).thenReturn(false);
  when(field.isStatic()).thenReturn(false);
  when(field.getType()).thenReturn(fieldType);
  when(field.getName()).thenReturn(fieldName);
  when(fieldType.isClass()).thenReturn(fieldType);
  when(field.getAnnotation(WithElementId.class)).thenReturn(idAnnotation);
  when(idAnnotation.value()).thenReturn(""); //$NON-NLS-1$
  when(idAnnotation.processType()).thenReturn(true);
}

相关文章