Java 类com.sun.codemodel.JResourceFile 实例源码

项目:jaxb2-basics    文件:CodeModelUtils.java   
/**
 * Returns a property file (created if necessary).
 * 
 * @param thePackage
 *            package to create property file
 * @param name
 *            property file name.
 * @return Property file.
 */

public static JPropertyFile getOrCreatePropertyFile(JPackage thePackage,
        String name) {
    JPropertyFile propertyFile = null;
    for (Iterator<JResourceFile> iterator = thePackage.propertyFiles(); iterator
            .hasNext() && (null == propertyFile);) {
        final JResourceFile resourceFile = (JResourceFile) iterator.next();
        if (resourceFile instanceof JPropertyFile
                && name.equals(resourceFile.name())) {
            propertyFile = (JPropertyFile) resourceFile;
        }
    }

    if (null == propertyFile) {
        propertyFile = new JPropertyFile(name);
        thePackage.addResourceFile(propertyFile);
    }
    return propertyFile;
}