Search in sources :

Example 1 with freemarker.core._DelayedConversionToString

use of freemarker.core._DelayedConversionToString in project freemarker by apache.

the class OverloadedMethods method memberListToString.

private _DelayedConversionToString memberListToString() {
    return new _DelayedConversionToString(null) {

        @Override
        protected String doConversion(Object obj) {
            final Iterator fixArgMethodsIter = fixArgMethods.getMemberDescriptors();
            final Iterator varargMethodsIter = varargMethods != null ? varargMethods.getMemberDescriptors() : null;
            boolean hasMethods = fixArgMethodsIter.hasNext() || (varargMethodsIter != null && varargMethodsIter.hasNext());
            if (hasMethods) {
                StringBuilder sb = new StringBuilder();
                HashSet fixArgMethods = new HashSet();
                while (fixArgMethodsIter.hasNext()) {
                    if (sb.length() != 0)
                        sb.append(",\n");
                    sb.append("    ");
                    CallableMemberDescriptor callableMemberDesc = (CallableMemberDescriptor) fixArgMethodsIter.next();
                    fixArgMethods.add(callableMemberDesc);
                    sb.append(callableMemberDesc.getDeclaration());
                }
                if (varargMethodsIter != null) {
                    while (varargMethodsIter.hasNext()) {
                        CallableMemberDescriptor callableMemberDesc = (CallableMemberDescriptor) varargMethodsIter.next();
                        if (!fixArgMethods.contains(callableMemberDesc)) {
                            if (sb.length() != 0)
                                sb.append(",\n");
                            sb.append("    ");
                            sb.append(callableMemberDesc.getDeclaration());
                        }
                    }
                }
                return sb.toString();
            } else {
                return "No members";
            }
        }
    };
}
Also used : Iterator(java.util.Iterator) freemarker.core._DelayedConversionToString(freemarker.core._DelayedConversionToString) HashSet(java.util.HashSet)

Aggregations

freemarker.core._DelayedConversionToString (freemarker.core._DelayedConversionToString)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1