com.sun.codemodel.JType.isPrimitive()方法的使用及代码示例

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

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

JType.isPrimitive介绍

[英]Tell whether or not this is a built-in primitive type, such as int or void.
[中]说明这是否为内置基元类型,如int或void。

代码示例

代码示例来源:origin: joelittlejohn/jsonschema2pojo

private static JDefinedClass definedClassOrNullFromType(JType type)
{
  if (type == null || type.isPrimitive())
  {
    return null;
  }
  JClass fieldClass = type.boxify();
  JPackage jPackage = fieldClass._package();
  return jPackage._getClass(fieldClass.name());
}

代码示例来源:origin: joelittlejohn/jsonschema2pojo

if (defaultPresent && !field.type().isPrimitive() && node.isNull()) {
  field.init(JExpr._null());

代码示例来源:origin: joelittlejohn/jsonschema2pojo

if (superType.isPrimitive() || isFinal(superType)) {
  return superType;

代码示例来源:origin: joelittlejohn/jsonschema2pojo

if (fieldVar.type().isPrimitive()) {
  if ("long".equals(fieldVar.type().name())) {
    fieldHash = JExpr.cast(jclass.owner().INT, fieldRef.xor(fieldRef.shrz(JExpr.lit(32))));
  if (!fieldVar.type().elementType().isPrimitive()) {
    throw new UnsupportedOperationException("Only primitive arrays are supported");

代码示例来源:origin: joelittlejohn/jsonschema2pojo

JExpression fieldEquals;
if (fieldVar.type().isPrimitive()) {
  if ("double".equals(fieldVar.type().name())) {
    JClass doubleClass = jclass.owner().ref(Double.class);
  if (!fieldVar.type().elementType().isPrimitive()) {
    throw new UnsupportedOperationException("Only primitive arrays are supported");

代码示例来源:origin: joelittlejohn/jsonschema2pojo

body.add(sb.invoke("append").arg(JExpr.lit('=')));
if (fieldVar.type().isPrimitive()) {
  body.add(sb.invoke("append").arg(JExpr.refthis(fieldVar.name())));
} else if (fieldVar.type().isArray()) {
  if (!fieldVar.type().elementType().isPrimitive()) {
    throw new UnsupportedOperationException("Only primitive arrays are supported");

代码示例来源:origin: javaee/jaxb-v2

/**
 * Returns true if this is a referenced type.
 */
public final boolean isReference() {
  return !isPrimitive();
}

代码示例来源:origin: com.sun.codemodel/codemodel

/**
 * Returns true if this is a referenced type.
 */
public final boolean isReference() {
  return !isPrimitive();
}

代码示例来源:origin: org.jvnet.jaxbvalidation/jaxbvalidation-core

/**
 * Returns object type for the given type. This method will return wrapper classes for primitive types.
 *
 * @param type the type.
 * @return Object type for given type.
 */
public static JType objectType(final JType type) {
 return type.isPrimitive() ? ((JPrimitiveType) type).getWrapperClass() : type;
}

代码示例来源:origin: org.jvnet.hyperjaxb3/hyperjaxb3-ejb-plugin

public AbstractWrappingField(ClassOutlineImpl context, CPropertyInfo prop,
    CPropertyInfo core) {
  super(context, prop);
  this.core = core;
  if (!Customizations.isGenerated(prop)) {
    this.coreField = JExpr.refthis(core.getName(false));
  } else {
    this.coreField = null;
  }
  assert !exposedType.isPrimitive() && !implType.isPrimitive();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-xjc

private String printMethodFor(XSSimpleType owner) {
  if(printMethod!=null)   return printMethod;
  if(inMemoryType.unboxify().isPrimitive()) {
    String method = getConversionMethod("print",owner);
    if(method!=null)
      return method;
  }
  return "toString";
}

代码示例来源:origin: org.jvnet.jaxbcommons/jaxbcommons-core

public JClass getObjectType(ClassContext classContext, FieldItem fieldItem) {
 final FieldUse fieldUse = getFieldUse(classContext, fieldItem);
 return fieldUse.type.isPrimitive()
   ? ((JPrimitiveType) fieldUse.type).getWrapperClass()
   : (JClass) fieldUse.type;
}

代码示例来源:origin: org.jvnet.jaxb2_commons/jaxb2-fluent-api

/** Returns true if the given type is a primitive int; false otherwise. */
  private boolean isInt(JType type) 
  {
    JCodeModel codeModel = type.owner();
    return type.isPrimitive() 
      && codeModel.INT.equals(
        JType.parse(codeModel, type.name()));
  }
}

代码示例来源:origin: org.glassfish.metro/webservices-tools

protected JClass substituteParams(JTypeVar[] variables, List<JClass> bindings) {
  if( componentType.isPrimitive() )
    return this;
  
  JClass c = ((JClass)componentType).substituteParams(variables,bindings);
  if(c==componentType)
    return this;
  
  return new JArrayClass(owner(),c);
}

代码示例来源:origin: com.sun.codemodel/codemodel

protected JClass substituteParams(JTypeVar[] variables, List<JClass> bindings) {
  if( componentType.isPrimitive() )
    return this;
  
  JClass c = ((JClass)componentType).substituteParams(variables,bindings);
  if(c==componentType)
    return this;
  
  return new JArrayClass(owner(),c);
}

代码示例来源:origin: com.unquietcode.tools.jcodemodel/codemodel

protected JClass substituteParams(JTypeVar[] variables, List<JClass> bindings) {
  if( componentType.isPrimitive() )
    return this;
  
  JClass c = ((JClass)componentType).substituteParams(variables,bindings);
  if(c==componentType)
    return this;
  
  return new JArrayClass(owner(),c);
}

代码示例来源:origin: org.jsonschema2pojo/jsonschema2pojo-core

private static JDefinedClass definedClassOrNullFromType(JType type)
{
  if (type == null || type.isPrimitive())
  {
    return null;
  }
  JClass fieldClass = type.boxify();
  JPackage jPackage = fieldClass._package();
  return jPackage._getClass(fieldClass.name());
}

代码示例来源:origin: sun-jaxb/jaxb-xjc

private String parseMethodFor(XSSimpleType owner) {
  if(parseMethod!=null)   return parseMethod;
  if(inMemoryType.unboxify().isPrimitive()) {
    String method = getConversionMethod("parse", owner);
    if(method!=null) {
      // this cast is necessary for conversion between primitive Java types
      return '('+inMemoryType.unboxify().fullName()+')'+method;
    }
  }
  return "new";
}

代码示例来源:origin: org.andromda.thirdparty.jaxb2_commons/jaxb-xjc

private String parseMethodFor(XSSimpleType owner) {
  if(parseMethod!=null)   return parseMethod;
  if(inMemoryType.unboxify().isPrimitive()) {
    String method = getConversionMethod("parse", owner);
    if(method!=null) {
      // this cast is necessary for conversion between primitive Java types
      return '('+inMemoryType.unboxify().fullName()+')'+method;
    }
  }
  return "new";
}

代码示例来源:origin: sabomichal/immutable-xjc

private JMethod addWithIfNotNullMethod(JDefinedClass builderClass, FieldOutline field, JMethod unconditionalWithMethod) {
  if (field.getRawType().isPrimitive())
   return null;
  String fieldName = field.getPropertyInfo().getName(true);
  JMethod method = builderClass.method(JMod.PUBLIC, builderClass, "with" + fieldName + "IfNotNull");
  JVar param = generateMethodParameter(method, field);
  JBlock block = method.body();
  JConditional conditional = block._if(param.eq(JExpr._null()));
  conditional._then()._return(JExpr.direct("this"));
  conditional._else()._return(JExpr.invoke(unconditionalWithMethod).arg(param));
  return method;
}

相关文章