in grails-forge-core/src/main/java/org/grails/forge/util/NameUtils.java [595:634]
public static String getPropertyNameConvention(Object object, String suffix) {
if (object != null) {
Class<?> type = object.getClass();
if (type.isArray()) {
return getPropertyName(type.getComponentType()) + suffix + "Array";
}
if (object instanceof Collection) {
Collection coll = (Collection) object;
if (coll.isEmpty()) {
return "emptyCollection";
}
Object first = coll.iterator().next();
if (coll instanceof List) {
return getPropertyName(first.getClass()) + suffix + "List";
}
if (coll instanceof Set) {
return getPropertyName(first.getClass()) + suffix + "Set";
}
return getPropertyName(first.getClass()) + suffix + "Collection";
}
if (object instanceof Map) {
Map map = (Map) object;
if (map.isEmpty()) {
return "emptyMap";
}
Object entry = map.values().iterator().next();
if (entry != null) {
return getPropertyName(entry.getClass()) + suffix + "Map";
}
} else {
return getPropertyName(object.getClass()) + suffix;
}
}
return null;
}