com.sun.codemodel.util.NameUtilities Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of codemodel Show documentation
Show all versions of codemodel Show documentation
The core functionality of the CodeModel Java source code generation library
The newest version!
package com.sun.codemodel.util;
import java.util.ArrayList;
import java.util.List;
/**
* @author Ben Fagin
* @version 2013-04-01
*/
public class NameUtilities {
public static String getFullName(Class c) {
if (c == null) {
throw new IllegalArgumentException("class cannot be null");
}
StringBuilder name = new StringBuilder();
name.append(c.getPackage().getName()).append(".");
Class klaus = c;
List enclosingClasses = new ArrayList();
while ((klaus = klaus.getEnclosingClass()) != null) {
enclosingClasses.add(klaus);
}
for (int i = enclosingClasses.size() - 1; i >= 0; i--) {
name.append(enclosingClasses.get(i).getSimpleName()).append(".");
}
name.append(c.getSimpleName());
return name.toString();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy