private JType unboxIfNecessary(JType type, GenerationConfig config) { if (config.isUsePrimitives()) { return type.unboxify(); } else { return type; } }
static JExpression getDefaultValue(JType fieldType, JsonNode node) { fieldType = fieldType.unboxify();
JType jtype = baseType.owner().ref(type); if (ruleFactory.getGenerationConfig().isUsePrimitives()) { jtype = jtype.unboxify();
private JType unboxIfNecessary(JType type, GenerationConfig config) { if (config.isUsePrimitives()) { return type.unboxify(); } else { return type; } }
private JType unboxIfNecessary(JType type, GenerationConfig config) { if (config.isUsePrimitives()) { return type.unboxify(); } else { return type; } }
private JType unboxIfNecessary(JType type, GenerationConfig config) { if (config.isUsePrimitives()) { return type.unboxify(); } else { return type; } }
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"; }
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"; }
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"; }
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"; }
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"; }
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"; }
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"; }
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"; }
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"; }
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"; }
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(); } }
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); }
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); }
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); }