genesis.metaData.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of genesis-scriptgen Show documentation
Show all versions of genesis-scriptgen Show documentation
Annotation Processor for generating java code using scripts
The newest version!
/*
* Copyright (C) 2015 by Sebastian Hasait (sebastian at hasait dot de)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var GenesisUtils = Java.type('de.hasait.genesis.scriptgen.shaded.genesis.base.util.GenesisUtils');
var StringUtils = Java.type('de.hasait.genesis.scriptgen.shaded.apache.commons.lang3.StringUtils');
var IOUtils = Java.type('de.hasait.genesis.scriptgen.shaded.apache.commons.io.IOUtils');
function generate(scriptEnv) {
var generatorEnv = scriptEnv.generatorEnv;
var typeElement = generatorEnv.annotatedElement;
var packageElement = typeElement.getEnclosingElement();
var srcW = generatorEnv.createRelativeJavaSrcFile("_MD");
srcW.println("// Generated by " + scriptEnv.scriptFileURL);
srcW.println("// Generated at " + new Date());
srcW.println("package " + packageElement.getQualifiedName() + ";");
srcW.println();
srcW.println("/** MetaData for " + typeElement.getQualifiedName() + " */");
srcW.println("public class " + typeElement.getSimpleName() + "_MD {");
srcW.println();
srcW.println("\tpublic static final String SOURCE__NAME = \"" + typeElement.getQualifiedName() + "\";");
var processedPropertyNames = new java.util.HashSet();
for each (var subElement in typeElement.getEnclosedElements()) {
var propertyName = GenesisUtils.determinePropertyNameFromAccessor(subElement);
if (propertyName != null && !processedPropertyNames.contains(propertyName)) {
processedPropertyNames.add(propertyName);
var propertyNameUU = GenesisUtils.camelCaseToUpperUnderscore(propertyName);
srcW.println();
srcW.println("\tpublic static final String PROPERTY__" + propertyNameUU + "__NAME = \"" + propertyName + "\";");
}
}
srcW.println();
srcW.println("}");
srcW.close();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy