org.milyn.javabean.pojogen.PojoGenUtil Maven / Gradle / Ivy
The newest version!
/*
* Milyn - Copyright (C) 2006 - 2010
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License (version 2.1) as published by the Free Software
* Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU Lesser General Public License for more details:
* http://www.gnu.org/licenses/lgpl.txt
*/
package org.milyn.javabean.pojogen;
import java.util.*;
/**
* Pojogen utility methods.
*
* @author [email protected]
*/
class PojoGenUtil {
public static String getTypeDecl(String pre, Set types) {
if(types.isEmpty()) {
return "";
}
StringBuilder typeDecl = new StringBuilder();
typeDecl.append(" ");
typeDecl.append(pre);
typeDecl.append(" ");
List typesList = new ArrayList(types);
Set> addedTypes = new LinkedHashSet>();
for(int i = 0; i < types.size(); i++) {
Class> type = typesList.get(i).getType();
if(!addedTypes.contains(type)) {
if(i > 0) {
typeDecl.append(", ");
}
typeDecl.append(type.getSimpleName());
addedTypes.add(type);
}
}
return typeDecl.toString();
}
}