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

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

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

JType.unboxify介绍

[英]If this class is a wrapper type for a primitive, return the primitive type. Otherwise return this.

For example, for "java.lang.Integer", this method returns "int".
[中]如果此类是基元的包装类型,则返回基元类型。否则,请返回此。
例如,对于“java.lang.Integer”,此方法返回“int”。

代码示例

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

private JType unboxIfNecessary(JType type, GenerationConfig config) {
  if (config.isUsePrimitives()) {
    return type.unboxify();
  } else {
    return type;
  }
}

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

static JExpression getDefaultValue(JType fieldType, JsonNode node) {
  fieldType = fieldType.unboxify();

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

JType jtype = baseType.owner().ref(type);
if (ruleFactory.getGenerationConfig().isUsePrimitives()) {
  jtype = jtype.unboxify();

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

private JType unboxIfNecessary(JType type, GenerationConfig config) {
  if (config.isUsePrimitives()) {
    return type.unboxify();
  } else {
    return type;
  }
}

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

private JType unboxIfNecessary(JType type, GenerationConfig config) {
  if (config.isUsePrimitives()) {
    return type.unboxify();
  } else {
    return type;
  }
}

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

private JType unboxIfNecessary(JType type, GenerationConfig config) {
  if (config.isUsePrimitives()) {
    return type.unboxify();
  } else {
    return type;
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.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.glassfish.metro/webservices-tools

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: apache/servicemix-bundles

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: 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: org.andromda.thirdparty.jaxb2_commons/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.glassfish.metro/webservices-tools

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: sun-jaxb/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.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: apache/servicemix-bundles

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: com.googlecode.jsonschema2pojo/jsonschema2pojo-core

private JExpression getDefaultValue(JType fieldType, JsonNode node) {
  if (!fieldType.isPrimitive() && node.isNull()) {
    return JExpr._null();
  }
  fieldType = fieldType.unboxify();
  if (fieldType.fullName().equals(String.class.getName())) {
    return JExpr.lit(node.asText());
  } else if (fieldType.fullName().equals(int.class.getName())) {
    return JExpr.lit(Integer.parseInt(node.asText()));
  } else if (fieldType.fullName().equals(double.class.getName())) {
    return JExpr.lit(Double.parseDouble(node.asText()));
  } else if (fieldType.fullName().equals(boolean.class.getName())) {
    return JExpr.lit(Boolean.parseBoolean(node.asText()));
  } else if (fieldType.fullName().equals(Date.class.getName())) {
    long millisecs = parseDateToMillisecs(node.asText());
    JInvocation newDate = JExpr._new(fieldType.owner().ref(Date.class));
    newDate.arg(JExpr.lit(millisecs));
    return newDate;
  } else if (fieldType.fullName().equals(long.class.getName())) {
    return JExpr.lit(Long.parseLong(node.asText()));
  } else if (fieldType instanceof JDefinedClass && ((JDefinedClass) fieldType).getClassType().equals(ClassType.ENUM)) {
    return getDefaultEnum(fieldType, node);
  } else {
    return JExpr._null();
  }
}

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

public PropertyFieldAccessor(final FieldOutline fieldOutline, JExpression targetObject) {
 super();
 this.fieldOutline = fieldOutline;
 this.targetObject = targetObject;
 this.fieldAccessor = fieldOutline.create(targetObject);
 final String publicName = fieldOutline.getPropertyInfo().getName(true);
 final JDefinedClass theClass = fieldOutline.parent().implClass;
 final String getterName = "get" + publicName;
 final String setterName = "set" + publicName;
 this.getter = theClass.getMethod(getterName, ABSENT);
 //      fieldOutline.getRawType();
 final JType rawType = fieldOutline.getRawType();
 final JMethod boxifiedSetter = theClass
   .getMethod(setterName, new JType[]{ rawType.boxify() });
 final JMethod unboxifiedSetter = theClass.getMethod(setterName, new JType[]{ rawType
   .unboxify() });
 this.setter = boxifiedSetter != null ? boxifiedSetter : unboxifiedSetter;
 this.isSetter = theClass.getMethod("isSet" + publicName, ABSENT);
 this.unSetter = theClass.getMethod("unset" + publicName, ABSENT);
}

代码示例来源:origin: org.andromda.thirdparty.jaxb2_commons/tools

public PropertyFieldAccessor(final FieldOutline fieldOutline,
    JExpression targetObject) {
  super();
  this.fieldOutline = fieldOutline;
  this.targetObject = targetObject;
  this.fieldAccessor = fieldOutline.create(targetObject);
  final String publicName = fieldOutline.getPropertyInfo().getName(
      true);
  final JDefinedClass theClass = fieldOutline.parent().implClass;
  final String getterName = "get" + publicName;
  final String setterName = "set" + publicName;
  this.getter = theClass.getMethod(getterName, ABSENT);
  // fieldOutline.getRawType();
  final JType rawType = fieldOutline.getRawType();
  final JMethod boxifiedSetter = theClass.getMethod(setterName,
      new JType[] { rawType.boxify() });
  final JMethod unboxifiedSetter = theClass.getMethod(setterName,
      new JType[] { rawType.unboxify() });
  this.setter = boxifiedSetter != null ? boxifiedSetter
      : unboxifiedSetter;
  this.isSetter = theClass.getMethod("isSet" + publicName, ABSENT);
  this.unSetter = theClass.getMethod("unset" + publicName, ABSENT);
}

代码示例来源:origin: org.jvnet.jaxb2_commons/tools

public PropertyFieldAccessor(final FieldOutline fieldOutline,
    JExpression targetObject) {
  super();
  this.fieldOutline = fieldOutline;
  this.targetObject = targetObject;
  this.fieldAccessor = fieldOutline.create(targetObject);
  final String publicName = fieldOutline.getPropertyInfo().getName(
      true);
  final JDefinedClass theClass = fieldOutline.parent().implClass;
  final String getterName = "get" + publicName;
  final String setterName = "set" + publicName;
  this.getter = theClass.getMethod(getterName, ABSENT);
  // fieldOutline.getRawType();
  final JType rawType = fieldOutline.getRawType();
  final JMethod boxifiedSetter = theClass.getMethod(setterName,
      new JType[] { rawType.boxify() });
  final JMethod unboxifiedSetter = theClass.getMethod(setterName,
      new JType[] { rawType.unboxify() });
  this.setter = boxifiedSetter != null ? boxifiedSetter
      : unboxifiedSetter;
  this.isSetter = theClass.getMethod("isSet" + publicName, ABSENT);
  this.unSetter = theClass.getMethod("unset" + publicName, ABSENT);
}

相关文章