Code example for Collection

Methods: getComparatorClassNameisSortedaccept

0
		if(c2j.getJavaTypeName(p, false)==null) {
			throw new IllegalArgumentException();
		} else if (p.getValue() instanceof Collection) {
			Collection col = (Collection) p.getValue();
			 
			DefaultInitializor initialization = (DefaultInitializor) col.accept(new DefaultValueVisitor(true) {
			  
				public Object accept(Bag o) {
					return new DefaultInitializor("java.util.ArrayList", true); 
				} 
				 
				public Object accept(org.hibernate.mapping.List o) {
					return new DefaultInitializor("java.util.ArrayList", true); 
				} 
				 
				public Object accept(org.hibernate.mapping.Map o) {
					if(o.isSorted()) {
						return new DefaultInitializor("java.util.TreeMap", false); 
					} else { 
						return new DefaultInitializor("java.util.HashMap", true); 
					} 
				} 
				 
				public Object accept(IdentifierBag o) {
					return new DefaultInitializor("java.util.ArrayList", true); 
				} 
				 
				public Object accept(Set o) {
					if(o.isSorted()) {
						return new DefaultInitializor("java.util.TreeSet", false); 
					} else { 
						return new DefaultInitializor("java.util.HashSet", true); 
					} 
				} 
				 
				 
				public Object accept(PrimitiveArray o) {
					return null; // TODO: default init for arrays ? 
				} 
				 
				public Object accept(Array o) {
					return null;// TODO: default init for arrays ? 
				} 
				 
			}); 
						  
			if(initialization!=null) {
				String comparator = null;
				String decl = null;
 
				if(col.isSorted()) {
					comparator = col.getComparatorClassName();
				} 
 
				if(useGenerics) {
					decl = c2j.getGenericCollectionDeclaration((Collection) p.getValue(), true, importContext);
				} 
				return initialization.getDefaultValue(comparator, decl, this);
			} else { 
				return null; 
			}