if (!fieldVar.type().elementType().isPrimitive()) { throw new UnsupportedOperationException("Only primitive arrays are supported");
if (!fieldVar.type().elementType().isPrimitive()) { throw new UnsupportedOperationException("Only primitive arrays are supported");
} else if (fieldVar.type().isArray()) { if (!fieldVar.type().elementType().isPrimitive()) { throw new UnsupportedOperationException("Only primitive arrays are supported");
public static JType getElementType(final FieldOutline fieldOutline) { final JFieldVar definedField = PluginUtil.getDeclaredField(fieldOutline); if (definedField != null) { if (fieldOutline.getPropertyInfo().isCollection()) { return definedField.type().isArray() ? definedField.type().elementType() : ((JClass) definedField.type()).getTypeParameters().get(0); } else { return definedField.type(); } } else { return null; } }
void generateBuilderMember(final PropertyOutline propertyOutline, final JBlock initBody, final JVar productParam) { final JType fieldType = propertyOutline.getRawType(); if (propertyOutline.isCollection()) { if (propertyOutline.getRawType().isArray()) { generateArrayProperty(initBody, productParam, propertyOutline, fieldType.elementType(), this.builderClass.type); } else { final List<JClass> typeParameters = ((JClass)fieldType).getTypeParameters(); final JClass elementType = typeParameters.get(0); generateCollectionProperty(initBody, productParam, propertyOutline, elementType); if (propertyOutline.getChoiceProperties().size() > 1) { generateCollectionChoiceProperty(propertyOutline); } } } else { generateSingularProperty(initBody, productParam, propertyOutline); if (propertyOutline.getChoiceProperties().size() > 1) { //throw new UnsupportedOperationException("Singular Properties with multiple references not currently supported."); generateSingularChoiceProperty(propertyOutline); } } }
if (type.isArray()) { final JBlock block = JBlock.dummyInstance.block(); final JType elementType = type.elementType(); block.assign(valueCopy, JExpr.newArray(elementType, value.ref("length"))); final JForLoop _for = block._for();
if (type.isArray()) { final JBlock block = JBlock.dummyInstance.block(); final JType elementType = type.elementType(); block.assign(valueCopy, JExpr.newArray(elementType, value .ref("length")));
public void generate(JFormatter f) { // generally we produce new T[x], but when T is an array type (T=T'[]) // then new T'[][x] is wrong. It has to be new T'[x][]. int arrayCount = 0; JType t = type; while( t.isArray() ) { t = t.elementType(); arrayCount++; } f.p("new").g(t).p('['); if (size != null) f.g(size); f.p(']'); for( int i=0; i<arrayCount; i++ ) f.p("[]"); if ((size == null) || (exprs != null)) f.p('{'); if (exprs != null) { f.g(exprs); } else { f.p(' '); } if ((size == null) || (exprs != null)) f.p('}'); }
public void generate(JFormatter f) { // generally we produce new T[x], but when T is an array type (T=T'[]) // then new T'[][x] is wrong. It has to be new T'[x][]. int arrayCount = 0; JType t = type; while( t.isArray() ) { t = t.elementType(); arrayCount++; } f.p("new").g(t).p('['); if (size != null) f.g(size); f.p(']'); for( int i=0; i<arrayCount; i++ ) f.p("[]"); if ((size == null) || (exprs != null)) f.p('{'); if (exprs != null) { f.g(exprs); } else { f.p(' '); } if ((size == null) || (exprs != null)) f.p('}'); }
public void generate(JFormatter f) { // generally we produce new T[x], but when T is an array type (T=T'[]) // then new T'[][x] is wrong. It has to be new T'[x][]. int arrayCount = 0; JType t = type; while( t.isArray() ) { t = t.elementType(); arrayCount++; } f.p("new").g(t).p('['); if (size != null) f.g(size); f.p(']'); for( int i=0; i<arrayCount; i++ ) f.p("[]"); if ((size == null) || (exprs != null)) f.p('{'); if (exprs != null) { f.g(exprs); } else { f.p(' '); } if ((size == null) || (exprs != null)) f.p('}'); }
public void generate(JFormatter f) { // generally we produce new T[x], but when T is an array type (T=T'[]) // then new T'[][x] is wrong. It has to be new T'[x][]. int arrayCount = 0; JType t = type; while( t.isArray() ) { t = t.elementType(); arrayCount++; } f.p("new").g(t).p('['); if (size != null) f.g(size); f.p(']'); for( int i=0; i<arrayCount; i++ ) f.p("[]"); if ((size == null) || (exprs != null)) f.p('{'); if (exprs != null) { f.g(exprs); } else { f.p(' '); } if ((size == null) || (exprs != null)) f.p('}'); }
public void generate(JFormatter f) { // generally we produce new T[x], but when T is an array type (T=T'[]) // then new T'[][x] is wrong. It has to be new T'[x][]. int arrayCount = 0; JType t = type; while( t.isArray() ) { t = t.elementType(); arrayCount++; } f.p("new").g(t).p('['); if (size != null) f.g(size); f.p(']'); for( int i=0; i<arrayCount; i++ ) f.p("[]"); if ((size == null) || (exprs != null)) f.p('{'); if (exprs != null) { f.g(exprs); } else { f.p(' '); } if ((size == null) || (exprs != null)) f.p('}'); }
private void appendHashCode(final JCodeModel codeModel, final JBlock block, final JVar hash, final JType type, final JExpression value, final JExpression isValueSet) { if (type.isArray()) { final JConditional _if = block._if(JExpr._null().eq(value)); _if._then().assign(hash, JOp.mul(JExpr.lit(31), hash)); final JForLoop _for = _if._else()._for(); final JVar i = _for.init(codeModel.INT, "i", JExpr.lit(0)); _for.test(JOp.lt(i, value.ref("length"))); _for.update(JOp.incr(i)); final JVar valueComponent = _for.body().decl(type.elementType(), "valueComponent", value.component(i)); _for.body().assign( hash, JOp.plus( JOp.mul(JExpr.lit(31), hash), valueHashCode(codeModel, type.elementType(), valueComponent, JOp.eq(JExpr._null(), valueComponent)))); } else { block.assign( hash, JOp.plus(JOp.mul(JExpr.lit(31), hash), valueHashCode(codeModel, type, value, isValueSet))); } }
if (!fieldVar.type().elementType().isPrimitive()) { throw new UnsupportedOperationException("Only primitive arrays are supported");
if (!fieldVar.type().elementType().isPrimitive()) { throw new UnsupportedOperationException("Only primitive arrays are supported");
if (!first) f.p(','); f.g(varParam.type().elementType()); f.p("... "); f.id(varParam.name());
if (!first) f.p(','); f.g(varParam.type().elementType()); f.p("... "); f.id(varParam.name());
if (!first) f.p(','); f.g(varParam.type().elementType()); f.p("... "); f.id(varParam.name());
if (!first) f.p(','); f.g(varParam.type().elementType()); f.p("... "); f.id(varParam.name());
_for.update(JOp.incr(i)); final JVar valueComponent = _for.body().decl( value.type().elementType(), "valueComponent", value.component(i));