private static String readObjectArrayValue ( String ref , TypeDef source , Property property ) { StringBuilder sb = new StringBuilder ( ) ; Method getter = getterOf ( source , property ) ; TypeRef getterTypeRef = getter . getReturnType ( ) ; TypeRef propertyTypeRef = property . getTypeRef ( ) ; if ( propertyTypeRef instanceof ClassRef && getterTypeRef instanceof ClassRef ) { String nextRef = variables . pop ( ) ; try { TypeDef propertyType = ( ( ClassRef ) propertyTypeRef ) . getDefinition ( ) ; TypeDef getterType = ( ( ClassRef ) getterTypeRef ) . getDefinition ( ) ; sb . append ( indent ( ref ) ) . append ( "Arrays.stream(" ) . append ( "(Map[])(" + ref + " instanceof Map ? ((Map)" + ref + ").getOrDefault(\"" + getterOf ( source , property ) . getName ( ) + "\" , new Map[0]) : new Map[0]))" ) //.append("("+getterType.getFullyQualifiedName()+"[])(" + ref + " instanceof Map ? ((Map)" + ref + ").getOrDefault(\"" + getterOf(source, property).getName() + "\" , new " +getterType.getFullyQualifiedName()+"[0]) : new "+ getterType.getFullyQualifiedName()+"[0]))") . append ( ".map(" ) . append ( nextRef ) . append ( " ->" ) . append ( convertMap ( nextRef , getterType , propertyType ) ) . append ( ")" ) . append ( ".toArray(size-> new " + propertyType . getFullyQualifiedName ( ) + "[size])" ) ; } finally { variables . push ( nextRef ) ; } return sb . toString ( ) ; } throw new IllegalArgumentException ( "Expected an object property and a matching object getter!!" ) ; }
Returns the string representation of the code that reads an object array property .