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

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

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

JType.isEnum介绍

暂无

代码示例

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Returns a parser for the given type(s). Accepts multiple types args to
 * allow requesting parsers for things like for pairs of ints.
 */
public AttributeParser getParser(JType... types) {
 if (types.length == 0) {
  throw new RuntimeException("Asked for attribute parser of no type");
 }
 AttributeParser rtn = getForKey(getParametersKey(types));
 if (rtn != null || types.length > 1) {
  return rtn;
 }
 /* Maybe it's an enum */
 JEnumType enumType = types[0].isEnum();
 if (enumType != null) {
  return new EnumAttributeParser(converter, enumType, logger);
 }
 /*
  * Dunno what it is, so let a StrictAttributeParser look for a
  * {field.reference}
  */
 return new StrictAttributeParser(converter, logger, types[0]);
}

代码示例来源:origin: nmorel/gwt-jackson

/**
 * <p>isEnum</p>
 *
 * @param type a {@link com.google.gwt.core.ext.typeinfo.JType} object.
 * @return a boolean.
 */
public boolean isEnum( JType type ) {
  return null != type.isEnum();
}

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

/**
 * Call {@link #processEnumType(JEnumType)} if {@code type} is a
 * {@link JEnumType}.
 */
private void maybeProcessEnumType(JType type) {
 assert type != null : "type == null";
 JEnumType enumType = type.isEnum();
 if (enumType != null) {
  processEnumType(enumType);
 }
}

代码示例来源:origin: errai/errai

@Override
public boolean isEnum() {
 return getEnclosedMetaObject().isEnum() != null;
}

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

/**
 * Call {@link #processEnumType(JEnumType)} if {@code type} is a
 * {@link JEnumType}.
 */
private void maybeProcessEnumType(JType type) {
 assert type != null : "type == null";
 JEnumType enumType = type.isEnum();
 if (enumType != null) {
  processEnumType(enumType);
 }
}

代码示例来源:origin: thothbot/parallax

/**
 * Call {@link #processEnumType(JEnumType)} if {@code type} is a
 * {@link JEnumType}.
 */
private void maybeProcessEnumType(JType type) {
 assert type != null : "type == null";
 JEnumType enumType = type.isEnum();
 if (enumType != null) {
  processEnumType(enumType);
 }
}

代码示例来源:origin: org.jboss.errai/errai-codegen-gwt

@Override
public boolean isEnum() {
 return getEnclosedMetaObject().isEnum() != null;
}

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

public static boolean isValueType(TypeOracle oracle, JType type) {
 JClassType classType = type.isClassOrInterface();
 if (classType == null) {
  return true;
 }
 if (type.isEnum() != null) {
  return true;
 }
 for (String valueType : VALUE_TYPE_NAMES) {
  JClassType found = oracle.findType(valueType);
  // null check to accommodate limited mock CompilationStates
  if (found != null && found.equals(classType)) {
   return true;
  }
 }
 return false;
}

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

public static boolean isValueType(TypeOracle oracle, JType type) {
 JClassType classType = type.isClassOrInterface();
 if (classType == null) {
  return true;
 }
 if (type.isEnum() != null) {
  return true;
 }
 for (String valueType : VALUE_TYPE_NAMES) {
  JClassType found = oracle.findType(valueType);
  // null check to accommodate limited mock CompilationStates
  if (found != null && found.equals(classType)) {
   return true;
  }
 }
 return false;
}

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

private void createSubModels(TreeLogger logger, GeneratorContext context) {
  for (JType jType : this.imports) {
    if (jType == null) {
      continue;
    }
    if (jType.isEnum() != null) {
      continue;
    }
    if (ModelCreator.DISCARD_MODEL_TYPES.contains(jType.getQualifiedSourceName())) {
      continue;
    }
    if (jType instanceof JClassType) {
      ModelCreator creator = new ModelCreator((JClassType) jType);
      String subModelType = creator.create(logger, context);
      this.subModels.put(jType, subModelType);
    }
  }
}

代码示例来源:origin: Putnami/putnami-web-toolkit

private void createSubModels(TreeLogger logger, GeneratorContext context) {
  for (JType jType : this.imports) {
    if (jType == null) {
      continue;
    }
    if (jType.isEnum() != null) {
      continue;
    }
    if (ModelCreator.DISCARD_MODEL_TYPES.contains(jType.getQualifiedSourceName())) {
      continue;
    }
    if (jType instanceof JClassType) {
      ModelCreator creator = new ModelCreator((JClassType) jType);
      String subModelType = creator.create(logger, context);
      this.subModels.put(jType, subModelType);
    }
  }
}

代码示例来源:origin: errai/errai

private List<MetaMethod> getSpecialTypeMethods() {
 final List<MetaMethod> meths = new ArrayList<>();
 final JEnumType type = getEnclosedMetaObject().isEnum();
 if (type != null) {
  meths.add(new GWTSpecialMethod(this, DefModifiers.none(), Scope.Public, String.class, "name"));
  meths.add(new GWTSpecialMethod(this, DefModifiers.none(), Scope.Public, Enum.class, "valueOf", Parameter.of(
    String.class, "p").getMetaParameter()));
  meths.add(new GWTSpecialMethod(this, DefModifiers.none(), Scope.Public, Enum[].class, "values"));
 }
 return meths;
}

代码示例来源:origin: org.jboss.errai/errai-codegen-gwt

private List<MetaMethod> getSpecialTypeMethods() {
 final List<MetaMethod> meths = new ArrayList<>();
 final JEnumType type = getEnclosedMetaObject().isEnum();
 if (type != null) {
  meths.add(new GWTSpecialMethod(this, DefModifiers.none(), Scope.Public, String.class, "name"));
  meths.add(new GWTSpecialMethod(this, DefModifiers.none(), Scope.Public, Enum.class, "valueOf", Parameter.of(
    String.class, "p").getMetaParameter()));
  meths.add(new GWTSpecialMethod(this, DefModifiers.none(), Scope.Public, Enum[].class, "values"));
 }
 return meths;
}

代码示例来源:origin: sk.seges.acris/acris-binding

private boolean isNotBean(JType type) {
  JClassType collection = typeOracle.findType(Collection.class.getCanonicalName());
  JClassType map = typeOracle.findType(Map.class.getCanonicalName());
  JClassType number = typeOracle.findType(Number.class.getCanonicalName());
  boolean isCollection = false, isMap = false, isNumber = false;
  if (type instanceof JClassType) {
    isCollection = ((JClassType) type).isAssignableTo(collection);
    isMap = ((JClassType) type).isAssignableTo(map);
    isNumber = ((JClassType) type).isAssignableTo(number);
  }
  return type.isPrimitive() != null || type.isEnum() != null || type.isArray() != null || isCollection || isNumber || isMap
      || type.getSimpleSourceName().equals("String") || type.getSimpleSourceName().equals("Byte") || type.getSimpleSourceName().equals("Short")
      || type.getSimpleSourceName().equals("Integer") || type.getSimpleSourceName().equals("Long") || type.getSimpleSourceName().equals("Boolean")
      || type.getSimpleSourceName().equals("Float") || type.getSimpleSourceName().equals("Double") || type.getSimpleSourceName().equals("Number")
      || type.getSimpleSourceName().equals("Character") || type.getSimpleSourceName().equals("Date")
      || type.getSimpleSourceName().equals("Timestamp");
}

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

/**
 * Returns a parser for the given type(s). Accepts multiple types args to
 * allow requesting parsers for things like for pairs of ints.
 */
public AttributeParser getParser(JType... types) {
 if (types.length == 0) {
  throw new RuntimeException("Asked for attribute parser of no type");
 }
 AttributeParser rtn = getForKey(getParametersKey(types));
 if (rtn != null || types.length > 1) {
  return rtn;
 }
 /* Maybe it's an enum */
 JEnumType enumType = types[0].isEnum();
 if (enumType != null) {
  return new EnumAttributeParser(converter, enumType, logger);
 }
 /*
  * Dunno what it is, so let a StrictAttributeParser look for a
  * {field.reference}
  */
 return new StrictAttributeParser(converter, logger, types[0]);
}

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

/**
 * Returns a parser for the given type(s). Accepts multiple types args to
 * allow requesting parsers for things like for pairs of ints.
 */
public AttributeParser getParser(JType... types) {
 if (types.length == 0) {
  throw new RuntimeException("Asked for attribute parser of no type");
 }
 AttributeParser rtn = getForKey(getParametersKey(types));
 if (rtn != null || types.length > 1) {
  return rtn;
 }
 /* Maybe it's an enum */
 JEnumType enumType = types[0].isEnum();
 if (enumType != null) {
  return new EnumAttributeParser(converter, enumType, logger);
 }
 /*
  * Dunno what it is, so let a StrictAttributeParser look for a
  * {field.reference}
  */
 return new StrictAttributeParser(converter, logger, types[0]);
}

代码示例来源:origin: hpehl/piriti

public static boolean canContainId(JType type)
{
  if (type != null)
  {
    return !(isBoolean(type) || isNumeric(type) || isCharacter(type) || isString(type) || type.isEnum() != null
        || isDate(type) || type.isArray() != null || isCollection(type) || isJavaType(type) || isGwtType(type));
  }
  return false;
}

代码示例来源:origin: org.fusesource.restygwt/restygwt

protected String toFormStringExpression(JParameter argument, Style classStyle) throws UnableToCompleteException {
  JType type = argument.getType();
  String expr = argument.getName();
  if (type.isPrimitive() != null) {
    return "\"\"+" + expr;
  }
  if (STRING_TYPE == type) {
    return expr;
  }
  if (type.isClass() != null && isOverlayArrayType(type.isClass())) {
    return "(new " + JSON_ARRAY_CLASS + "(" + expr + ")).toString()";
  }
  if (type.isClass() != null && OVERLAY_VALUE_TYPE.isAssignableFrom(type.isClass())) {
    return "(new " + JSON_OBJECT_CLASS + "(" + expr + ")).toString()";
  }
  if ((!isThrowable(type) && type.getQualifiedBinaryName().startsWith("java.lang.")) || type.isEnum() != null) {
    return String.format("(%s != null ? %s.toString() : null)", expr, expr);
  }
  Json jsonAnnotation = getAnnotation(argument, Json.class);
  Style style = jsonAnnotation != null ? jsonAnnotation.style() : classStyle;
  return locator.encodeExpression(type, expr, style) + ".toString()";
}

代码示例来源:origin: resty-gwt/resty-gwt

protected String toFormStringExpression(JParameter argument, Style classStyle) throws UnableToCompleteException {
  JType type = argument.getType();
  String expr = argument.getName();
  if (type.isPrimitive() != null) {
    return "\"\"+" + expr;
  }
  if (STRING_TYPE == type) {
    return expr;
  }
  if (type.isClass() != null && isOverlayArrayType(type.isClass())) {
    return "(new " + JSON_ARRAY_CLASS + "(" + expr + ")).toString()";
  }
  if (type.isClass() != null && OVERLAY_VALUE_TYPE.isAssignableFrom(type.isClass())) {
    return "(new " + JSON_OBJECT_CLASS + "(" + expr + ")).toString()";
  }
  if ((!isThrowable(type) && type.getQualifiedBinaryName().startsWith("java.lang.")) || type.isEnum() != null) {
    return String.format("(%s != null ? %s.toString() : null)", expr, expr);
  }
  Json jsonAnnotation = getAnnotation(argument, Json.class);
  Style style = jsonAnnotation != null ? jsonAnnotation.style() : classStyle;
  return locator.encodeExpression(type, expr, style) + ".toString()";
}

代码示例来源:origin: errai/errai

public static MetaType fromType(final TypeOracle oracle, final JType t) {
 if (t.isTypeParameter() != null) {
  return new GWTTypeVariable(oracle, t.isTypeParameter());
 }
 else if (t.isArray() != null
   && (t.isArray().getComponentType().isTypeParameter() != null
   || t.isArray().getComponentType().isWildcard() != null)) {
  return new GWTGenericArrayType(oracle, t.isArray());
 }
 else if (t.isParameterized() != null) {
  return new GWTParameterizedType(oracle, t.isParameterized());
 }
 else if (t.isWildcard() != null) {
  return new GWTWildcardType(oracle, t.isWildcard());
 }
 else if (t.isClassOrInterface() != null
   || t.isEnum() != null
   || t.isPrimitive() != null
   || t.isRawType() != null
   || t.isArray() != null) {
  return GWTClass.newInstance(oracle, t);
 }
 else {
  throw new RuntimeException("Don't know how to make a MetaType from given JType " + t +
    " (which is a " + (t.getClass()) + ")");
 }
}

相关文章