private JExpression getDefaultSet(JType fieldType, JsonNode node) {

        JClass setGenericType = ((JClass) fieldType).getTypeParameters().get(0);

        JClass setImplClass = fieldType.owner().ref(LinkedHashSet.class);
        setImplClass = setImplClass.narrow(setGenericType);

        JInvocation newSetImpl = JExpr._new(setImplClass);

        if (node instanceof ArrayNode && node.size() > 0) {
            JInvocation invokeAsList = fieldType.owner().ref(Arrays.class).staticInvoke("asList");
            for (JsonNode defaultValue : node) {
                invokeAsList.arg(getDefaultValue(setGenericType, defaultValue));
            }
            newSetImpl.arg(invokeAsList);
        } else if (!ruleFactory.getGenerationConfig().isInitializeCollections()) {
            return JExpr._null();
        }

        return newSetImpl;

    }
private JExpression getDefaultSet ( JType fieldType , JsonNode node ) { JClass setGenericType = ( ( JClass ) fieldType ) . getTypeParameters ( ) . get ( 0 ) ; JClass setImplClass = fieldType . owner ( ) . ref ( LinkedHashSet . class ) ; setImplClass = setImplClass . narrow ( setGenericType ) ; JInvocation newSetImpl = JExpr . _new ( setImplClass ) ; if ( node instanceof ArrayNode && node . size ( ) > 0 ) { JInvocation invokeAsList = fieldType . owner ( ) . ref ( Arrays . class ) . staticInvoke ( "asList" ) ; for ( JsonNode defaultValue : node ) { invokeAsList . arg ( getDefaultValue ( setGenericType , defaultValue ) ) ; } newSetImpl . arg ( invokeAsList ) ; } else if ( ! ruleFactory . getGenerationConfig ( ) . isInitializeCollections ( ) ) { return JExpr . _null ( ) ; } return newSetImpl ; }
Creates a default value for a set property by:
<ol>
<li>Creating a new {@link LinkedHashSet} with the correct generic type
<li>Using {@link Arrays#asList(Object...)} to initialize the set with the
correct default values
</ol>

@param fieldType
the java type that applies for this field ({@link Set} with
some generic type argument)
@param node
the node containing default values for this set
@return an expression that creates a default value that can be assigned
to this field