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()); }
if (defaultPresent && !field.type().isPrimitive() && node.isNull()) { field.init(JExpr._null());
if (superType.isPrimitive() || isFinal(superType)) { return superType;
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");
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");
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");
/** * Returns true if this is a referenced type. */ public final boolean isReference() { return !isPrimitive(); }
/** * Returns true if this is a referenced type. */ public final boolean isReference() { return !isPrimitive(); }
/** * 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; }
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(); }
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"; }
public JClass getObjectType(ClassContext classContext, FieldItem fieldItem) { final FieldUse fieldUse = getFieldUse(classContext, fieldItem); return fieldUse.type.isPrimitive() ? ((JPrimitiveType) fieldUse.type).getWrapperClass() : (JClass) fieldUse.type; }
/** 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())); } }
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); }
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); }
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); }
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()); }
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 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; }