diff --git a/cobigen-plugins/cobigen-javaplugin-parent/cobigen-javaplugin/src/main/java/com/devonfw/cobigen/api/template/out/java/CobiGenOutputJava.java b/cobigen-plugins/cobigen-javaplugin-parent/cobigen-javaplugin/src/main/java/com/devonfw/cobigen/api/template/out/java/CobiGenOutputJava.java new file mode 100644 index 0000000000..99f13c81cf --- /dev/null +++ b/cobigen-plugins/cobigen-javaplugin-parent/cobigen-javaplugin/src/main/java/com/devonfw/cobigen/api/template/out/java/CobiGenOutputJava.java @@ -0,0 +1,74 @@ +package com.devonfw.cobigen.api.template.out.java; + +import com.devonfw.cobigen.api.template.out.CobiGenOutputCode; +import com.devonfw.cobigen.api.template.out.ImportStatement; +import com.devonfw.cobigen.api.template.out.QualifiedName; + +/** + * Implementation of {@link com.devonfw.cobigen.api.template.out.CobiGenOutput} for Java. + */ +public class CobiGenOutputJava extends CobiGenOutputCode { + + /** + * The constructor. + * + * @param parent the parent type output. + */ + public CobiGenOutputJava(CobiGenOutputJava parent) { + + super(parent); + } + + /** + * The constructor. + * + * @param filename the {@link #getFilename() filename}. + */ + public CobiGenOutputJava(String filename) { + + super(filename); + } + + @Override + protected CobiGenOutputJava createChild() { + + return new CobiGenOutputJava(this); + } + + @Override + public boolean addImport(QualifiedName qualifiedName) { + + if (isImportRequired(qualifiedName)) { + return addImport(new JavaImportStatement(qualifiedName)); + } + return false; + } + + @Override + protected ImportStatement createImportStatement(LineTokenizer tokenizer) { + + String token = tokenizer.next(); + String staticReference = null; + QualifiedName qname; + if (KEYWORD_STATIC.equals(token)) { + token = tokenizer.next(); + qname = parseName(token); + staticReference = qname.getSimpleName(); + qname = parseName(qname.getNamespace()); + } else { + qname = parseName(token); + } + return new JavaImportStatement(qname, staticReference); + } + + @Override + protected boolean isImportRequired(QualifiedName qualifiedName) { + + String pkg = qualifiedName.getNamespace(); + if (pkg.isEmpty() || "java.lang".equals(pkg)) { + return false; + } + return true; + } + +} diff --git a/cobigen-plugins/cobigen-javaplugin-parent/cobigen-javaplugin/src/main/java/com/devonfw/cobigen/api/template/out/java/CobiGenOutputTypeFactoryJava.java b/cobigen-plugins/cobigen-javaplugin-parent/cobigen-javaplugin/src/main/java/com/devonfw/cobigen/api/template/out/java/CobiGenOutputTypeFactoryJava.java new file mode 100644 index 0000000000..6e7d795ba8 --- /dev/null +++ b/cobigen-plugins/cobigen-javaplugin-parent/cobigen-javaplugin/src/main/java/com/devonfw/cobigen/api/template/out/java/CobiGenOutputTypeFactoryJava.java @@ -0,0 +1,23 @@ +package com.devonfw.cobigen.api.template.out.java; + +import com.devonfw.cobigen.api.template.out.CobiGenOutput; +import com.devonfw.cobigen.api.template.out.CobiGenOutputTypeFactory; + +/** + * Implementation of {@link CobiGenOutputTypeFactory} for Java. + */ +public class CobiGenOutputTypeFactoryJava implements CobiGenOutputTypeFactory { + + @Override + public String getType() { + + return "java"; + } + + @Override + public CobiGenOutput create(String filename) { + + return new CobiGenOutputJava(filename); + } + +} diff --git a/cobigen-plugins/cobigen-javaplugin-parent/cobigen-javaplugin/src/main/java/com/devonfw/cobigen/api/template/out/java/JavaImportStatement.java b/cobigen-plugins/cobigen-javaplugin-parent/cobigen-javaplugin/src/main/java/com/devonfw/cobigen/api/template/out/java/JavaImportStatement.java new file mode 100644 index 0000000000..6c1b6b0adf --- /dev/null +++ b/cobigen-plugins/cobigen-javaplugin-parent/cobigen-javaplugin/src/main/java/com/devonfw/cobigen/api/template/out/java/JavaImportStatement.java @@ -0,0 +1,104 @@ +package com.devonfw.cobigen.api.template.out.java; + +import java.util.Objects; + +import com.devonfw.cobigen.api.template.out.ImportStatement; +import com.devonfw.cobigen.api.template.out.QualifiedName; + +/** + * Implementation of {@link IllegalStateException} for Java. + */ +public class JavaImportStatement implements ImportStatement { + + private final QualifiedName type; + + private final String staticReference; + + /** + * The constructor. + * + * @param type the {@link QualifiedName} of the type to import. + */ + public JavaImportStatement(QualifiedName type) { + + this(type, null); + } + + /** + * The constructor. + * + * @param type the {@link QualifiedName} of the type to import. + * @param staticReference the optional static reference (method, constant, etc.) to import from the specified type. + */ + public JavaImportStatement(QualifiedName type, String staticReference) { + + super(); + this.type = type; + this.staticReference = staticReference; + } + + @Override + public int getKeyCount() { + + return 1; + } + + @Override + public String getKey(int i) { + + if (i == 0) { + if (this.staticReference == null) { + return this.type.getSimpleName(); + } + return this.staticReference; + } + return null; + } + + @Override + public String getTarget() { + + return this.type.getQualifiedName(); + } + + @Override + public String getStaticReference() { + + return this.staticReference; + } + + @Override + public int hashCode() { + + return Objects.hash(this.staticReference, this.type); + } + + @Override + public boolean equals(Object obj) { + + if (this == obj) { + return true; + } else if ((obj == null) || (getClass() != obj.getClass())) { + return false; + } + JavaImportStatement other = (JavaImportStatement) obj; + return Objects.equals(this.staticReference, other.staticReference) && Objects.equals(this.type, other.type); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder("import "); + if (isStatic()) { + sb.append("static "); + } + sb.append(getTarget()); + if (this.staticReference != null) { + sb.append('.'); + sb.append(this.staticReference); + } + sb.append(";"); + return sb.toString(); + } + +} diff --git a/cobigen-plugins/cobigen-javaplugin-parent/cobigen-javaplugin/src/main/resources/META-INF/services/com.devonfw.cobigen.api.template.out.CobiGenOutputTypeFactory b/cobigen-plugins/cobigen-javaplugin-parent/cobigen-javaplugin/src/main/resources/META-INF/services/com.devonfw.cobigen.api.template.out.CobiGenOutputTypeFactory new file mode 100644 index 0000000000..c5aca2f081 --- /dev/null +++ b/cobigen-plugins/cobigen-javaplugin-parent/cobigen-javaplugin/src/main/resources/META-INF/services/com.devonfw.cobigen.api.template.out.CobiGenOutputTypeFactory @@ -0,0 +1 @@ +com.devonfw.cobigen.api.template.out.java.CobiGenOutputTypeFactoryJava \ No newline at end of file diff --git a/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/pom.xml b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/pom.xml new file mode 100644 index 0000000000..531277a945 --- /dev/null +++ b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/pom.xml @@ -0,0 +1,36 @@ + + 4.0.0 + tempeng-agnostic + CobiGen - Template Engine for language agnostic templates + + com.devonfw.cobigen + tempeng-parent + ${revision} + + + false + + + + com.devonfw.cobigen + core + + + + com.devonfw.cobigen.templates + templates-devonfw-java + test + + + com.devonfw.cobigen + core-test + test + + + com.devonfw.cobigen + javaplugin + test + + + \ No newline at end of file diff --git a/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/main/java/com/devonfw/cobigen/tempeng/agnostic/AgnosticTemplateEngine.java b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/main/java/com/devonfw/cobigen/tempeng/agnostic/AgnosticTemplateEngine.java new file mode 100644 index 0000000000..d0d49bd534 --- /dev/null +++ b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/main/java/com/devonfw/cobigen/tempeng/agnostic/AgnosticTemplateEngine.java @@ -0,0 +1,210 @@ +package com.devonfw.cobigen.tempeng.agnostic; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Map; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.devonfw.cobigen.api.annotation.CobiGenDynamicType; +import com.devonfw.cobigen.api.annotation.Name; +import com.devonfw.cobigen.api.exception.CobiGenRuntimeException; +import com.devonfw.cobigen.api.extension.TextTemplate; +import com.devonfw.cobigen.api.extension.TextTemplateEngine; +import com.devonfw.cobigen.api.model.CobiGenModel; +import com.devonfw.cobigen.api.model.CobiGenModelDefault; +import com.devonfw.cobigen.api.model.CobiGenVariableDefinitions; +import com.devonfw.cobigen.api.model.VariableSyntax; +import com.devonfw.cobigen.api.template.generator.CobiGenGeneratorProvider; +import com.devonfw.cobigen.api.template.out.AbstractCobiGenOutput; +import com.devonfw.cobigen.api.template.out.CobiGenOutputFactory; +import com.devonfw.cobigen.api.template.out.CobiGenOutputFallback; + +/** + * Template engine for language-agnostic-templates.
+ * The idea is that templates are written in the syntax and language of the target file to generate. That is, e.g. a + * Java file is generated from a template with the package and name of the file to generate and simply has a ".java" + * extension. It is containing valid Java code and the Java compiler is used to validate its syntax. The IDE of your + * choice can be used for auto-completion, refactoring, code-formatting, etc. In order to represent variables in the + * template, you simply put them in a specific {@link VariableSyntax#AGNOSTIC agnostic variable syntax} that is + * compliant with any kind of format or programming language as it only uses letters and underscores that are more or + * less allowed anywhere. + */ +@Name("Agnostic") +public class AgnosticTemplateEngine implements TextTemplateEngine { + + private static final Logger LOG = LoggerFactory.getLogger(AgnosticTemplateEngine.class); + + static final Pattern PATTERN_IMPORT = Pattern.compile( + // .......1............2.............................................3........4...............5...............6 + "^\\s*import\\s(static)?\\s*(\\{[^}]+\\}|[\\p{L}0-9.]+|[\\\\p{L}0-9.]*\\*)(\\sas\\s([\\p{L}0-9]+))?(\\sfrom\\s[\"']([^\"']+)[\"'])?;"); + + private static final Pattern PATTERN_COBIGEN = Pattern.compile( // + // 1....................2...3...........4 + "@?(CobiGen[\\p{L}0-9]*)(\\(([^)]*)\\))?(\\s+[\\p{L}0-9]+)?"); + + /** + * The constructor. + */ + public AgnosticTemplateEngine() { + + super(); + } + + @Override + public void setTemplateFolder(Path templateFolderPath) { + + // pointless + } + + @Override + public String getTemplateFileEnding() { + + return null; + } + + @Override + public void process(TextTemplate template, Map modelAsMap, Writer writer, String outputEncoding) { + + // executeInThisClassloader(() -> { + try { + CobiGenModelDefault model = CobiGenModelDefault.fromLegacyMap(modelAsMap); + process(template, model, writer); + } catch (Throwable e) { + throw new CobiGenRuntimeException("An unkonwn error occurred while generating the template." + + template.getAbsoluteTemplatePath() + "(Agnostic)", e); + } + // }); + } + + private void process(TextTemplate template, CobiGenModel model, Writer writer) { + + String path = template.getRelativeTemplatePath(); + path = model.resolve(path, '/', VariableSyntax.AGNOSTIC); + AbstractCobiGenOutput out = (AbstractCobiGenOutput) CobiGenOutputFactory.get().create(path); + model = new CobiGenModelDefault(model); + CobiGenVariableDefinitions.OUT.setValue(model, (out != null) ? out : new CobiGenOutputFallback(path)); + AbstractCobiGenOutput currentOut = out; + Path templatePath = template.getAbsoluteTemplatePath(); + try (BufferedReader reader = Files.newBufferedReader(templatePath)) { + boolean todo = true; + while (todo) { + String line = reader.readLine(); + if (line != null) { + line = processLine(line, model, writer, out); + if (line != null) { + if (currentOut == null) { + writer.write(line); + writer.write('\n'); + } else { + AbstractCobiGenOutput newOut = currentOut.addLine(line); + if (newOut != currentOut) { + currentOut = newOut; + model = new CobiGenModelDefault(model); + CobiGenVariableDefinitions.OUT.setValue(model, currentOut); + } + } + } + } else { + todo = false; + } + } + if (out != null) { + out.write(writer); + } + } catch (IOException e) { + throw new IllegalStateException("I/O error while instantiation template.", e); + } + } + + private String processLine(String line, CobiGenModel model, Writer writer, AbstractCobiGenOutput out) + throws IOException { + + Matcher matcher = PATTERN_COBIGEN.matcher(line); + boolean cgFound = matcher.find(); + if (cgFound) { + if (line.trim().startsWith("import")) { + return null; + } + StringBuilder sb = null; + do { + String cobiGenString = matcher.group(); + String cobiGenType = matcher.group(1); + if (cobiGenString.startsWith("@")) { + if (cobiGenType.equals("CobiGenDynamicType")) { + if (sb == null) { + sb = new StringBuilder(line.length()); + } + String cobiGenArgs = matcher.group(3); + Objects.requireNonNull(cobiGenArgs, cobiGenString); + if (cobiGenType.equals(CobiGenDynamicType.class.getSimpleName())) { + cobiGenArgs = cobiGenArgs.trim().replaceAll("value\\s*=", "").replace(".class", "").trim(); + String replacement = CobiGenGeneratorProvider.get().generate(cobiGenArgs, model); + String typeName = matcher.group(4); + if (typeName == null) { + LOG.warn( + "Missing type when replacing '{}' with '{}' - check your auto-formatter and prevent line-wrapping between annotation and type.", + cobiGenString, replacement); + } else { + if ((replacement == null) || replacement.isBlank()) { + replacement = typeName; // fallback to parent type if generator result is empty + } + LOG.debug("Replacing '{}' with '{}'.", cobiGenString, replacement); + } + matcher.appendReplacement(sb, replacement); + } else { + LOG.warn("Unsupported annotation {}", cobiGenString); + } + } else { + LOG.warn("Unsupported annotation {}", cobiGenString); + return null; + } + } else if (cobiGenString.startsWith("CobiGenGenerator")) { + if (out == null) { + CobiGenGeneratorProvider.get().generate(cobiGenType, model, writer); + } else { + String code = CobiGenGeneratorProvider.get().generate(cobiGenType, model); + if (code.indexOf('\n') >= 0) { + for (String codeLine : code.split("\n")) { + out.addLine(codeLine); + } + } else { + out.addLine(code); + } + } + return null; + } else { + return null; + } + } while (matcher.find()); + matcher.appendTail(sb); + line = sb.toString(); + } + return model.resolve(line, '.', VariableSyntax.AGNOSTIC); + } + + /** + * Execute a {@link Runnable} within the classloader loading THIS class to circumvent from classpath conflicts in osgi + * environments + * + * @param exec the {@link Runnable} to be called + */ + private void executeInThisClassloader(Runnable exec) { + + Thread thread = Thread.currentThread(); + ClassLoader loader = thread.getContextClassLoader(); + thread.setContextClassLoader(this.getClass().getClassLoader()); + try { + exec.run(); + } finally { + thread.setContextClassLoader(loader); + } + } +} diff --git a/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/main/resources/META-INF/LICENSE.txt b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..49c6980566 --- /dev/null +++ b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2015-2018 Capgemini SE. + + 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. diff --git a/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/main/resources/META-INF/LICENSEP2BUNDLE.txt b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/main/resources/META-INF/LICENSEP2BUNDLE.txt new file mode 100644 index 0000000000..206f140626 --- /dev/null +++ b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/main/resources/META-INF/LICENSEP2BUNDLE.txt @@ -0,0 +1,1944 @@ + +License CobiGen +=============== + +Binaries of this product have been made available to you by devonfw (http://www.devonfw.com/) under the Apache Public License 2.0. +All of the source code to this product is available under licenses which are both free (https://www.gnu.org/philosophy/free-sw.html) and open source (https://www.opensource.org/docs/definition.php). +More specifically, most of the source code is available under the Apache Public License 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt). The remainder of the software which is not under the Apache license is available under one of a variety of other free and open source licenses. Those that require reproduction of the license text in the distribution are given below. (Note: your copy of this product may not contain code covered by one or more of the licenses listed here, depending on the exact product and version you choose.) ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| Name | Group Id | Version | Application | License | License Url | ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| logback-classic | ch.qos.logback | 1.2.3 | cobigen-eclipse, cobigen-cli | LGPL-2.1 | http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html | +| logback-core | ch.qos.logback | 1.2.3 | cobigen-eclipse, cobigen-cli | LGPL-2.1 | http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html | +| java-sizeof | com.carrotsearch | 0.0.5 | cobigen-maven, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| jackson-annotations | com.fasterxml.jackson.core | 2.10.0 | cobigen-tsplugin, cobigen-openapiplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| jackson-core | com.fasterxml.jackson.core | 2.10.0 | cobigen-tsplugin, cobigen-openapiplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| jackson-databind | com.fasterxml.jackson.core | 2.10.0 | cobigen-tsplugin, cobigen-openapiplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| jackson-dataformat-yaml | com.fasterxml.jackson.dataformat | 2.9.8 | cobigen-openapiplugin | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| lexeme | com.github.maybeec | 2.0.0 | cobigen-xmlplugin | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| openapi-parser | com.github.maybeec | 4.0.4 | cobigen-openapiplugin | EPL-2.0 | https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt | +| jsr305 | com.google.code.findbugs | 3.0.2 | cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| gson | com.google.code.gson | 2.8.6 | cobigen-tsplugin, cobigen-maven, cobigen-jsonplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| error_prone_annotations | com.google.errorprone | 2.5.1 | cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| google-java-format | com.google.googlejavaformat | 1.10.0 | cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| failureaccess | com.google.guava | 1.0.1 | cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| guava | com.google.guava | 30.1.1-jre | cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| listenablefuture | com.google.guava | 9999.0-empty-to-avoid-conflict-with-guava | cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| j2objc-annotations | com.google.j2objc | 1.3 | cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| json-path | com.jayway.jsonpath | 2.4.0 | cobigen-openapiplugin | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| jsonoverlay | com.reprezen.jsonoverlay | 4.0.4 | cobigen-openapiplugin | EPL-2.0 | https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt | +| okhttp | com.squareup.okhttp3 | 4.9.1 | cobigen-tsplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| okio | com.squareup.okio | 2.8.0 | cobigen-tsplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| jakarta.activation | com.sun.activation | 2.0.1 | cobigen-xmlplugin, cobigen-openapiplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | EDL-1.0 | http://www.eclipse.org/org/documents/edl-v10.php | +| istack-commons-runtime | com.sun.istack | 4.0.1 | cobigen-xmlplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | EDL-1.0 | http://www.eclipse.org/org/documents/edl-v10.php | +| jakarta.mail | com.sun.mail | 2.0.1 | cobigen-openapiplugin | EPL-2.0 | https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt | +| jaxb-core | com.sun.xml.bind | 3.0.1 | cobigen-xmlplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | EDL-1.0 | http://www.eclipse.org/org/documents/edl-v10.php | +| jaxb-impl | com.sun.xml.bind | 3.0.1 | cobigen-xmlplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | EDL-1.0 | http://www.eclipse.org/org/documents/edl-v10.php | +| paranamer | com.thoughtworks.paranamer | 2.8 | cobigen-maven, cobigen-eclipse, cobigen-cli | BSD-3-Clause | https://raw.githubusercontent.com/paul-hammant/paranamer/master/LICENSE.txt | +| qdox | com.thoughtworks.qdox | 2.0.0 | cobigen-javaplugin | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| commons-collections | commons-collections | 3.2.1 | cobigen-tempeng-velocity | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| commons-io | commons-io | 2.9.0 | cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-maven, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | https://www.apache.org/licenses/LICENSE-2.0.txt | +| commons-jxpath | commons-jxpath | 1.3 | cobigen-maven, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| commons-lang | commons-lang | 2.4 | cobigen-tempeng-velocity | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| picocli | info.picocli | 4.5.1 | cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| jakarta.annotation-api | jakarta.annotation | 2.0.0 | cobigen-openapiplugin | EPL-2.0 | https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt | +| jakarta.mail-api | jakarta.mail | 2.0.1 | cobigen-openapiplugin | EPL-2.0 | https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt | +| jakarta.xml.bind-api | jakarta.xml.bind | 3.0.1 | cobigen-xmlplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | EDL-1.0 | http://www.eclipse.org/org/documents/edl-v10.php | +| javax.inject | javax.inject | 1 | cobigen-maven, cobigen-javaplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| jaxen | jaxen | 1.2.0 | cobigen-xmlplugin, cobigen-tempeng-freemarker, cobigen-maven, cobigen-eclipse, cobigen-cli | BSD-3-Clause | https://raw.githubusercontent.com/jaxen-xpath/jaxen/master/LICENSE.txt | +| orika-core | ma.glasnost.orika | 1.5.4 | cobigen-maven, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| accessors-smart | net.minidev | 1.2 | cobigen-openapiplugin | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| json-smart | net.minidev | 2.3 | cobigen-openapiplugin | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| mmm-code-api | net.sf.m-m-m | 1.0.0-beta6 | cobigen-javaplugin | Apache-2.0 | https://raw.githubusercontent.com/m-m-m/code/master/LICENSE | +| mmm-code-base | net.sf.m-m-m | 1.0.0-beta6 | cobigen-javaplugin | Apache-2.0 | https://raw.githubusercontent.com/m-m-m/code/master/LICENSE | +| mmm-code-java-impl | net.sf.m-m-m | 1.0.0-beta6 | cobigen-javaplugin | Apache-2.0 | https://raw.githubusercontent.com/m-m-m/code/master/LICENSE | +| mmm-code-java-maven | net.sf.m-m-m | 1.0.0-beta6 | cobigen-javaplugin | Apache-2.0 | https://raw.githubusercontent.com/m-m-m/code/master/LICENSE | +| mmm-code-java-parser | net.sf.m-m-m | 1.0.0-beta6 | cobigen-javaplugin | Apache-2.0 | https://raw.githubusercontent.com/m-m-m/code/master/LICENSE | +| mmm-util-core | net.sf.m-m-m | 7.4.0 | cobigen-maven, cobigen-javaplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| mmm-util-io | net.sf.m-m-m | 7.5.1 | cobigen-javaplugin | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| mmm-util-pojo | net.sf.m-m-m | 7.5.1 | cobigen-javaplugin | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| antlr4-runtime | org.antlr | 4.7 | cobigen-javaplugin | BSD-3-Clause | https://www.antlr.org/license.html | +| ant | org.apache.ant | 1.8.1 | cobigen-eclipse | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.html | +| ant-nodeps | org.apache.ant | 1.8.1 | cobigen-eclipse | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.html | +| commons-compress | org.apache.commons | 1.18 | cobigen-tsplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | Apache-2.0 | https://www.apache.org/licenses/LICENSE-2.0.txt | +| commons-lang3 | org.apache.commons | 3.12.0 | cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | https://www.apache.org/licenses/LICENSE-2.0.txt | +| commons-text | org.apache.commons | 1.6 | cobigen-cli | Apache-2.0 | https://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-aether-provider | org.apache.maven | 3.0 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-artifact | org.apache.maven | 3.0 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-artifact | org.apache.maven | 3.6.1 | cobigen-javaplugin | Apache-2.0 | https://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-builder-support | org.apache.maven | 3.6.1 | cobigen-javaplugin | Apache-2.0 | https://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-compat | org.apache.maven | 3.0 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-core | org.apache.maven | 3.0 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-model | org.apache.maven | 3.0 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-model | org.apache.maven | 3.8.1, 3.6.1 | cobigen-javaplugin, cobigen-cli | Apache-2.0 | https://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-model-builder | org.apache.maven | 3.0 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-model-builder | org.apache.maven | 3.6.1 | cobigen-javaplugin | Apache-2.0 | https://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-plugin-api | org.apache.maven | 3.0 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-repository-metadata | org.apache.maven | 3.0 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-settings | org.apache.maven | 3.0 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| maven-settings-builder | org.apache.maven | 3.0 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| wagon-provider-api | org.apache.maven.wagon | 1.0-beta-6 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| velocity | org.apache.velocity | 1.7 | cobigen-tempeng-velocity | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| checker-qual | org.checkerframework | 3.8.0 | cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli | MIT | http://opensource.org/licenses/MIT | +| commons-compiler | org.codehaus.janino | 3.0.8 | cobigen-maven, cobigen-eclipse, cobigen-cli | BSD-3-Clause | https://raw.githubusercontent.com/janino-compiler/janino/master/LICENSE | +| janino | org.codehaus.janino | 3.0.8 | cobigen-maven, cobigen-eclipse, cobigen-cli | BSD-3-Clause | https://raw.githubusercontent.com/janino-compiler/janino/master/LICENSE | +| plexus-classworlds | org.codehaus.plexus | 2.2.3 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| plexus-component-annotations | org.codehaus.plexus | 1.7.1, 1.5.5 | cobigen-maven, cobigen-javaplugin | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| plexus-interpolation | org.codehaus.plexus | 1.25, 1.14 | cobigen-maven, cobigen-javaplugin | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| plexus-utils | org.codehaus.plexus | 3.2.1, 3.2.0, 2.0.4 | cobigen-maven, cobigen-javaplugin, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| freemarker | org.freemarker | 2.3.29 | cobigen-tempeng-freemarker | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| jaxb-core | org.glassfish.jaxb | 3.0.1 | cobigen-xmlplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | EDL-1.0 | http://www.eclipse.org/org/documents/edl-v10.php | +| txw2 | org.glassfish.jaxb | 3.0.1 | cobigen-xmlplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | EDL-1.0 | http://www.eclipse.org/org/documents/edl-v10.php | +| javassist | org.javassist | 3.24.0-GA | cobigen-maven, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/ | +| jdom2 | org.jdom | 2.0.6 | cobigen-xmlplugin | JDOM | https://raw.github.com/hunterhacker/jdom/master/LICENSE.txt | +| annotations | org.jetbrains | 13.0 | cobigen-tsplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| kotlin-stdlib | org.jetbrains.kotlin | 1.4.10 | cobigen-tsplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| kotlin-stdlib-common | org.jetbrains.kotlin | 1.4.0 | cobigen-tsplugin, cobigen-maven, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| json | org.json | 20180813 | cobigen-tsplugin | JSON | https://raw.githubusercontent.com/stleary/JSON-java/master/LICENSE | +| jsoup | org.jsoup | 1.10.2 | cobigen-htmlplugin | MIT | https://jsoup.org/license | +| asm | org.ow2.asm | 5.0.4 | cobigen-openapiplugin | BSD-3-Clause | https://gitlab.ow2.org/asm/asm/raw/ASM_5_0_4/LICENSE.txt | +| jcl-over-slf4j | org.slf4j | 1.7.30 | cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | https://www.apache.org/licenses/LICENSE-2.0.txt | +| log4j-over-slf4j | org.slf4j | 1.7.30 | cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| slf4j-api | org.slf4j | 1.7.30 | cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli | MIT | http://www.slf4j.org/license.html | +| aether-api | org.sonatype.aether | 1.7 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| aether-impl | org.sonatype.aether | 1.7 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| aether-spi | org.sonatype.aether | 1.7 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| aether-util | org.sonatype.aether | 1.7 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| plexus-cipher | org.sonatype.plexus | 1.4 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0 | +| plexus-sec-dispatcher | org.sonatype.plexus | 1.3 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0 | +| sisu-guice | org.sonatype.sisu | 2.1.7 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| sisu-inject-bean | org.sonatype.sisu | 1.4.2 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| sisu-inject-plexus | org.sonatype.sisu | 1.4.2 | cobigen-maven | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| snakeyaml | org.yaml | 1.23 | cobigen-openapiplugin | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| zt-exec | org.zeroturnaround | 1.12 | cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli | Apache-2.0 | http://www.apache.org/licenses/LICENSE-2.0.txt | +| sax | sax | 2.0.1 | cobigen-xmlplugin | PublicDomain | https://creativecommons.org/licenses/publicdomain | ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +Overview of used licenses +========================= + +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +Apache-2.0 +---------- + + The component(s) (Name/GroupId/Version): + + * mmm-code-api/net.sf.m-m-m/1.0.0-beta6 (cobigen-javaplugin) + * mmm-code-base/net.sf.m-m-m/1.0.0-beta6 (cobigen-javaplugin) + * mmm-code-java-impl/net.sf.m-m-m/1.0.0-beta6 (cobigen-javaplugin) + * mmm-code-java-maven/net.sf.m-m-m/1.0.0-beta6 (cobigen-javaplugin) + * mmm-code-java-parser/net.sf.m-m-m/1.0.0-beta6 (cobigen-javaplugin) + + are at least partly licensed via the following license of type Apache-2.0: + ++-------------------------------------------------------------------------------+ +| Apache License | +| Version 2.0, January 2004 | +| http://www.apache.org/licenses/ | +| | +| TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | +| | +| 1. Definitions. | +| | +| "License" shall mean the terms and conditions for use, reproduction, | +| and distribution as defined by Sections 1 through 9 of this document. | +| | +| "Licensor" shall mean the copyright owner or entity authorized by | +| the copyright owner that is granting the License. | +| | +| "Legal Entity" shall mean the union of the acting entity and all | +| other entities that control, are controlled by, or are under common | +| control with that entity. For the purposes of this definition, | +| "control" means (i) the power, direct or indirect, to cause the | +| direction or management of such entity, whether by contract or | +| otherwise, or (ii) ownership of fifty percent (50%) or more of the | +| outstanding shares, or (iii) beneficial ownership of such entity. | +| | +| "You" (or "Your") shall mean an individual or Legal Entity | +| exercising permissions granted by this License. | +| | +| "Source" form shall mean the preferred form for making modifications, | +| including but not limited to software source code, documentation | +| source, and configuration files. | +| | +| "Object" form shall mean any form resulting from mechanical | +| transformation or translation of a Source form, including but | +| not limited to compiled object code, generated documentation, | +| and conversions to other media types. | +| | +| "Work" shall mean the work of authorship, whether in Source or | +| Object form, made available under the License, as indicated by a | +| copyright notice that is included in or attached to the work | +| (an example is provided in the Appendix below). | +| | +| "Derivative Works" shall mean any work, whether in Source or Object | +| form, that is based on (or derived from) the Work and for which the | +| editorial revisions, annotations, elaborations, or other modifications | +| represent, as a whole, an original work of authorship. For the purposes | +| of this License, Derivative Works shall not include works that remain | +| separable from, or merely link (or bind by name) to the interfaces of, | +| the Work and Derivative Works thereof. | +| | +| "Contribution" shall mean any work of authorship, including | +| the original version of the Work and any modifications or additions | +| to that Work or Derivative Works thereof, that is intentionally | +| submitted to Licensor for inclusion in the Work by the copyright owner | +| or by an individual or Legal Entity authorized to submit on behalf of | +| the copyright owner. For the purposes of this definition, "submitted" | +| means any form of electronic, verbal, or written communication sent | +| to the Licensor or its representatives, including but not limited to | +| communication on electronic mailing lists, source code control systems, | +| and issue tracking systems that are managed by, or on behalf of, the | +| Licensor for the purpose of discussing and improving the Work, but | +| excluding communication that is conspicuously marked or otherwise | +| designated in writing by the copyright owner as "Not a Contribution." | +| | +| "Contributor" shall mean Licensor and any individual or Legal Entity | +| on behalf of whom a Contribution has been received by Licensor and | +| subsequently incorporated within the Work. | +| | +| 2. Grant of Copyright License. Subject to the terms and conditions of | +| this License, each Contributor hereby grants to You a perpetual, | +| worldwide, non-exclusive, no-charge, royalty-free, irrevocable | +| copyright license to reproduce, prepare Derivative Works of, | +| publicly display, publicly perform, sublicense, and distribute the | +| Work and such Derivative Works in Source or Object form. | +| | +| 3. Grant of Patent License. Subject to the terms and conditions of | +| this License, each Contributor hereby grants to You a perpetual, | +| worldwide, non-exclusive, no-charge, royalty-free, irrevocable | +| (except as stated in this section) patent license to make, have made, | +| use, offer to sell, sell, import, and otherwise transfer the Work, | +| where such license applies only to those patent claims licensable | +| by such Contributor that are necessarily infringed by their | +| Contribution(s) alone or by combination of their Contribution(s) | +| with the Work to which such Contribution(s) was submitted. If You | +| institute patent litigation against any entity (including a | +| cross-claim or counterclaim in a lawsuit) alleging that the Work | +| or a Contribution incorporated within the Work constitutes direct | +| or contributory patent infringement, then any patent licenses | +| granted to You under this License for that Work shall terminate | +| as of the date such litigation is filed. | +| | +| 4. Redistribution. You may reproduce and distribute copies of the | +| Work or Derivative Works thereof in any medium, with or without | +| modifications, and in Source or Object form, provided that You | +| meet the following conditions: | +| | +| (a) You must give any other recipients of the Work or | +| Derivative Works a copy of this License; and | +| | +| (b) You must cause any modified files to carry prominent notices | +| stating that You changed the files; and | +| | +| (c) You must retain, in the Source form of any Derivative Works | +| that You distribute, all copyright, patent, trademark, and | +| attribution notices from the Source form of the Work, | +| excluding those notices that do not pertain to any part of | +| the Derivative Works; and | +| | +| (d) If the Work includes a "NOTICE" text file as part of its | +| distribution, then any Derivative Works that You distribute must | +| include a readable copy of the attribution notices contained | +| within such NOTICE file, excluding those notices that do not | +| pertain to any part of the Derivative Works, in at least one | +| of the following places: within a NOTICE text file distributed | +| as part of the Derivative Works; within the Source form or | +| documentation, if provided along with the Derivative Works; or, | +| within a display generated by the Derivative Works, if and | +| wherever such third-party notices normally appear. The contents | +| of the NOTICE file are for informational purposes only and | +| do not modify the License. You may add Your own attribution | +| notices within Derivative Works that You distribute, alongside | +| or as an addendum to the NOTICE text from the Work, provided | +| that such additional attribution notices cannot be construed | +| as modifying the License. | +| | +| You may add Your own copyright statement to Your modifications and | +| may provide additional or different license terms and conditions | +| for use, reproduction, or distribution of Your modifications, or | +| for any such Derivative Works as a whole, provided Your use, | +| reproduction, and distribution of the Work otherwise complies with | +| the conditions stated in this License. | +| | +| 5. Submission of Contributions. Unless You explicitly state otherwise, | +| any Contribution intentionally submitted for inclusion in the Work | +| by You to the Licensor shall be under the terms and conditions of | +| this License, without any additional terms or conditions. | +| Notwithstanding the above, nothing herein shall supersede or modify | +| the terms of any separate license agreement you may have executed | +| with Licensor regarding such Contributions. | +| | +| 6. Trademarks. This License does not grant permission to use the trade | +| names, trademarks, service marks, or product names of the Licensor, | +| except as required for reasonable and customary use in describing the | +| origin of the Work and reproducing the content of the NOTICE file. | +| | +| 7. Disclaimer of Warranty. Unless required by applicable law or | +| agreed to in writing, Licensor provides the Work (and each | +| Contributor provides its Contributions) on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | +| implied, including, without limitation, any warranties or conditions | +| of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A | +| PARTICULAR PURPOSE. You are solely responsible for determining the | +| appropriateness of using or redistributing the Work and assume any | +| risks associated with Your exercise of permissions under this License. | +| | +| 8. Limitation of Liability. In no event and under no legal theory, | +| whether in tort (including negligence), contract, or otherwise, | +| unless required by applicable law (such as deliberate and grossly | +| negligent acts) or agreed to in writing, shall any Contributor be | +| liable to You for damages, including any direct, indirect, special, | +| incidental, or consequential damages of any character arising as a | +| result of this License or out of the use or inability to use the | +| Work (including but not limited to damages for loss of goodwill, | +| work stoppage, computer failure or malfunction, or any and all | +| other commercial damages or losses), even if such Contributor | +| has been advised of the possibility of such damages. | +| | +| 9. Accepting Warranty or Additional Liability. While redistributing | +| the Work or Derivative Works thereof, You may choose to offer, | +| and charge a fee for, acceptance of support, warranty, indemnity, | +| or other liability obligations and/or rights consistent with this | +| License. However, in accepting such obligations, You may act only | +| on Your own behalf and on Your sole responsibility, not on behalf | +| of any other Contributor, and only if You agree to indemnify, | +| defend, and hold each Contributor harmless for any liability | +| incurred by, or claims asserted against, such Contributor by reason | +| of your accepting any such warranty or additional liability. | +| | +| END OF TERMS AND CONDITIONS | +| | +| APPENDIX: How to apply the Apache License to your work. | +| | +| To apply the Apache License to your work, attach the following | +| boilerplate notice, with the fields enclosed by brackets "{}" | +| replaced with your own identifying information. (Don't include | +| the brackets!) The text should be enclosed in the appropriate | +| comment syntax for the file format. We also recommend that a | +| file or class name and description of purpose be included on the | +| same "printed page" as the copyright notice for easier | +| identification within third-party archives. | +| | +| Copyright {yyyy} {name of copyright owner} | +| | +| 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. | ++-------------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: https://raw.githubusercontent.com/m-m-m/code/master/LICENSE +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +Apache-2.0 +---------- + + The component(s) (Name/GroupId/Version): + + * java-sizeof/com.carrotsearch/0.0.5 (cobigen-maven, cobigen-eclipse, cobigen-cli) + * jackson-annotations/com.fasterxml.jackson.core/2.10.0 (cobigen-tsplugin, cobigen-openapiplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * jackson-core/com.fasterxml.jackson.core/2.10.0 (cobigen-tsplugin, cobigen-openapiplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * jackson-databind/com.fasterxml.jackson.core/2.10.0 (cobigen-tsplugin, cobigen-openapiplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * jackson-dataformat-yaml/com.fasterxml.jackson.dataformat/2.9.8 (cobigen-openapiplugin) + * lexeme/com.github.maybeec/2.0.0 (cobigen-xmlplugin) + * jsr305/com.google.code.findbugs/3.0.2 (cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli) + * gson/com.google.code.gson/2.8.6 (cobigen-tsplugin, cobigen-maven, cobigen-jsonplugin, cobigen-eclipse, cobigen-cli) + * error_prone_annotations/com.google.errorprone/2.5.1 (cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli) + * google-java-format/com.google.googlejavaformat/1.10.0 (cobigen-cli) + * failureaccess/com.google.guava/1.0.1 (cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli) + * guava/com.google.guava/30.1.1-jre (cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli) + * listenablefuture/com.google.guava/9999.0-empty-to-avoid-conflict-with-guava (cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli) + * j2objc-annotations/com.google.j2objc/1.3 (cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli) + * json-path/com.jayway.jsonpath/2.4.0 (cobigen-openapiplugin) + * okhttp/com.squareup.okhttp3/4.9.1 (cobigen-tsplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * okio/com.squareup.okio/2.8.0 (cobigen-tsplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * qdox/com.thoughtworks.qdox/2.0.0 (cobigen-javaplugin) + * commons-collections/commons-collections/3.2.1 (cobigen-tempeng-velocity) + * commons-io/commons-io/2.9.0 (cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-maven, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli) + * commons-jxpath/commons-jxpath/1.3 (cobigen-maven, cobigen-eclipse, cobigen-cli) + * commons-lang/commons-lang/2.4 (cobigen-tempeng-velocity) + * picocli/info.picocli/4.5.1 (cobigen-cli) + * javax.inject/javax.inject/1 (cobigen-maven, cobigen-javaplugin, cobigen-eclipse, cobigen-cli) + * orika-core/ma.glasnost.orika/1.5.4 (cobigen-maven, cobigen-eclipse, cobigen-cli) + * accessors-smart/net.minidev/1.2 (cobigen-openapiplugin) + * json-smart/net.minidev/2.3 (cobigen-openapiplugin) + * mmm-util-core/net.sf.m-m-m/7.4.0 (cobigen-maven, cobigen-javaplugin, cobigen-eclipse, cobigen-cli) + * mmm-util-io/net.sf.m-m-m/7.5.1 (cobigen-javaplugin) + * mmm-util-pojo/net.sf.m-m-m/7.5.1 (cobigen-javaplugin) + * ant/org.apache.ant/1.8.1 (cobigen-eclipse) + * ant-nodeps/org.apache.ant/1.8.1 (cobigen-eclipse) + * commons-compress/org.apache.commons/1.18 (cobigen-tsplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * commons-lang3/org.apache.commons/3.12.0 (cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli) + * commons-text/org.apache.commons/1.6 (cobigen-cli) + * maven-aether-provider/org.apache.maven/3.0 (cobigen-maven) + * maven-artifact/org.apache.maven/3.0 (cobigen-maven) + * maven-artifact/org.apache.maven/3.6.1 (cobigen-javaplugin) + * maven-builder-support/org.apache.maven/3.6.1 (cobigen-javaplugin) + * maven-compat/org.apache.maven/3.0 (cobigen-maven) + * maven-core/org.apache.maven/3.0 (cobigen-maven) + * maven-model/org.apache.maven/3.0 (cobigen-maven) + * maven-model/org.apache.maven/3.8.1, 3.6.1 (cobigen-javaplugin, cobigen-cli) + * maven-model-builder/org.apache.maven/3.0 (cobigen-maven) + * maven-model-builder/org.apache.maven/3.6.1 (cobigen-javaplugin) + * maven-plugin-api/org.apache.maven/3.0 (cobigen-maven) + * maven-repository-metadata/org.apache.maven/3.0 (cobigen-maven) + * maven-settings/org.apache.maven/3.0 (cobigen-maven) + * maven-settings-builder/org.apache.maven/3.0 (cobigen-maven) + * wagon-provider-api/org.apache.maven.wagon/1.0-beta-6 (cobigen-maven) + * velocity/org.apache.velocity/1.7 (cobigen-tempeng-velocity) + * plexus-classworlds/org.codehaus.plexus/2.2.3 (cobigen-maven) + * plexus-component-annotations/org.codehaus.plexus/1.7.1, 1.5.5 (cobigen-maven, cobigen-javaplugin) + * plexus-interpolation/org.codehaus.plexus/1.25, 1.14 (cobigen-maven, cobigen-javaplugin) + * plexus-utils/org.codehaus.plexus/3.2.1, 3.2.0, 2.0.4 (cobigen-maven, cobigen-javaplugin, cobigen-cli) + * freemarker/org.freemarker/2.3.29 (cobigen-tempeng-freemarker) + * javassist/org.javassist/3.24.0-GA (cobigen-maven, cobigen-eclipse, cobigen-cli) + * annotations/org.jetbrains/13.0 (cobigen-tsplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * kotlin-stdlib/org.jetbrains.kotlin/1.4.10 (cobigen-tsplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * kotlin-stdlib-common/org.jetbrains.kotlin/1.4.0 (cobigen-tsplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * jcl-over-slf4j/org.slf4j/1.7.30 (cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli) + * log4j-over-slf4j/org.slf4j/1.7.30 (cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli) + * aether-api/org.sonatype.aether/1.7 (cobigen-maven) + * aether-impl/org.sonatype.aether/1.7 (cobigen-maven) + * aether-spi/org.sonatype.aether/1.7 (cobigen-maven) + * aether-util/org.sonatype.aether/1.7 (cobigen-maven) + * plexus-cipher/org.sonatype.plexus/1.4 (cobigen-maven) + * plexus-sec-dispatcher/org.sonatype.plexus/1.3 (cobigen-maven) + * sisu-guice/org.sonatype.sisu/2.1.7 (cobigen-maven) + * sisu-inject-bean/org.sonatype.sisu/1.4.2 (cobigen-maven) + * sisu-inject-plexus/org.sonatype.sisu/1.4.2 (cobigen-maven) + * snakeyaml/org.yaml/1.23 (cobigen-openapiplugin) + * zt-exec/org.zeroturnaround/1.12 (cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli) + + are at least partly licensed via the following license of type Apache-2.0: + ++-------------------------------------------------------------------------------+ +| Apache License | +| Version 2.0, January 2004 | +| http://www.apache.org/licenses/ | +| | +| TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | +| | +| 1. Definitions. | +| | +| "License" shall mean the terms and conditions for use, reproduction, | +| and distribution as defined by Sections 1 through 9 of this document. | +| | +| "Licensor" shall mean the copyright owner or entity authorized by | +| the copyright owner that is granting the License. | +| | +| "Legal Entity" shall mean the union of the acting entity and all | +| other entities that control, are controlled by, or are under common | +| control with that entity. For the purposes of this definition, | +| "control" means (i) the power, direct or indirect, to cause the | +| direction or management of such entity, whether by contract or | +| otherwise, or (ii) ownership of fifty percent (50%) or more of the | +| outstanding shares, or (iii) beneficial ownership of such entity. | +| | +| "You" (or "Your") shall mean an individual or Legal Entity | +| exercising permissions granted by this License. | +| | +| "Source" form shall mean the preferred form for making modifications, | +| including but not limited to software source code, documentation | +| source, and configuration files. | +| | +| "Object" form shall mean any form resulting from mechanical | +| transformation or translation of a Source form, including but | +| not limited to compiled object code, generated documentation, | +| and conversions to other media types. | +| | +| "Work" shall mean the work of authorship, whether in Source or | +| Object form, made available under the License, as indicated by a | +| copyright notice that is included in or attached to the work | +| (an example is provided in the Appendix below). | +| | +| "Derivative Works" shall mean any work, whether in Source or Object | +| form, that is based on (or derived from) the Work and for which the | +| editorial revisions, annotations, elaborations, or other modifications | +| represent, as a whole, an original work of authorship. For the purposes | +| of this License, Derivative Works shall not include works that remain | +| separable from, or merely link (or bind by name) to the interfaces of, | +| the Work and Derivative Works thereof. | +| | +| "Contribution" shall mean any work of authorship, including | +| the original version of the Work and any modifications or additions | +| to that Work or Derivative Works thereof, that is intentionally | +| submitted to Licensor for inclusion in the Work by the copyright owner | +| or by an individual or Legal Entity authorized to submit on behalf of | +| the copyright owner. For the purposes of this definition, "submitted" | +| means any form of electronic, verbal, or written communication sent | +| to the Licensor or its representatives, including but not limited to | +| communication on electronic mailing lists, source code control systems, | +| and issue tracking systems that are managed by, or on behalf of, the | +| Licensor for the purpose of discussing and improving the Work, but | +| excluding communication that is conspicuously marked or otherwise | +| designated in writing by the copyright owner as "Not a Contribution." | +| | +| "Contributor" shall mean Licensor and any individual or Legal Entity | +| on behalf of whom a Contribution has been received by Licensor and | +| subsequently incorporated within the Work. | +| | +| 2. Grant of Copyright License. Subject to the terms and conditions of | +| this License, each Contributor hereby grants to You a perpetual, | +| worldwide, non-exclusive, no-charge, royalty-free, irrevocable | +| copyright license to reproduce, prepare Derivative Works of, | +| publicly display, publicly perform, sublicense, and distribute the | +| Work and such Derivative Works in Source or Object form. | +| | +| 3. Grant of Patent License. Subject to the terms and conditions of | +| this License, each Contributor hereby grants to You a perpetual, | +| worldwide, non-exclusive, no-charge, royalty-free, irrevocable | +| (except as stated in this section) patent license to make, have made, | +| use, offer to sell, sell, import, and otherwise transfer the Work, | +| where such license applies only to those patent claims licensable | +| by such Contributor that are necessarily infringed by their | +| Contribution(s) alone or by combination of their Contribution(s) | +| with the Work to which such Contribution(s) was submitted. If You | +| institute patent litigation against any entity (including a | +| cross-claim or counterclaim in a lawsuit) alleging that the Work | +| or a Contribution incorporated within the Work constitutes direct | +| or contributory patent infringement, then any patent licenses | +| granted to You under this License for that Work shall terminate | +| as of the date such litigation is filed. | +| | +| 4. Redistribution. You may reproduce and distribute copies of the | +| Work or Derivative Works thereof in any medium, with or without | +| modifications, and in Source or Object form, provided that You | +| meet the following conditions: | +| | +| (a) You must give any other recipients of the Work or | +| Derivative Works a copy of this License; and | +| | +| (b) You must cause any modified files to carry prominent notices | +| stating that You changed the files; and | +| | +| (c) You must retain, in the Source form of any Derivative Works | +| that You distribute, all copyright, patent, trademark, and | +| attribution notices from the Source form of the Work, | +| excluding those notices that do not pertain to any part of | +| the Derivative Works; and | +| | +| (d) If the Work includes a "NOTICE" text file as part of its | +| distribution, then any Derivative Works that You distribute must | +| include a readable copy of the attribution notices contained | +| within such NOTICE file, excluding those notices that do not | +| pertain to any part of the Derivative Works, in at least one | +| of the following places: within a NOTICE text file distributed | +| as part of the Derivative Works; within the Source form or | +| documentation, if provided along with the Derivative Works; or, | +| within a display generated by the Derivative Works, if and | +| wherever such third-party notices normally appear. The contents | +| of the NOTICE file are for informational purposes only and | +| do not modify the License. You may add Your own attribution | +| notices within Derivative Works that You distribute, alongside | +| or as an addendum to the NOTICE text from the Work, provided | +| that such additional attribution notices cannot be construed | +| as modifying the License. | +| | +| You may add Your own copyright statement to Your modifications and | +| may provide additional or different license terms and conditions | +| for use, reproduction, or distribution of Your modifications, or | +| for any such Derivative Works as a whole, provided Your use, | +| reproduction, and distribution of the Work otherwise complies with | +| the conditions stated in this License. | +| | +| 5. Submission of Contributions. Unless You explicitly state otherwise, | +| any Contribution intentionally submitted for inclusion in the Work | +| by You to the Licensor shall be under the terms and conditions of | +| this License, without any additional terms or conditions. | +| Notwithstanding the above, nothing herein shall supersede or modify | +| the terms of any separate license agreement you may have executed | +| with Licensor regarding such Contributions. | +| | +| 6. Trademarks. This License does not grant permission to use the trade | +| names, trademarks, service marks, or product names of the Licensor, | +| except as required for reasonable and customary use in describing the | +| origin of the Work and reproducing the content of the NOTICE file. | +| | +| 7. Disclaimer of Warranty. Unless required by applicable law or | +| agreed to in writing, Licensor provides the Work (and each | +| Contributor provides its Contributions) on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | +| implied, including, without limitation, any warranties or conditions | +| of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A | +| PARTICULAR PURPOSE. You are solely responsible for determining the | +| appropriateness of using or redistributing the Work and assume any | +| risks associated with Your exercise of permissions under this License. | +| | +| 8. Limitation of Liability. In no event and under no legal theory, | +| whether in tort (including negligence), contract, or otherwise, | +| unless required by applicable law (such as deliberate and grossly | +| negligent acts) or agreed to in writing, shall any Contributor be | +| liable to You for damages, including any direct, indirect, special, | +| incidental, or consequential damages of any character arising as a | +| result of this License or out of the use or inability to use the | +| Work (including but not limited to damages for loss of goodwill, | +| work stoppage, computer failure or malfunction, or any and all | +| other commercial damages or losses), even if such Contributor | +| has been advised of the possibility of such damages. | +| | +| 9. Accepting Warranty or Additional Liability. While redistributing | +| the Work or Derivative Works thereof, You may choose to offer, | +| and charge a fee for, acceptance of support, warranty, indemnity, | +| or other liability obligations and/or rights consistent with this | +| License. However, in accepting such obligations, You may act only | +| on Your own behalf and on Your sole responsibility, not on behalf | +| of any other Contributor, and only if You agree to indemnify, | +| defend, and hold each Contributor harmless for any liability | +| incurred by, or claims asserted against, such Contributor by reason | +| of your accepting any such warranty or additional liability. | +| | +| END OF TERMS AND CONDITIONS | +| | +| APPENDIX: How to apply the Apache License to your work. | +| | +| To apply the Apache License to your work, attach the following | +| boilerplate notice, with the fields enclosed by brackets "[]" | +| replaced with your own identifying information. (Don't include | +| the brackets!) The text should be enclosed in the appropriate | +| comment syntax for the file format. We also recommend that a | +| file or class name and description of purpose be included on the | +| same "printed page" as the copyright notice for easier | +| identification within third-party archives. | +| | +| Copyright [yyyy] [name of copyright owner] | +| | +| 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. | ++-------------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: https://www.apache.org/licenses/LICENSE-2.0.txt, http://www.apache.org/licenses/LICENSE-2.0.txt, http://www.apache.org/licenses/LICENSE-2.0.html, http://www.apache.org/licenses/LICENSE-2.0, http://www.apache.org/licenses/ +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +BSD-3-Clause +------------ + + The component(s) (Name/GroupId/Version): + + * asm/org.ow2.asm/5.0.4 (cobigen-openapiplugin) + + are at least partly licensed via the following license of type BSD-3-Clause: + ++------------------------------------------------------------------------------+ +| ASM: a very small and fast Java bytecode manipulation framework | +| Copyright (c) 2000-2011 INRIA, France Telecom | +| All rights reserved. | +| | +| Redistribution and use in source and binary forms, with or without | +| modification, are permitted provided that the following conditions | +| are met: | +| 1. Redistributions of source code must retain the above copyright | +| notice, this list of conditions and the following disclaimer. | +| 2. Redistributions in binary form must reproduce the above copyright | +| notice, this list of conditions and the following disclaimer in the | +| documentation and/or other materials provided with the distribution. | +| 3. Neither the name of the copyright holders nor the names of its | +| contributors may be used to endorse or promote products derived from | +| this software without specific prior written permission. | +| | +| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | +| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | +| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | +| ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | +| LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | +| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | +| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | +| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | +| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | +| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | +| THE POSSIBILITY OF SUCH DAMAGE. | ++------------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: https://gitlab.ow2.org/asm/asm/raw/ASM_5_0_4/LICENSE.txt +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +BSD-3-Clause +------------ + + The component(s) (Name/GroupId/Version): + + * commons-compiler/org.codehaus.janino/3.0.8 (cobigen-maven, cobigen-eclipse, cobigen-cli) + * janino/org.codehaus.janino/3.0.8 (cobigen-maven, cobigen-eclipse, cobigen-cli) + + are at least partly licensed via the following license of type BSD-3-Clause: + ++-----------------------------------------------------------------------------+ +| Janino - An embedded Java[TM] compiler | +| | +| Copyright (c) 2001-2016, Arno Unkrig | +| Copyright (c) 2015-2016 TIBCO Software Inc. | +| All rights reserved. | +| | +| Redistribution and use in source and binary forms, with or without | +| modification, are permitted provided that the following conditions | +| are met: | +| | +| 1. Redistributions of source code must retain the above copyright | +| notice, this list of conditions and the following disclaimer. | +| 2. Redistributions in binary form must reproduce the above | +| copyright notice, this list of conditions and the following | +| disclaimer in the documentation and/or other materials | +| provided with the distribution. | +| 3. Neither the name of JANINO nor the names of its contributors | +| may be used to endorse or promote products derived from this | +| software without specific prior written permission. | +| | +| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | +| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | +| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | +| ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | +| LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | +| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | +| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | +| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | +| IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | +| OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | +| IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ++-----------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: https://raw.githubusercontent.com/janino-compiler/janino/master/LICENSE +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +BSD-3-Clause +------------ + + The component(s) (Name/GroupId/Version): + + * jaxen/jaxen/1.2.0 (cobigen-xmlplugin, cobigen-tempeng-freemarker, cobigen-maven, cobigen-eclipse, cobigen-cli) + + are at least partly licensed via the following license of type BSD-3-Clause: + ++--------------------------------------------------------------------------+ +| /* | +| $Id$ | +| | +| Copyright 2003-2006 The Werken Company. All Rights Reserved. | +| | +| Redistribution and use in source and binary forms, with or without | +| modification, are permitted provided that the following conditions are | +| met: | +| | +| * Redistributions of source code must retain the above copyright | +| notice, this list of conditions and the following disclaimer. | +| | +| * Redistributions in binary form must reproduce the above copyright | +| notice, this list of conditions and the following disclaimer in the | +| documentation and/or other materials provided with the distribution. | +| | +| * Neither the name of the Jaxen Project nor the names of its | +| contributors may be used to endorse or promote products derived | +| from this software without specific prior written permission. | +| | +| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | +| IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | +| TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | +| PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | +| OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | +| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | +| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | +| PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | +| LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | +| NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | +| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | +| | +| */ | ++--------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: https://raw.githubusercontent.com/jaxen-xpath/jaxen/master/LICENSE.txt +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +BSD-3-Clause +------------ + + The component(s) (Name/GroupId/Version): + + * paranamer/com.thoughtworks.paranamer/2.8 (cobigen-maven, cobigen-eclipse, cobigen-cli) + + are at least partly licensed via the following license of type BSD-3-Clause: + ++-----------------------------------------------------------------------------------------------------------------------------+ +| [ ParaNamer used to be 'Pubic Domain', but since it includes a small piece of ASM it is now the same license as that: BSD ] | +| | +| Portions copyright (c) 2006-2018 Paul Hammant & ThoughtWorks Inc | +| Portions copyright (c) 2000-2007 INRIA, France Telecom | +| All rights reserved. | +| | +| Redistribution and use in source and binary forms, with or without | +| modification, are permitted provided that the following conditions | +| are met: | +| 1. Redistributions of source code must retain the above copyright | +| notice, this list of conditions and the following disclaimer. | +| 2. Redistributions in binary form must reproduce the above copyright | +| notice, this list of conditions and the following disclaimer in the | +| documentation and/or other materials provided with the distribution. | +| 3. Neither the name of the copyright holders nor the names of its | +| contributors may be used to endorse or promote products derived from | +| this software without specific prior written permission. | +| | +| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | +| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | +| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | +| ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | +| LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | +| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | +| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | +| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | +| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | +| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | +| THE POSSIBILITY OF SUCH DAMAGE. | ++-----------------------------------------------------------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: https://raw.githubusercontent.com/paul-hammant/paranamer/master/LICENSE.txt +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +BSD-3-Clause +------------ + + The component(s) (Name/GroupId/Version): + + * antlr4-runtime/org.antlr/4.7 (cobigen-javaplugin) + + are at least partly licensed via the following license of type BSD-3-Clause: + ++-----------------------------------------------------------------------------------+ +| ANTLR 4 License [The BSD License] Copyright (c) 2012 Terence Parr and Sam | +| Harwell All rights reserved. | +| | +| Redistribution and use in source and binary forms, with or without modification, | +| are permitted provided that the following conditions are met: | +| | +| Redistributions of source code must retain the above copyright notice, this | +| list of conditions and the following disclaimer. Redistributions in binary | +| form must reproduce the above copyright notice, this list of conditions and | +| the following disclaimer in the documentation and/or other materials | +| provided with the distribution. Neither the name of the author nor the names | +| of its contributors may be used to endorse or promote products derived from | +| this software without specific prior written permission. | +| | +| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | +| ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | +| WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | +| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | +| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | +| (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | +| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | +| ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | +| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | +| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | +| | +| Developer's Certificate of Origin | +| | +| All contributors to ANTLR v4 must formally agree to abide by the certificate of | +| origin by signing on the bottom of that document. To contribute: | +| | +| fork the ANTLR v4 github repository make your changes [first time | +| contributors]: sign contributors.txt by adding your github userid, full | +| name, email address (you can obscure your e- mail, but it must be computable | +| by human), and date. commit your changes send a pull request | +| | +| After you have signed once, you don't have to sign future pull requests. We can | +| merge by simply checking to see your name is in the contributors file. | ++-----------------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: https://www.antlr.org/license.html +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +EDL-1.0 +------- + + The component(s) (Name/GroupId/Version): + + * jakarta.activation/com.sun.activation/2.0.1 (cobigen-xmlplugin, cobigen-openapiplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * istack-commons-runtime/com.sun.istack/4.0.1 (cobigen-xmlplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * jaxb-core/com.sun.xml.bind/3.0.1 (cobigen-xmlplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * jaxb-impl/com.sun.xml.bind/3.0.1 (cobigen-xmlplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * jakarta.xml.bind-api/jakarta.xml.bind/3.0.1 (cobigen-xmlplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * jaxb-core/org.glassfish.jaxb/3.0.1 (cobigen-xmlplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + * txw2/org.glassfish.jaxb/3.0.1 (cobigen-xmlplugin, cobigen-maven, cobigen-eclipse, cobigen-cli) + + are at least partly licensed via the following license of type EDL-1.0: + ++-----------------------------------------------------------------------------------+ +| Eclipse Distribution License - v 1.0 | +| | +| Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors. | +| | +| All rights reserved. | +| | +| Redistribution and use in source and binary forms, with or without modification, | +| are permitted provided that the following conditions are met: | +| | +| Redistributions of source code must retain the above copyright notice, this | +| list of conditions and the following disclaimer. Redistributions in binary | +| form must reproduce the above copyright notice, this list of conditions and | +| the following disclaimer in the documentation and/or other materials | +| provided with the distribution. Neither the name of the Eclipse Foundation, | +| Inc. nor the names of its contributors may be used to endorse or promote | +| products derived from this software without specific prior written | +| permission. | +| | +| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | +| ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | +| WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | +| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | +| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | +| (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | +| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | +| ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | +| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | +| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ++-----------------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: http://www.eclipse.org/org/documents/edl-v10.php +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +EPL-2.0 +------- + + The component(s) (Name/GroupId/Version): + + * openapi-parser/com.github.maybeec/4.0.4 (cobigen-openapiplugin) + * jsonoverlay/com.reprezen.jsonoverlay/4.0.4 (cobigen-openapiplugin) + * jakarta.mail/com.sun.mail/2.0.1 (cobigen-openapiplugin) + * jakarta.annotation-api/jakarta.annotation/2.0.0 (cobigen-openapiplugin) + * jakarta.mail-api/jakarta.mail/2.0.1 (cobigen-openapiplugin) + + are at least partly licensed via the following license of type EPL-2.0: + ++----------------------------------------------------------------------------+ +| Eclipse Public License - v 2.0 | +| | +| THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE | +| PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION | +| OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. | +| | +| 1. DEFINITIONS | +| | +| "Contribution" means: | +| | +| a) in the case of the initial Contributor, the initial content | +| Distributed under this Agreement, and | +| | +| b) in the case of each subsequent Contributor: | +| i) changes to the Program, and | +| ii) additions to the Program; | +| where such changes and/or additions to the Program originate from | +| and are Distributed by that particular Contributor. A Contribution | +| "originates" from a Contributor if it was added to the Program by | +| such Contributor itself or anyone acting on such Contributor's behalf. | +| Contributions do not include changes or additions to the Program that | +| are not Modified Works. | +| | +| "Contributor" means any person or entity that Distributes the Program. | +| | +| "Licensed Patents" mean patent claims licensable by a Contributor which | +| are necessarily infringed by the use or sale of its Contribution alone | +| or when combined with the Program. | +| | +| "Program" means the Contributions Distributed in accordance with this | +| Agreement. | +| | +| "Recipient" means anyone who receives the Program under this Agreement | +| or any Secondary License (as applicable), including Contributors. | +| | +| "Derivative Works" shall mean any work, whether in Source Code or other | +| form, that is based on (or derived from) the Program and for which the | +| editorial revisions, annotations, elaborations, or other modifications | +| represent, as a whole, an original work of authorship. | +| | +| "Modified Works" shall mean any work in Source Code or other form that | +| results from an addition to, deletion from, or modification of the | +| contents of the Program, including, for purposes of clarity any new file | +| in Source Code form that contains any contents of the Program. Modified | +| Works shall not include works that contain only declarations, | +| interfaces, types, classes, structures, or files of the Program solely | +| in each case in order to link to, bind by name, or subclass the Program | +| or Modified Works thereof. | +| | +| "Distribute" means the acts of a) distributing or b) making available | +| in any manner that enables the transfer of a copy. | +| | +| "Source Code" means the form of a Program preferred for making | +| modifications, including but not limited to software source code, | +| documentation source, and configuration files. | +| | +| "Secondary License" means either the GNU General Public License, | +| Version 2.0, or any later versions of that license, including any | +| exceptions or additional permissions as identified by the initial | +| Contributor. | +| | +| 2. GRANT OF RIGHTS | +| | +| a) Subject to the terms of this Agreement, each Contributor hereby | +| grants Recipient a non-exclusive, worldwide, royalty-free copyright | +| license to reproduce, prepare Derivative Works of, publicly display, | +| publicly perform, Distribute and sublicense the Contribution of such | +| Contributor, if any, and such Derivative Works. | +| | +| b) Subject to the terms of this Agreement, each Contributor hereby | +| grants Recipient a non-exclusive, worldwide, royalty-free patent | +| license under Licensed Patents to make, use, sell, offer to sell, | +| import and otherwise transfer the Contribution of such Contributor, | +| if any, in Source Code or other form. This patent license shall | +| apply to the combination of the Contribution and the Program if, at | +| the time the Contribution is added by the Contributor, such addition | +| of the Contribution causes such combination to be covered by the | +| Licensed Patents. The patent license shall not apply to any other | +| combinations which include the Contribution. No hardware per se is | +| licensed hereunder. | +| | +| c) Recipient understands that although each Contributor grants the | +| licenses to its Contributions set forth herein, no assurances are | +| provided by any Contributor that the Program does not infringe the | +| patent or other intellectual property rights of any other entity. | +| Each Contributor disclaims any liability to Recipient for claims | +| brought by any other entity based on infringement of intellectual | +| property rights or otherwise. As a condition to exercising the | +| rights and licenses granted hereunder, each Recipient hereby | +| assumes sole responsibility to secure any other intellectual | +| property rights needed, if any. For example, if a third party | +| patent license is required to allow Recipient to Distribute the | +| Program, it is Recipient's responsibility to acquire that license | +| before distributing the Program. | +| | +| d) Each Contributor represents that to its knowledge it has | +| sufficient copyright rights in its Contribution, if any, to grant | +| the copyright license set forth in this Agreement. | +| | +| e) Notwithstanding the terms of any Secondary License, no | +| Contributor makes additional grants to any Recipient (other than | +| those set forth in this Agreement) as a result of such Recipient's | +| receipt of the Program under the terms of a Secondary License | +| (if permitted under the terms of Section 3). | +| | +| 3. REQUIREMENTS | +| | +| 3.1 If a Contributor Distributes the Program in any form, then: | +| | +| a) the Program must also be made available as Source Code, in | +| accordance with section 3.2, and the Contributor must accompany | +| the Program with a statement that the Source Code for the Program | +| is available under this Agreement, and informs Recipients how to | +| obtain it in a reasonable manner on or through a medium customarily | +| used for software exchange; and | +| | +| b) the Contributor may Distribute the Program under a license | +| different than this Agreement, provided that such license: | +| i) effectively disclaims on behalf of all other Contributors all | +| warranties and conditions, express and implied, including | +| warranties or conditions of title and non-infringement, and | +| implied warranties or conditions of merchantability and fitness | +| for a particular purpose; | +| | +| ii) effectively excludes on behalf of all other Contributors all | +| liability for damages, including direct, indirect, special, | +| incidental and consequential damages, such as lost profits; | +| | +| iii) does not attempt to limit or alter the recipients' rights | +| in the Source Code under section 3.2; and | +| | +| iv) requires any subsequent distribution of the Program by any | +| party to be under a license that satisfies the requirements | +| of this section 3. | +| | +| 3.2 When the Program is Distributed as Source Code: | +| | +| a) it must be made available under this Agreement, or if the | +| Program (i) is combined with other material in a separate file or | +| files made available under a Secondary License, and (ii) the initial | +| Contributor attached to the Source Code the notice described in | +| Exhibit A of this Agreement, then the Program may be made available | +| under the terms of such Secondary Licenses, and | +| | +| b) a copy of this Agreement must be included with each copy of | +| the Program. | +| | +| 3.3 Contributors may not remove or alter any copyright, patent, | +| trademark, attribution notices, disclaimers of warranty, or limitations | +| of liability ("notices") contained within the Program from any copy of | +| the Program which they Distribute, provided that Contributors may add | +| their own appropriate notices. | +| | +| 4. COMMERCIAL DISTRIBUTION | +| | +| Commercial distributors of software may accept certain responsibilities | +| with respect to end users, business partners and the like. While this | +| license is intended to facilitate the commercial use of the Program, | +| the Contributor who includes the Program in a commercial product | +| offering should do so in a manner which does not create potential | +| liability for other Contributors. Therefore, if a Contributor includes | +| the Program in a commercial product offering, such Contributor | +| ("Commercial Contributor") hereby agrees to defend and indemnify every | +| other Contributor ("Indemnified Contributor") against any losses, | +| damages and costs (collectively "Losses") arising from claims, lawsuits | +| and other legal actions brought by a third party against the Indemnified | +| Contributor to the extent caused by the acts or omissions of such | +| Commercial Contributor in connection with its distribution of the Program | +| in a commercial product offering. The obligations in this section do not | +| apply to any claims or Losses relating to any actual or alleged | +| intellectual property infringement. In order to qualify, an Indemnified | +| Contributor must: a) promptly notify the Commercial Contributor in | +| writing of such claim, and b) allow the Commercial Contributor to control, | +| and cooperate with the Commercial Contributor in, the defense and any | +| related settlement negotiations. The Indemnified Contributor may | +| participate in any such claim at its own expense. | +| | +| For example, a Contributor might include the Program in a commercial | +| product offering, Product X. That Contributor is then a Commercial | +| Contributor. If that Commercial Contributor then makes performance | +| claims, or offers warranties related to Product X, those performance | +| claims and warranties are such Commercial Contributor's responsibility | +| alone. Under this section, the Commercial Contributor would have to | +| defend claims against the other Contributors related to those performance | +| claims and warranties, and if a court requires any other Contributor to | +| pay any damages as a result, the Commercial Contributor must pay | +| those damages. | +| | +| 5. NO WARRANTY | +| | +| EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT | +| PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" | +| BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR | +| IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF | +| TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR | +| PURPOSE. Each Recipient is solely responsible for determining the | +| appropriateness of using and distributing the Program and assumes all | +| risks associated with its exercise of rights under this Agreement, | +| including but not limited to the risks and costs of program errors, | +| compliance with applicable laws, damage to or loss of data, programs | +| or equipment, and unavailability or interruption of operations. | +| | +| 6. DISCLAIMER OF LIABILITY | +| | +| EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT | +| PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS | +| SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | +| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST | +| PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | +| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | +| ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE | +| EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE | +| POSSIBILITY OF SUCH DAMAGES. | +| | +| 7. GENERAL | +| | +| If any provision of this Agreement is invalid or unenforceable under | +| applicable law, it shall not affect the validity or enforceability of | +| the remainder of the terms of this Agreement, and without further | +| action by the parties hereto, such provision shall be reformed to the | +| minimum extent necessary to make such provision valid and enforceable. | +| | +| If Recipient institutes patent litigation against any entity | +| (including a cross-claim or counterclaim in a lawsuit) alleging that the | +| Program itself (excluding combinations of the Program with other software | +| or hardware) infringes such Recipient's patent(s), then such Recipient's | +| rights granted under Section 2(b) shall terminate as of the date such | +| litigation is filed. | +| | +| All Recipient's rights under this Agreement shall terminate if it | +| fails to comply with any of the material terms or conditions of this | +| Agreement and does not cure such failure in a reasonable period of | +| time after becoming aware of such noncompliance. If all Recipient's | +| rights under this Agreement terminate, Recipient agrees to cease use | +| and distribution of the Program as soon as reasonably practicable. | +| However, Recipient's obligations under this Agreement and any licenses | +| granted by Recipient relating to the Program shall continue and survive. | +| | +| Everyone is permitted to copy and distribute copies of this Agreement, | +| but in order to avoid inconsistency the Agreement is copyrighted and | +| may only be modified in the following manner. The Agreement Steward | +| reserves the right to publish new versions (including revisions) of | +| this Agreement from time to time. No one other than the Agreement | +| Steward has the right to modify this Agreement. The Eclipse Foundation | +| is the initial Agreement Steward. The Eclipse Foundation may assign the | +| responsibility to serve as the Agreement Steward to a suitable separate | +| entity. Each new version of the Agreement will be given a distinguishing | +| version number. The Program (including Contributions) may always be | +| Distributed subject to the version of the Agreement under which it was | +| received. In addition, after a new version of the Agreement is published, | +| Contributor may elect to Distribute the Program (including its | +| Contributions) under the new version. | +| | +| Except as expressly stated in Sections 2(a) and 2(b) above, Recipient | +| receives no rights or licenses to the intellectual property of any | +| Contributor under this Agreement, whether expressly, by implication, | +| estoppel or otherwise. All rights in the Program not expressly granted | +| under this Agreement are reserved. Nothing in this Agreement is intended | +| to be enforceable by any entity that is not a Contributor or Recipient. | +| No third-party beneficiary rights are created under this Agreement. | +| | +| Exhibit A - Form of Secondary Licenses Notice | +| | +| "This Source Code may also be made available under the following | +| Secondary Licenses when the conditions for such availability set forth | +| in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), | +| version(s), and exceptions or additional permissions here}." | +| | +| Simply including a copy of this Agreement, including this Exhibit A | +| is not sufficient to license the Source Code under Secondary Licenses. | +| | +| If it is not possible or desirable to put the notice in a particular | +| file, then You may include the notice in a location (such as a LICENSE | +| file in a relevant directory) where a recipient would be likely to | +| look for such a notice. | +| | +| You may add additional accurate notices of copyright ownership. | ++----------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +JDOM +---- + + The component(s) (Name/GroupId/Version): + + * jdom2/org.jdom/2.0.6 (cobigen-xmlplugin) + + are at least partly licensed via the following license of type JDOM: + ++-------------------------------------------------------------------------+ +| /*-- | +| | +| Copyright (C) 2000-2012 Jason Hunter & Brett McLaughlin. | +| All rights reserved. | +| | +| Redistribution and use in source and binary forms, with or without | +| modification, are permitted provided that the following conditions | +| are met: | +| | +| 1. Redistributions of source code must retain the above copyright | +| notice, this list of conditions, and the following disclaimer. | +| | +| 2. Redistributions in binary form must reproduce the above copyright | +| notice, this list of conditions, and the disclaimer that follows | +| these conditions in the documentation and/or other materials | +| provided with the distribution. | +| | +| 3. The name "JDOM" must not be used to endorse or promote products | +| derived from this software without prior written permission. For | +| written permission, please contact . | +| | +| 4. Products derived from this software may not be called "JDOM", nor | +| may "JDOM" appear in their name, without prior written permission | +| from the JDOM Project Management . | +| | +| In addition, we request (but do not require) that you include in the | +| end-user documentation provided with the redistribution and/or in the | +| software itself an acknowledgement equivalent to the following: | +| "This product includes software developed by the | +| JDOM Project (http://www.jdom.org/)." | +| Alternatively, the acknowledgment may be graphical using the logos | +| available at http://www.jdom.org/images/logos. | +| | +| THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | +| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | +| OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | +| DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT | +| CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | +| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | +| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | +| USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | +| ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | +| OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | +| OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | +| SUCH DAMAGE. | +| | +| This software consists of voluntary contributions made by many | +| individuals on behalf of the JDOM Project and was originally | +| created by Jason Hunter and | +| Brett McLaughlin . For more information | +| on the JDOM Project, please see . | +| | +| */ | ++-------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: https://raw.github.com/hunterhacker/jdom/master/LICENSE.txt +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +JSON +---- + + The component(s) (Name/GroupId/Version): + + * json/org.json/20180813 (cobigen-tsplugin) + + are at least partly licensed via the following license of type JSON: + ++--------------------------------------------------------------------------------+ +| Copyright (c) 2002 JSON.org | +| | +| Permission is hereby granted, free of charge, to any person obtaining a copy | +| of this software and associated documentation files (the "Software"), to deal | +| in the Software without restriction, including without limitation the rights | +| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | +| copies of the Software, and to permit persons to whom the Software is | +| furnished to do so, subject to the following conditions: | +| | +| The above copyright notice and this permission notice shall be included in all | +| copies or substantial portions of the Software. | +| | +| The Software shall be used for Good, not Evil. | +| | +| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | +| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | +| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | +| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | +| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | +| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | +| SOFTWARE. | ++--------------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: https://raw.githubusercontent.com/stleary/JSON-java/master/LICENSE +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +LGPL-2.1 +-------- + + The component(s) (Name/GroupId/Version): + + * logback-classic/ch.qos.logback/1.2.3 (cobigen-eclipse, cobigen-cli) + * logback-core/ch.qos.logback/1.2.3 (cobigen-eclipse, cobigen-cli) + + are at least partly licensed via the following license of type LGPL-2.1: + ++------------------------------------------------------------------------------------+ +| GNU LESSER GENERAL PUBLIC LICENSE | +| Version 2.1, February 1999 | +| | +| Copyright (C) 1991, 1999 Free Software Foundation, Inc. | +| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | +| Everyone is permitted to copy and distribute verbatim copies | +| of this license document, but changing it is not allowed. | +| | +| [This is the first released version of the Lesser GPL. It also counts | +| as the successor of the GNU Library Public License, version 2, hence | +| the version number 2.1.] | +| | +| Preamble | +| | +| The licenses for most software are designed to take away your | +| freedom to share and change it. By contrast, the GNU General Public | +| Licenses are intended to guarantee your freedom to share and change | +| free software--to make sure the software is free for all its users. | +| | +| This license, the Lesser General Public License, applies to some | +| specially designated software packages--typically libraries--of the | +| Free Software Foundation and other authors who decide to use it. You | +| can use it too, but we suggest you first think carefully about whether | +| this license or the ordinary General Public License is the better | +| strategy to use in any particular case, based on the explanations below. | +| | +| When we speak of free software, we are referring to freedom of use, | +| not price. Our General Public Licenses are designed to make sure that | +| you have the freedom to distribute copies of free software (and charge | +| for this service if you wish); that you receive source code or can get | +| it if you want it; that you can change the software and use pieces of | +| it in new free programs; and that you are informed that you can do | +| these things. | +| | +| To protect your rights, we need to make restrictions that forbid | +| distributors to deny you these rights or to ask you to surrender these | +| rights. These restrictions translate to certain responsibilities for | +| you if you distribute copies of the library or if you modify it. | +| | +| For example, if you distribute copies of the library, whether gratis | +| or for a fee, you must give the recipients all the rights that we gave | +| you. You must make sure that they, too, receive or can get the source | +| code. If you link other code with the library, you must provide | +| complete object files to the recipients, so that they can relink them | +| with the library after making changes to the library and recompiling | +| it. And you must show them these terms so they know their rights. | +| | +| We protect your rights with a two-step method: (1) we copyright the | +| library, and (2) we offer you this license, which gives you legal | +| permission to copy, distribute and/or modify the library. | +| | +| To protect each distributor, we want to make it very clear that | +| there is no warranty for the free library. Also, if the library is | +| modified by someone else and passed on, the recipients should know | +| that what they have is not the original version, so that the original | +| author's reputation will not be affected by problems that might be | +| introduced by others. | +| | +| Finally, software patents pose a constant threat to the existence of | +| any free program. We wish to make sure that a company cannot | +| effectively restrict the users of a free program by obtaining a | +| restrictive license from a patent holder. Therefore, we insist that | +| any patent license obtained for a version of the library must be | +| consistent with the full freedom of use specified in this license. | +| | +| Most GNU software, including some libraries, is covered by the | +| ordinary GNU General Public License. This license, the GNU Lesser | +| General Public License, applies to certain designated libraries, and | +| is quite different from the ordinary General Public License. We use | +| this license for certain libraries in order to permit linking those | +| libraries into non-free programs. | +| | +| When a program is linked with a library, whether statically or using | +| a shared library, the combination of the two is legally speaking a | +| combined work, a derivative of the original library. The ordinary | +| General Public License therefore permits such linking only if the | +| entire combination fits its criteria of freedom. The Lesser General | +| Public License permits more lax criteria for linking other code with | +| the library. | +| | +| We call this license the "Lesser" General Public License because it | +| does Less to protect the user's freedom than the ordinary General | +| Public License. It also provides other free software developers Less | +| of an advantage over competing non-free programs. These disadvantages | +| are the reason we use the ordinary General Public License for many | +| libraries. However, the Lesser license provides advantages in certain | +| special circumstances. | +| | +| For example, on rare occasions, there may be a special need to | +| encourage the widest possible use of a certain library, so that it becomes | +| a de-facto standard. To achieve this, non-free programs must be | +| allowed to use the library. A more frequent case is that a free | +| library does the same job as widely used non-free libraries. In this | +| case, there is little to gain by limiting the free library to free | +| software only, so we use the Lesser General Public License. | +| | +| In other cases, permission to use a particular library in non-free | +| programs enables a greater number of people to use a large body of | +| free software. For example, permission to use the GNU C Library in | +| non-free programs enables many more people to use the whole GNU | +| operating system, as well as its variant, the GNU/Linux operating | +| system. | +| | +| Although the Lesser General Public License is Less protective of the | +| users' freedom, it does ensure that the user of a program that is | +| linked with the Library has the freedom and the wherewithal to run | +| that program using a modified version of the Library. | +| | +| The precise terms and conditions for copying, distribution and | +| modification follow. Pay close attention to the difference between a | +| "work based on the library" and a "work that uses the library". The | +| former contains code derived from the library, whereas the latter must | +| be combined with the library in order to run. | +| | +| GNU LESSER GENERAL PUBLIC LICENSE | +| TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | +| | +| 0. This License Agreement applies to any software library or other | +| program which contains a notice placed by the copyright holder or | +| other authorized party saying it may be distributed under the terms of | +| this Lesser General Public License (also called "this License"). | +| Each licensee is addressed as "you". | +| | +| A "library" means a collection of software functions and/or data | +| prepared so as to be conveniently linked with application programs | +| (which use some of those functions and data) to form executables. | +| | +| The "Library", below, refers to any such software library or work | +| which has been distributed under these terms. A "work based on the | +| Library" means either the Library or any derivative work under | +| copyright law: that is to say, a work containing the Library or a | +| portion of it, either verbatim or with modifications and/or translated | +| straightforwardly into another language. (Hereinafter, translation is | +| included without limitation in the term "modification".) | +| | +| "Source code" for a work means the preferred form of the work for | +| making modifications to it. For a library, complete source code means | +| all the source code for all modules it contains, plus any associated | +| interface definition files, plus the scripts used to control compilation | +| and installation of the library. | +| | +| Activities other than copying, distribution and modification are not | +| covered by this License; they are outside its scope. The act of | +| running a program using the Library is not restricted, and output from | +| such a program is covered only if its contents constitute a work based | +| on the Library (independent of the use of the Library in a tool for | +| writing it). Whether that is true depends on what the Library does | +| and what the program that uses the Library does. | +| | +| 1. You may copy and distribute verbatim copies of the Library's | +| complete source code as you receive it, in any medium, provided that | +| you conspicuously and appropriately publish on each copy an | +| appropriate copyright notice and disclaimer of warranty; keep intact | +| all the notices that refer to this License and to the absence of any | +| warranty; and distribute a copy of this License along with the | +| Library. | +| | +| You may charge a fee for the physical act of transferring a copy, | +| and you may at your option offer warranty protection in exchange for a | +| fee. | +| | +| 2. You may modify your copy or copies of the Library or any portion | +| of it, thus forming a work based on the Library, and copy and | +| distribute such modifications or work under the terms of Section 1 | +| above, provided that you also meet all of these conditions: | +| | +| a) The modified work must itself be a software library. | +| | +| b) You must cause the files modified to carry prominent notices | +| stating that you changed the files and the date of any change. | +| | +| c) You must cause the whole of the work to be licensed at no | +| charge to all third parties under the terms of this License. | +| | +| d) If a facility in the modified Library refers to a function or a | +| table of data to be supplied by an application program that uses | +| the facility, other than as an argument passed when the facility | +| is invoked, then you must make a good faith effort to ensure that, | +| in the event an application does not supply such function or | +| table, the facility still operates, and performs whatever part of | +| its purpose remains meaningful. | +| | +| (For example, a function in a library to compute square roots has | +| a purpose that is entirely well-defined independent of the | +| application. Therefore, Subsection 2d requires that any | +| application-supplied function or table used by this function must | +| be optional: if the application does not supply it, the square | +| root function must still compute square roots.) | +| | +| These requirements apply to the modified work as a whole. If | +| identifiable sections of that work are not derived from the Library, | +| and can be reasonably considered independent and separate works in | +| themselves, then this License, and its terms, do not apply to those | +| sections when you distribute them as separate works. But when you | +| distribute the same sections as part of a whole which is a work based | +| on the Library, the distribution of the whole must be on the terms of | +| this License, whose permissions for other licensees extend to the | +| entire whole, and thus to each and every part regardless of who wrote | +| it. | +| | +| Thus, it is not the intent of this section to claim rights or contest | +| your rights to work written entirely by you; rather, the intent is to | +| exercise the right to control the distribution of derivative or | +| collective works based on the Library. | +| | +| In addition, mere aggregation of another work not based on the Library | +| with the Library (or with a work based on the Library) on a volume of | +| a storage or distribution medium does not bring the other work under | +| the scope of this License. | +| | +| 3. You may opt to apply the terms of the ordinary GNU General Public | +| License instead of this License to a given copy of the Library. To do | +| this, you must alter all the notices that refer to this License, so | +| that they refer to the ordinary GNU General Public License, version 2, | +| instead of to this License. (If a newer version than version 2 of the | +| ordinary GNU General Public License has appeared, then you can specify | +| that version instead if you wish.) Do not make any other change in | +| these notices. | +| | +| Once this change is made in a given copy, it is irreversible for | +| that copy, so the ordinary GNU General Public License applies to all | +| subsequent copies and derivative works made from that copy. | +| | +| This option is useful when you wish to copy part of the code of | +| the Library into a program that is not a library. | +| | +| 4. You may copy and distribute the Library (or a portion or | +| derivative of it, under Section 2) in object code or executable form | +| under the terms of Sections 1 and 2 above provided that you accompany | +| it with the complete corresponding machine-readable source code, which | +| must be distributed under the terms of Sections 1 and 2 above on a | +| medium customarily used for software interchange. | +| | +| If distribution of object code is made by offering access to copy | +| from a designated place, then offering equivalent access to copy the | +| source code from the same place satisfies the requirement to | +| distribute the source code, even though third parties are not | +| compelled to copy the source along with the object code. | +| | +| 5. A program that contains no derivative of any portion of the | +| Library, but is designed to work with the Library by being compiled or | +| linked with it, is called a "work that uses the Library". Such a | +| work, in isolation, is not a derivative work of the Library, and | +| therefore falls outside the scope of this License. | +| | +| However, linking a "work that uses the Library" with the Library | +| creates an executable that is a derivative of the Library (because it | +| contains portions of the Library), rather than a "work that uses the | +| library". The executable is therefore covered by this License. | +| Section 6 states terms for distribution of such executables. | +| | +| When a "work that uses the Library" uses material from a header file | +| that is part of the Library, the object code for the work may be a | +| derivative work of the Library even though the source code is not. | +| Whether this is true is especially significant if the work can be | +| linked without the Library, or if the work is itself a library. The | +| threshold for this to be true is not precisely defined by law. | +| | +| If such an object file uses only numerical parameters, data | +| structure layouts and accessors, and small macros and small inline | +| functions (ten lines or less in length), then the use of the object | +| file is unrestricted, regardless of whether it is legally a derivative | +| work. (Executables containing this object code plus portions of the | +| Library will still fall under Section 6.) | +| | +| Otherwise, if the work is a derivative of the Library, you may | +| distribute the object code for the work under the terms of Section 6. | +| Any executables containing that work also fall under Section 6, | +| whether or not they are linked directly with the Library itself. | +| | +| 6. As an exception to the Sections above, you may also combine or | +| link a "work that uses the Library" with the Library to produce a | +| work containing portions of the Library, and distribute that work | +| under terms of your choice, provided that the terms permit | +| modification of the work for the customer's own use and reverse | +| engineering for debugging such modifications. | +| | +| You must give prominent notice with each copy of the work that the | +| Library is used in it and that the Library and its use are covered by | +| this License. You must supply a copy of this License. If the work | +| during execution displays copyright notices, you must include the | +| copyright notice for the Library among them, as well as a reference | +| directing the user to the copy of this License. Also, you must do one | +| of these things: | +| | +| a) Accompany the work with the complete corresponding | +| machine-readable source code for the Library including whatever | +| changes were used in the work (which must be distributed under | +| Sections 1 and 2 above); and, if the work is an executable linked | +| with the Library, with the complete machine-readable "work that | +| uses the Library", as object code and/or source code, so that the | +| user can modify the Library and then relink to produce a modified | +| executable containing the modified Library. (It is understood | +| that the user who changes the contents of definitions files in the | +| Library will not necessarily be able to recompile the application | +| to use the modified definitions.) | +| | +| b) Use a suitable shared library mechanism for linking with the | +| Library. A suitable mechanism is one that (1) uses at run time a | +| copy of the library already present on the user's computer system, | +| rather than copying library functions into the executable, and (2) | +| will operate properly with a modified version of the library, if | +| the user installs one, as long as the modified version is | +| interface-compatible with the version that the work was made with. | +| | +| c) Accompany the work with a written offer, valid for at | +| least three years, to give the same user the materials | +| specified in Subsection 6a, above, for a charge no more | +| than the cost of performing this distribution. | +| | +| d) If distribution of the work is made by offering access to copy | +| from a designated place, offer equivalent access to copy the above | +| specified materials from the same place. | +| | +| e) Verify that the user has already received a copy of these | +| materials or that you have already sent this user a copy. | +| | +| For an executable, the required form of the "work that uses the | +| Library" must include any data and utility programs needed for | +| reproducing the executable from it. However, as a special exception, | +| the materials to be distributed need not include anything that is | +| normally distributed (in either source or binary form) with the major | +| components (compiler, kernel, and so on) of the operating system on | +| which the executable runs, unless that component itself accompanies | +| the executable. | +| | +| It may happen that this requirement contradicts the license | +| restrictions of other proprietary libraries that do not normally | +| accompany the operating system. Such a contradiction means you cannot | +| use both them and the Library together in an executable that you | +| distribute. | +| | +| 7. You may place library facilities that are a work based on the | +| Library side-by-side in a single library together with other library | +| facilities not covered by this License, and distribute such a combined | +| library, provided that the separate distribution of the work based on | +| the Library and of the other library facilities is otherwise | +| permitted, and provided that you do these two things: | +| | +| a) Accompany the combined library with a copy of the same work | +| based on the Library, uncombined with any other library | +| facilities. This must be distributed under the terms of the | +| Sections above. | +| | +| b) Give prominent notice with the combined library of the fact | +| that part of it is a work based on the Library, and explaining | +| where to find the accompanying uncombined form of the same work. | +| | +| 8. You may not copy, modify, sublicense, link with, or distribute | +| the Library except as expressly provided under this License. Any | +| attempt otherwise to copy, modify, sublicense, link with, or | +| distribute the Library is void, and will automatically terminate your | +| rights under this License. However, parties who have received copies, | +| or rights, from you under this License will not have their licenses | +| terminated so long as such parties remain in full compliance. | +| | +| 9. You are not required to accept this License, since you have not | +| signed it. However, nothing else grants you permission to modify or | +| distribute the Library or its derivative works. These actions are | +| prohibited by law if you do not accept this License. Therefore, by | +| modifying or distributing the Library (or any work based on the | +| Library), you indicate your acceptance of this License to do so, and | +| all its terms and conditions for copying, distributing or modifying | +| the Library or works based on it. | +| | +| 10. Each time you redistribute the Library (or any work based on the | +| Library), the recipient automatically receives a license from the | +| original licensor to copy, distribute, link with or modify the Library | +| subject to these terms and conditions. You may not impose any further | +| restrictions on the recipients' exercise of the rights granted herein. | +| You are not responsible for enforcing compliance by third parties with | +| this License. | +| | +| 11. If, as a consequence of a court judgment or allegation of patent | +| infringement or for any other reason (not limited to patent issues), | +| conditions are imposed on you (whether by court order, agreement or | +| otherwise) that contradict the conditions of this License, they do not | +| excuse you from the conditions of this License. If you cannot | +| distribute so as to satisfy simultaneously your obligations under this | +| License and any other pertinent obligations, then as a consequence you | +| may not distribute the Library at all. For example, if a patent | +| license would not permit royalty-free redistribution of the Library by | +| all those who receive copies directly or indirectly through you, then | +| the only way you could satisfy both it and this License would be to | +| refrain entirely from distribution of the Library. | +| | +| If any portion of this section is held invalid or unenforceable under any | +| particular circumstance, the balance of the section is intended to apply, | +| and the section as a whole is intended to apply in other circumstances. | +| | +| It is not the purpose of this section to induce you to infringe any | +| patents or other property right claims or to contest validity of any | +| such claims; this section has the sole purpose of protecting the | +| integrity of the free software distribution system which is | +| implemented by public license practices. Many people have made | +| generous contributions to the wide range of software distributed | +| through that system in reliance on consistent application of that | +| system; it is up to the author/donor to decide if he or she is willing | +| to distribute software through any other system and a licensee cannot | +| impose that choice. | +| | +| This section is intended to make thoroughly clear what is believed to | +| be a consequence of the rest of this License. | +| | +| 12. If the distribution and/or use of the Library is restricted in | +| certain countries either by patents or by copyrighted interfaces, the | +| original copyright holder who places the Library under this License may add | +| an explicit geographical distribution limitation excluding those countries, | +| so that distribution is permitted only in or among countries not thus | +| excluded. In such case, this License incorporates the limitation as if | +| written in the body of this License. | +| | +| 13. The Free Software Foundation may publish revised and/or new | +| versions of the Lesser General Public License from time to time. | +| Such new versions will be similar in spirit to the present version, | +| but may differ in detail to address new problems or concerns. | +| | +| Each version is given a distinguishing version number. If the Library | +| specifies a version number of this License which applies to it and | +| "any later version", you have the option of following the terms and | +| conditions either of that version or of any later version published by | +| the Free Software Foundation. If the Library does not specify a | +| license version number, you may choose any version ever published by | +| the Free Software Foundation. | +| | +| 14. If you wish to incorporate parts of the Library into other free | +| programs whose distribution conditions are incompatible with these, | +| write to the author to ask for permission. For software which is | +| copyrighted by the Free Software Foundation, write to the Free | +| Software Foundation; we sometimes make exceptions for this. Our | +| decision will be guided by the two goals of preserving the free status | +| of all derivatives of our free software and of promoting the sharing | +| and reuse of software generally. | +| | +| NO WARRANTY | +| | +| 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO | +| WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. | +| EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR | +| OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY | +| KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE | +| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | +| PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE | +| LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME | +| THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. | +| | +| 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN | +| WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY | +| AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU | +| FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR | +| CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE | +| LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING | +| RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A | +| FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF | +| SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH | +| DAMAGES. | +| | +| END OF TERMS AND CONDITIONS | +| | +| How to Apply These Terms to Your New Libraries | +| | +| If you develop a new library, and you want it to be of the greatest | +| possible use to the public, we recommend making it free software that | +| everyone can redistribute and change. You can do so by permitting | +| redistribution under these terms (or, alternatively, under the terms of the | +| ordinary General Public License). | +| | +| To apply these terms, attach the following notices to the library. It is | +| safest to attach them to the start of each source file to most effectively | +| convey the exclusion of warranty; and each file should have at least the | +| "copyright" line and a pointer to where the full notice is found. | +| | +| | +| Copyright (C) | +| | +| This library is free software; you can redistribute it and/or | +| modify it under the terms of the GNU Lesser General Public | +| License as published by the Free Software Foundation; either | +| version 2.1 of the License, or (at your option) any later version. | +| | +| 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. | +| | +| You should have received a copy of the GNU Lesser General Public | +| License along with this library; if not, write to the Free Software | +| Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | +| | +| Also add information on how to contact you by electronic and paper mail. | +| | +| You should also get your employer (if you work as a programmer) or your | +| school, if any, to sign a "copyright disclaimer" for the library, if | +| necessary. Here is a sample; alter the names: | +| | +| Yoyodyne, Inc., hereby disclaims all copyright interest in the | +| library `Frob' (a library for tweaking knobs) written by James Random Hacker. | +| | +| , 1 April 1990 | +| Ty Coon, President of Vice | +| | +| That's all there is to it! | ++------------------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +MIT +--- + + The component(s) (Name/GroupId/Version): + + * checker-qual/org.checkerframework/3.8.0 (cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli) + + are at least partly licensed via the following license of type MIT: + ++----------------------------------------------------------------------------------+ +| MIT License Copyright (c) | +| | +| Permission is hereby granted, free of charge, to any person obtaining a copy | +| of this software and associated documentation files (the "Software"), to deal | +| in the Software without restriction, including without limitation the rights | +| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | +| copies of the Software, and to permit persons to whom the Software is furnished | +| to do so, subject to the following conditions: | +| | +| The above copyright notice and this permission notice (including the next | +| paragraph) shall be included in all copies or substantial portions of the | +| Software. | +| | +| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | +| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | +| FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS | +| OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | +| WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF | +| OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ++----------------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: http://opensource.org/licenses/MIT +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +MIT +--- + + The component(s) (Name/GroupId/Version): + + * slf4j-api/org.slf4j/1.7.30 (cobigen-xmlplugin, cobigen-tsplugin, cobigen-textmerger, cobigen-tempeng-velocity, cobigen-tempeng-freemarker, cobigen-propertyplugin, cobigen-openapiplugin, cobigen-maven, cobigen-jsonplugin, cobigen-javaplugin, cobigen-htmlplugin, cobigen-eclipse, cobigen-cli) + + are at least partly licensed via the following license of type MIT: + ++-------------------------------------------------------------------------+ +| Copyright (c) 2004-2017 QOS.ch | +| All rights reserved. | +| | +| Permission is hereby granted, free of charge, to any person obtaining | +| a copy of this software and associated documentation files (the | +| "Software"), to deal in the Software without restriction, including | +| without limitation the rights to use, copy, modify, merge, publish, | +| distribute, sublicense, and/or sell copies of the Software, and to | +| permit persons to whom the Software is furnished to do so, subject to | +| the following conditions: | +| | +| The above copyright notice and this permission notice shall be | +| included in all copies or substantial portions of the Software. | +| | +| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | +| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | +| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | +| NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | +| LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | +| OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | +| WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ++-------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: http://www.slf4j.org/license.html +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +MIT +--- + + The component(s) (Name/GroupId/Version): + + * jsoup/org.jsoup/1.10.2 (cobigen-htmlplugin) + + are at least partly licensed via the following license of type MIT: + ++--------------------------------------------------------------------------------+ +| The MIT License | +| | +| Copyright (c) 2009-2018 Jonathan Hedley | +| | +| Permission is hereby granted, free of charge, to any person obtaining a copy | +| of this software and associated documentation files (the "Software"), to deal | +| in the Software without restriction, including without limitation the rights | +| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | +| copies of the Software, and to permit persons to whom the Software is | +| furnished to do so, subject to the following conditions: | +| | +| The above copyright notice and this permission notice shall be included in all | +| copies or substantial portions of the Software. | +| | +| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | +| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | +| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | +| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | +| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | +| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | +| SOFTWARE. | ++--------------------------------------------------------------------------------+ + + URL(s) leading to the above given license text: https://jsoup.org/license +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ + +PublicDomain +------------ + + The component(s) (Name/GroupId/Version): + + * sax/sax/2.0.1 (cobigen-xmlplugin) + + are at least partly licensed under Public Domain (https://creativecommons.org/licenses/publicdomain) \ No newline at end of file diff --git a/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/main/resources/META-INF/services/com.devonfw.cobigen.api.extension.TextTemplateEngine b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/main/resources/META-INF/services/com.devonfw.cobigen.api.extension.TextTemplateEngine new file mode 100644 index 0000000000..e42b6f7658 --- /dev/null +++ b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/main/resources/META-INF/services/com.devonfw.cobigen.api.extension.TextTemplateEngine @@ -0,0 +1 @@ +com.devonfw.cobigen.tempeng.agnostic.AgnosticTemplateEngine \ No newline at end of file diff --git a/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/test/java/com/customer/app/mycomponent/dataaccess/FooBarEntity.java b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/test/java/com/customer/app/mycomponent/dataaccess/FooBarEntity.java new file mode 100644 index 0000000000..fbcfc03538 --- /dev/null +++ b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/test/java/com/customer/app/mycomponent/dataaccess/FooBarEntity.java @@ -0,0 +1,26 @@ +package com.customer.app.mycomponent.dataaccess; + +/** + * + */ +public class FooBarEntity extends MyExampleEntity { + + private String foo; + + /** + * @return foo + */ + public String getFoo() { + + return this.foo; + } + + /** + * @param foo new value of {@link #getFoo()}. + */ + public void setFoo(String foo) { + + this.foo = foo; + } + +} diff --git a/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/test/java/com/customer/app/mycomponent/dataaccess/MyExampleEntity.java b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/test/java/com/customer/app/mycomponent/dataaccess/MyExampleEntity.java new file mode 100644 index 0000000000..187425feb6 --- /dev/null +++ b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/test/java/com/customer/app/mycomponent/dataaccess/MyExampleEntity.java @@ -0,0 +1,48 @@ +package com.customer.app.mycomponent.dataaccess; + +import java.time.LocalDate; + +import x_rootpackage_x.general.dataaccess.x_scope_x.ApplicationPersistenceEntity; + +/** + * + */ +public class MyExampleEntity extends ApplicationPersistenceEntity { + + private String name; + + private LocalDate birthday; + + /** + * @return name + */ + public String getName() { + + return this.name; + } + + /** + * @param name new value of {@link #getName()}. + */ + public void setName(String name) { + + this.name = name; + } + + /** + * @return birthday + */ + public LocalDate getBirthday() { + + return this.birthday; + } + + /** + * @param birthday new value of {@link #getBirthday()}. + */ + public void setBirthday(LocalDate birthday) { + + this.birthday = birthday; + } + +} diff --git a/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/test/java/com/devonfw/cobigen/tempeng/agnostic/unittest/AgnosticTemplateEngineTest.java b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/test/java/com/devonfw/cobigen/tempeng/agnostic/unittest/AgnosticTemplateEngineTest.java new file mode 100644 index 0000000000..afeb52abd7 --- /dev/null +++ b/cobigen-plugins/cobigen-templateengines/cobigen-tempeng-agnostic/src/test/java/com/devonfw/cobigen/tempeng/agnostic/unittest/AgnosticTemplateEngineTest.java @@ -0,0 +1,266 @@ +package com.devonfw.cobigen.tempeng.agnostic.unittest; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.StringWriter; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; + +import org.junit.Before; +import org.junit.Test; + +import com.customer.app.mycomponent.dataaccess.FooBarEntity; +import com.customer.app.mycomponent.dataaccess.MyExampleEntity; +import com.devonfw.cobigen.api.extension.TextTemplate; +import com.devonfw.cobigen.tempeng.agnostic.AgnosticTemplateEngine; + +/** + * Test of {@link AgnosticTemplateEngine}. + */ +public class AgnosticTemplateEngineTest { + + private static final String JAVA_TEMPLATES_PATH = "../../../cobigen-templates/templates-devonfw-java/src/main/java/"; + + /** + * Test subject + */ + private AgnosticTemplateEngine engine; + + /** + * @throws java.lang.Exception if something unexpected happens + */ + @Before + public void setUpBefore() throws Exception { + + this.engine = new AgnosticTemplateEngine(); + } + + /** + * Tests a basic agnostic generation. + */ + @Test + public void testGenerateUcFind() { + + // arrange + final Path templateFolder = Paths.get(JAVA_TEMPLATES_PATH).toAbsolutePath(); + TextTemplate template = new TextTemplate() { + @Override + public String getRelativeTemplatePath() { + + return "x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/UcFindX_EntityName_X.java"; + } + + @Override + public Path getAbsoluteTemplatePath() { + + return templateFolder.resolve(getRelativeTemplatePath()); + } + }; + HashMap model = new HashMap<>(); + model.put("rootpackage", "com.customer.app"); + model.put("component", "mycomponent"); + model.put("entityName", "MyExample"); + model.put("scope", ""); + model.put("detail", ""); + + // act + StringWriter out = new StringWriter(); + this.engine.process(template, model, out, "UTF-8"); + + // assert + assertThat(out.toString()).isEqualTo("package com.customer.app.mycomponent.logic;\n" // + + "\n" // + + "import java.util.Optional;\n" // + + "\n" // + + "import javax.annotation.security.RolesAllowed;\n" // + + "import javax.inject.Named;\n" // + + "import javax.transaction.Transactional;\n" // + + "\n" // + + "import org.slf4j.Logger;\n" // + + "import org.slf4j.LoggerFactory;\n" // + + "\n" // + + "import com.customer.app.general.common.security.ApplicationAccessControlConfig;\n" // + + "import com.customer.app.mycomponent.common.MyExample;\n" // + + "import com.customer.app.mycomponent.common.MyExampleEto;\n" // + + "import com.customer.app.mycomponent.dataaccess.MyExampleEntity;\n" // + + "\n" // + + "/**\n" // + + " * Use-case to find instances of {@link MyExample}.\n" // + + " */\n" // + + "@Named\n" // + + "@Transactional\n" // + + "public class UcFindMyExample extends AbstractUcMyExample {\n" // + + "\n" // + + " /** Logger instance. */\n" // + + " private static final Logger LOG = LoggerFactory.getLogger(UcFindMyExample.class);\n" // + + "\n" // + + " /**\n" // + + " * @param id the {@link MyExampleEntity#getId() primary key} of the requested {@link MyExampleEto}.\n" // + + " * @return the {@link MyExampleEto} or {@code null} if no such ETO exists.\n" // + + " */\n" // + + " @RolesAllowed(ApplicationAccessControlConfig.PERMISSION_FIND_MY_EXAMPLE)\n" // + + " public MyExampleEto findMyExample(Long id) {\n" // + + "\n" // + + " LOG.debug(\"Get MyExample with id {} from database.\", id);\n" // + + " if (id == null) {\n" // + + " return null;\n" // + + " }\n" // + + " Optional entity = getRepository().findById(id);\n" // + + " if (entity.isPresent()) {\n" // + + " return getBeanMapper().toEto(entity.get());\n" // + + " } else {\n" // + + " return null;\n" // + + " }\n" // + + " }\n" // + + "\n" // + + "}\n"); + } + + /** + * Tests a basic agnostic generation. + */ + @Test + public void testGenerateEto() { + + // arrange + final Path templateFolder = Paths.get(JAVA_TEMPLATES_PATH).toAbsolutePath(); + TextTemplate template = new TextTemplate() { + @Override + public String getRelativeTemplatePath() { + + return "x_rootpackage_x/x_component_x/common/x_scope_x/x_detail_x/X_EntityName_XEto.java"; + } + + @Override + public Path getAbsoluteTemplatePath() { + + return templateFolder.resolve(getRelativeTemplatePath()); + } + }; + HashMap model = new HashMap<>(); + model.put("rootpackage", "com.customer.app"); + model.put("component", "mycomponent"); + model.put("entityName", "MyExample"); + model.put("classObject", MyExampleEntity.class); + model.put("scope", ""); + model.put("detail", ""); + + // act + StringWriter out = new StringWriter(); + this.engine.process(template, model, out, "UTF-8"); + + // assert + assertThat(out.toString()).isEqualTo("package com.customer.app.mycomponent.common;\n" // + + "\n" // + + "import com.customer.app.general.common.AbstractEto;\n" // + + "import java.time.LocalDate;\n" // + + "\n" // + + "/**\n" // + + " * Implementation of {@link MyExample} as {@link AbstractEto ETO}.\n" // + + " */\n" // + + "public class MyExampleEto extends AbstractEto implements MyExample {\n" // + + "\n" // + + " private String name;\n" // + + "\n" // + + " private LocalDate birthday;\n" // + + "\n" // + + " /**\n" // + + " * The constructor.\n" // + + " */\n" // + + " public MyExampleEto() {\n" // + + "\n" // + + " super();\n" // + + " }\n" // + + "\n" // + + " @Override\n" // + + " public String getName() {\n" // + + " return this.name;\n" // + + " }\n" // + + "\n" // + + " @Override\n" // + + " public void setName(String name) {\n" // + + " this.name = name;\n" // + + " }\n" // + + "\n" // + + " @Override\n" // + + " public LocalDate getBirthday() {\n" // + + " return this.birthday;\n" // + + " }\n" // + + "\n" // + + " @Override\n" // + + " public void setBirthday(LocalDate birthday) {\n" // + + " this.birthday = birthday;\n" // + + " }\n" // + + "\n" // + + "}\n"); + } + + /** + * Tests a basic agnostic generation. + */ + @Test + public void testGenerateEtoWithParentEntity() { + + // arrange + final Path templateFolder = Paths.get(JAVA_TEMPLATES_PATH).toAbsolutePath(); + TextTemplate template = new TextTemplate() { + @Override + public String getRelativeTemplatePath() { + + return "x_rootpackage_x/x_component_x/common/x_scope_x/x_detail_x/X_EntityName_XEto.java"; + } + + @Override + public Path getAbsoluteTemplatePath() { + + return templateFolder.resolve(getRelativeTemplatePath()); + } + }; + HashMap model = new HashMap<>(); + model.put("rootpackage", "com.customer.app"); + model.put("component", "mycomponent"); + model.put("entityName", "FooBar"); + model.put("classObject", FooBarEntity.class); + model.put("scope", ""); + model.put("detail", ""); + + // act + StringWriter out = new StringWriter(); + this.engine.process(template, model, out, "UTF-8"); + + // assert + assertThat(out.toString()).isEqualTo("package com.customer.app.mycomponent.common;\n" // + + "\n" // + + "import com.customer.app.general.common.AbstractEto;\n" // + + "import com.customer.app.mycomponent.common.MyExampleEto;\n" // + + "\n" // + + "/**\n" // + + " * Implementation of {@link FooBar} as {@link AbstractEto ETO}.\n" // + + " */\n" // + + "public class FooBarEto extends MyExampleEto implements FooBar {\n" // + + "\n" // + + " private String foo;\n" // + + "\n" // + + " /**\n" // + + " * The constructor.\n" // + + " */\n" // + + " public FooBarEto() {\n" // + + "\n" // + + " super();\n" // + + " }\n" // + + "\n" // + + " @Override\n" // + + " public String getFoo() {\n" // + + " return this.foo;\n" // + + " }\n" // + + "\n" // + + " @Override\n" // + + " public void setFoo(String foo) {\n" // + + " this.foo = foo;\n" // + + " }\n" // + + "\n" // + + "}\n"); + } + +} diff --git a/cobigen-plugins/cobigen-templateengines/pom.xml b/cobigen-plugins/cobigen-templateengines/pom.xml index 49a7034c05..5a482b21d8 100644 --- a/cobigen-plugins/cobigen-templateengines/pom.xml +++ b/cobigen-plugins/cobigen-templateengines/pom.xml @@ -15,6 +15,7 @@ cobigen-tempeng-freemarker cobigen-tempeng-velocity + cobigen-tempeng-agnostic diff --git a/cobigen-templates/pom.xml b/cobigen-templates/pom.xml index 09f7db4f18..40ceb19e53 100644 --- a/cobigen-templates/pom.xml +++ b/cobigen-templates/pom.xml @@ -21,6 +21,7 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLS + templates-devonfw-java templates-devon4j-utils templates-devon4j-tests crud-angular-client-app diff --git a/cobigen-templates/templates-devonfw-java/pom.xml b/cobigen-templates/templates-devonfw-java/pom.xml new file mode 100644 index 0000000000..dfc00f0a0c --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/pom.xml @@ -0,0 +1,73 @@ + + + 4.0.0 + templates-devonfw-java + jar + CobiGen - devonfw Java Templates + + com.devonfw.cobigen.templates + templates-parent + ${revision} + ../pom.xml + + + false + + + + com.devonfw.cobigen + core-api + + + com.fasterxml.jackson.core + jackson-databind + + + jakarta.platform + jakarta.jakartaee-api + 8.0.0 + + + org.springframework.data + spring-data-jpa + 2.7.7 + + + org.mapstruct + mapstruct + 1.4.2.Final + + + org.assertj + assertj-core + 3.10.0 + test + + + + + + src/main/resources + + **/* + + + + src/main/java + + **/*.java + + + com/**/* + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/CobiGenJavaIncrements.java b/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/CobiGenJavaIncrements.java new file mode 100644 index 0000000000..92d9e5980a --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/CobiGenJavaIncrements.java @@ -0,0 +1,23 @@ +package com.devonfw.cobigen.api.template; + +/** + * The increments of this template set. + */ +public interface CobiGenJavaIncrements { + + /** Entity interface, ETO, etc. */ + String ENTITY = "entity"; + + /** Data-access with repository. */ + String DATA_ACCESS = "dataaccess"; + + /** Logic with use-cases. */ + String LOGIC = "logic"; + + /** REST services. */ + String REST = "rest"; + + /** Search criteria and search. */ + String SEARCH = "search"; + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/CobiGenJavaProperties.java b/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/CobiGenJavaProperties.java new file mode 100644 index 0000000000..4af29cd9f4 --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/CobiGenJavaProperties.java @@ -0,0 +1,33 @@ +package com.devonfw.cobigen.api.template; + +/** + * The tags of this template set. + */ +public interface CobiGenJavaProperties { + + // -- scope -- + + /** Key for the target scope of a template. */ + String KEY_SCOPE = "scope"; + + /** {@link #KEY_SCOPE Scope} value {@value} */ + String VALUE_SCOPE_API = "api"; + + /** {@link #KEY_SCOPE Scope} value {@value} */ + String VALUE_SCOPE_BASE = "base"; + + /** {@link #KEY_SCOPE Scope} value {@value} */ + String VALUE_SCOPE_IMPL = "impl"; + + // -- module -- + + /** Key for the target (maven) module of a template. Will only be used in multi-module projects. */ + String KEY_MODULE = "module"; + + /** {@link #KEY_MODULE Module} value {@value} */ + String VALUE_MODULE_API = "api"; + + /** {@link #KEY_MODULE Module} value {@value} */ + String VALUE_MODULE_CORE = "core"; + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorJavaTypeEntitySuperInterface.java b/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorJavaTypeEntitySuperInterface.java new file mode 100644 index 0000000000..b724b35f48 --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorJavaTypeEntitySuperInterface.java @@ -0,0 +1,35 @@ +package com.devonfw.cobigen.api.template.generator; + +import java.io.IOException; + +import com.devonfw.cobigen.api.model.CobiGenModel; +import com.devonfw.cobigen.api.model.CobiGenVariableDefinitions; +import com.devonfw.cobigen.api.template.out.QualifiedName; + +import x_rootpackage_x.general.common.x_scope_x.ApplicationEntity; +import x_rootpackage_x.general.dataaccess.x_scope_x.ApplicationPersistenceEntity; + +/** + * Implementation of {@link CobiGenGenerator} to generate super-interface name and import of generated entity interface. + * + */ +public class CobiGenGeneratorJavaTypeEntitySuperInterface implements CobiGenGenerator { + + @Override + public void generate(CobiGenModel model, Appendable code) throws IOException { + + Class type = CobiGenVariableDefinitions.JAVA_TYPE.getValue(model); + + Class superclass = type.getSuperclass(); + String superclassName = superclass.getSimpleName(); + String parentEntityInterface = ApplicationEntity.class.getSimpleName(); + if (superclassName.endsWith("Entity") + && !superclassName.equals(ApplicationPersistenceEntity.class.getSimpleName())) { + parentEntityInterface = superclassName.substring(0, superclassName.length() - 6); + String pkg = superclass.getPackageName().replace(".dataaccess", ".common"); + CobiGenVariableDefinitions.OUT.getValue(model).addImport(QualifiedName.of(pkg, parentEntityInterface, '.')); + } + code.append(parentEntityInterface); + } + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorJavaTypeEtoProperties.java b/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorJavaTypeEtoProperties.java new file mode 100644 index 0000000000..9b70272f84 --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorJavaTypeEtoProperties.java @@ -0,0 +1,39 @@ +package com.devonfw.cobigen.api.template.generator; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Collection; + +import com.devonfw.cobigen.api.code.CobiGenCodeProperty; +import com.devonfw.cobigen.api.model.CobiGenModel; +import com.devonfw.cobigen.api.template.out.CobiGenOutput; + +/** + * {@link CobiGenOutputGenerator} to generate properties of an ETO. + */ +public class CobiGenGeneratorJavaTypeEtoProperties extends CobiGenGeneratorJavaTypeProperties { + + @Override + protected CobiGenCodeProperty map(Field field, CobiGenOutput out, CobiGenModel model) { + + if (Modifier.isStatic(field.getModifiers())) { + return null; // ignore static fields. + } + String name = field.getName(); + Class type = field.getType(); + String typeName = type.getName(); + if (typeName.endsWith("Entity") && typeName.contains(".dataaccess.")) { + typeName = typeName.replace(".dataaccess.", ".common."); + typeName = typeName.substring(0, typeName.length() - "Entity".length()) + "Eto"; + name = name + "Id"; + } else if (Collection.class.isAssignableFrom(type)) { + return null; + } + String description = null; + if (out.isInterface()) { + description = "the " + name; // kind of hack, only generate JavaDoc in case of interface + } + return new CobiGenCodeProperty(name, typeName, description); + } + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorJavaTypeEtoSuperClass.java b/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorJavaTypeEtoSuperClass.java new file mode 100644 index 0000000000..94ea727d7f --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorJavaTypeEtoSuperClass.java @@ -0,0 +1,35 @@ +package com.devonfw.cobigen.api.template.generator; + +import java.io.IOException; + +import com.devonfw.cobigen.api.model.CobiGenModel; +import com.devonfw.cobigen.api.model.CobiGenVariableDefinitions; +import com.devonfw.cobigen.api.template.out.QualifiedName; + +import x_rootpackage_x.general.common.x_scope_x.AbstractEto; +import x_rootpackage_x.general.dataaccess.x_scope_x.ApplicationPersistenceEntity; + +/** + * Implementation of {@link CobiGenGenerator} to generate super-class name and import of generated ETO. + * + */ +public class CobiGenGeneratorJavaTypeEtoSuperClass implements CobiGenGenerator { + + @Override + public void generate(CobiGenModel model, Appendable code) throws IOException { + + Class type = CobiGenVariableDefinitions.JAVA_TYPE.getValue(model); + + Class superclass = type.getSuperclass(); + String superclassName = superclass.getSimpleName(); + String parentEto = AbstractEto.class.getSimpleName(); + if (superclassName.endsWith("Entity") + && !superclassName.equals(ApplicationPersistenceEntity.class.getSimpleName())) { + parentEto = superclassName.substring(0, superclassName.length() - 6) + "Eto"; + String pkg = superclass.getPackageName().replace(".dataaccess", ".common"); + CobiGenVariableDefinitions.OUT.getValue(model).addImport(QualifiedName.of(pkg, parentEto, '.')); + } + code.append(parentEto); + } + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorJavaTypeProperties.java b/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorJavaTypeProperties.java new file mode 100644 index 0000000000..f8a9decf3d --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorJavaTypeProperties.java @@ -0,0 +1,58 @@ +package com.devonfw.cobigen.api.template.generator; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + +import com.devonfw.cobigen.api.code.CobiGenCodeProperty; +import com.devonfw.cobigen.api.model.CobiGenModel; +import com.devonfw.cobigen.api.model.CobiGenVariableDefinitions; +import com.devonfw.cobigen.api.template.out.CobiGenOutput; + +/** + * {@link CobiGenOutputGenerator} to generate properties of an ETO. + */ +public class CobiGenGeneratorJavaTypeProperties extends CobiGenOutputGenerator { + + @Override + protected void doGenerate(CobiGenOutput out, CobiGenModel model) { + + Class type = CobiGenVariableDefinitions.JAVA_TYPE.getValue(model); + for (Field field : type.getDeclaredFields()) { + generate(field, out, model); + } + } + + /** + * @param field the {@link Field} to generate. + * @param out the {@link CobiGenOutput} where to generate the code. + * @param model the {@link CobiGenModel}. Typically not needed but available for complex cases. + */ + protected void generate(Field field, CobiGenOutput out, CobiGenModel model) { + + CobiGenCodeProperty property = map(field, out, model); + if (property != null) { + out.addProperty(property.getName(), property.getType(), property.getDescription()); + } + } + + /** + * @param field the {@link Field} to map. + * @param out the {@link CobiGenOutput}. Typically not needed but available for complex cases. If used here then only + * to read information like imports but never write in this method. + * @param model the {@link CobiGenModel}. Typically not needed but available for complex cases. + * @return the mapped {@link CobiGenCodeProperty} or {@code null} to filter and ignore the given {@link Field}. + */ + protected CobiGenCodeProperty map(Field field, CobiGenOutput out, CobiGenModel model) { + + if (Modifier.isStatic(field.getModifiers())) { + return null; // ignore static fields. + } + String name = field.getName(); + String description = null; + if (out.isInterface()) { + description = "the " + name; // kind of hack, only generate JavaDoc in case of interface + } + return new CobiGenCodeProperty(name, field.getType().getName(), description); + } + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/general/common/x_scope_x/AbstractEto.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/general/common/x_scope_x/AbstractEto.java new file mode 100644 index 0000000000..fabe703729 --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/general/common/x_scope_x/AbstractEto.java @@ -0,0 +1,76 @@ +package x_rootpackage_x.general.common.x_scope_x; + +import java.util.Objects; + +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; + +/** + * Abstract base class for an Entity Transfer Object (ETO). + */ +@CobiGenTemplate(value = CobiGenJavaIncrements.ENTITY, constant = true) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_API), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_API) }) +public abstract class AbstractEto implements ApplicationEntity { + + private Long id; + + private Integer version; + + @Override + public Long getId() { + + return this.id; + } + + @Override + public void setId(Long id) { + + this.id = id; + } + + @Override + public Integer getVersion() { + + return this.version; + } + + @Override + public void setVersion(Integer version) { + + this.version = version; + } + + @Override + public int hashCode() { + + final int prime = 31; + int result = (this.id == null) ? 0 : this.id.hashCode(); + result = prime * result; + if (this.version != null) { + result = result + this.version.intValue(); + } + return result; + } + + @Override + public boolean equals(Object obj) { + + if (this == obj) { + return true; + } else if ((obj == null) || (getClass() != obj.getClass())) { + return false; + } + AbstractEto other = (AbstractEto) obj; + if (!Objects.equals(this.id, other.id)) { + return false; + } else if (!Objects.equals(this.version, other.version)) { + return false; + } + return true; + } +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/general/common/x_scope_x/ApplicationEntity.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/general/common/x_scope_x/ApplicationEntity.java new file mode 100644 index 0000000000..9e625294ff --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/general/common/x_scope_x/ApplicationEntity.java @@ -0,0 +1,37 @@ +package x_rootpackage_x.general.common.x_scope_x; + +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; + +/** + * Interface for an entity of this application. + */ +@CobiGenTemplate(value = CobiGenJavaIncrements.ENTITY, constant = true) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_API), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_API) }) +public interface ApplicationEntity { + + /** + * @return the primary key of this entity. + */ + Long getId(); + + /** + * @param id new value of {@link #getId()}. + */ + void setId(Long id); + + /** + * @return version + */ + Integer getVersion(); + + /** + * @param version new value of {@link #getVersion()}. + */ + void setVersion(Integer version); +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/general/common/x_scope_x/security/ApplicationAccessControlConfig.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/general/common/x_scope_x/security/ApplicationAccessControlConfig.java new file mode 100644 index 0000000000..3e2f3eaaef --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/general/common/x_scope_x/security/ApplicationAccessControlConfig.java @@ -0,0 +1,33 @@ +package x_rootpackage_x.general.common.x_scope_x.security; + +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; + +/** + * Constants for permissions of this application. + */ +@CobiGenTemplate(value = CobiGenJavaIncrements.LOGIC, constant = true) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_API), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_CORE) }) +public class ApplicationAccessControlConfig { + + /** + * The namespace prefix build from {@link #APP_ID} and prepended to every permission to avoid name-clashing of + * permissions with other applications within the same application landscape in identity & access management (IAM). + */ + private static final String PREFIX = "appId."; + + /** Permission to for {@link x_rootpackage_x.x_component_x.logic.x_scope_x.x_detail_x.UcFindX_EntityName_X}. */ + public static final String PERMISSION_FIND_X_ENTITY_NAME_X = PREFIX + "FindX_EntityName_X"; + + /** Permission to for {@link x_rootpackage_x.x_component_x.logic.x_scope_x.x_detail_x.UcSaveX_EntityName_X}. */ + public static final String PERMISSION_SAVE_X_ENTITY_NAME_X = PREFIX + "SaveX_EntityName_X"; + + /** Permission to for {@link x_rootpackage_x.x_component_x.logic.x_scope_x.x_detail_x.UcDeleteX_EntityName_X}. */ + public static final String PERMISSION_DELETE_X_ENTITY_NAME_X = PREFIX + "DeleteX_EntityName_X"; + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/general/dataaccess/x_scope_x/ApplicationPersistenceEntity.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/general/dataaccess/x_scope_x/ApplicationPersistenceEntity.java new file mode 100644 index 0000000000..53a5a33f1c --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/general/dataaccess/x_scope_x/ApplicationPersistenceEntity.java @@ -0,0 +1,56 @@ +package x_rootpackage_x.general.dataaccess.x_scope_x; + +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; +import javax.persistence.Version; + +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; + +import x_rootpackage_x.general.common.x_scope_x.ApplicationEntity; + +/** + * Abstract base class for a persistent (JPA) entity of this application. + */ +@MappedSuperclass +@CobiGenTemplate(value = CobiGenJavaIncrements.ENTITY, constant = true) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_API), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_CORE) }) +public class ApplicationPersistenceEntity implements ApplicationEntity { + + @Id + @GeneratedValue + private Long id; + + @Version + private Integer version; + + @Override + public Long getId() { + + return this.id; + } + + @Override + public void setId(Long id) { + + this.id = id; + } + + @Override + public Integer getVersion() { + + return this.version; + } + + @Override + public void setVersion(Integer version) { + + this.version = version; + } +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/common/x_scope_x/x_detail_x/X_EntityName_X.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/common/x_scope_x/x_detail_x/X_EntityName_X.java new file mode 100644 index 0000000000..23266d29ab --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/common/x_scope_x/x_detail_x/X_EntityName_X.java @@ -0,0 +1,26 @@ +package x_rootpackage_x.x_component_x.common.x_scope_x.x_detail_x; + +import com.devonfw.cobigen.api.annotation.CobiGenDynamicType; +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; +import com.devonfw.cobigen.api.template.generator.CobiGenGeneratorJavaTypeEntitySuperInterface; +import com.devonfw.cobigen.api.template.generator.CobiGenGeneratorJavaTypeEtoProperties; + +import x_rootpackage_x.general.common.x_scope_x.ApplicationEntity; + +/** + * {@link ApplicationEntity} for {@link X_EntityName_X}. + */ +@CobiGenTemplate(value = CobiGenJavaIncrements.ENTITY) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_API), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_API) }) +public interface X_EntityName_X + extends @CobiGenDynamicType(CobiGenGeneratorJavaTypeEntitySuperInterface.class) ApplicationEntity { + + CobiGenGeneratorJavaTypeEtoProperties GENERATOR = null; + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/common/x_scope_x/x_detail_x/X_EntityName_XEto.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/common/x_scope_x/x_detail_x/X_EntityName_XEto.java new file mode 100644 index 0000000000..a950db3c85 --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/common/x_scope_x/x_detail_x/X_EntityName_XEto.java @@ -0,0 +1,33 @@ +package x_rootpackage_x.x_component_x.common.x_scope_x.x_detail_x; + +import com.devonfw.cobigen.api.annotation.CobiGenDynamicType; +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; +import com.devonfw.cobigen.api.template.generator.CobiGenGeneratorJavaTypeEtoProperties; +import com.devonfw.cobigen.api.template.generator.CobiGenGeneratorJavaTypeEtoSuperClass; + +import x_rootpackage_x.general.common.x_scope_x.AbstractEto; + +/** + * Implementation of {@link X_EntityName_X} as {@link AbstractEto ETO}. + */ +@CobiGenTemplate(value = CobiGenJavaIncrements.ENTITY) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_API), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_API) }) +public class X_EntityName_XEto extends @CobiGenDynamicType(CobiGenGeneratorJavaTypeEtoSuperClass.class) AbstractEto implements X_EntityName_X { + + private CobiGenGeneratorJavaTypeEtoProperties field; + + /** + * The constructor. + */ + public X_EntityName_XEto() { + + super(); + } + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/dataaccess/x_scope_x/x_detail_x/X_EntityName_XEntity.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/dataaccess/x_scope_x/x_detail_x/X_EntityName_XEntity.java new file mode 100644 index 0000000000..2739dab253 --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/dataaccess/x_scope_x/x_detail_x/X_EntityName_XEntity.java @@ -0,0 +1,23 @@ +package x_rootpackage_x.x_component_x.dataaccess.x_scope_x.x_detail_x; + +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; + +import x_rootpackage_x.general.dataaccess.x_scope_x.ApplicationPersistenceEntity; +import x_rootpackage_x.x_component_x.common.x_scope_x.x_detail_x.X_EntityName_X; + +/** + * Implementation of {@link X_EntityName_X} as {@link ApplicationPersistenceEntity}. + */ +@CobiGenTemplate(value = CobiGenJavaIncrements.ENTITY) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_API), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_CORE) }) +public class X_EntityName_XEntity extends ApplicationPersistenceEntity implements X_EntityName_X { + + // TODO + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/dataaccess/x_scope_x/x_detail_x/X_EntityName_XRepository.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/dataaccess/x_scope_x/x_detail_x/X_EntityName_XRepository.java new file mode 100644 index 0000000000..c6dab7c076 --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/dataaccess/x_scope_x/x_detail_x/X_EntityName_XRepository.java @@ -0,0 +1,20 @@ +package x_rootpackage_x.x_component_x.dataaccess.x_scope_x.x_detail_x; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; + +/** + * {@link JpaRepository} for {@link X_EntityName_XEntity}. + */ +@CobiGenTemplate(value = CobiGenJavaIncrements.DATA_ACCESS) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_API), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_CORE) }) +public interface X_EntityName_XRepository extends JpaRepository { + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/AbstractUcX_EntityName_X.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/AbstractUcX_EntityName_X.java new file mode 100644 index 0000000000..a10ce8f885 --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/AbstractUcX_EntityName_X.java @@ -0,0 +1,47 @@ +package x_rootpackage_x.x_component_x.logic.x_scope_x.x_detail_x; + +import javax.inject.Inject; + +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; + +import x_rootpackage_x.x_component_x.common.x_scope_x.x_detail_x.X_EntityName_X; +import x_rootpackage_x.x_component_x.dataaccess.x_scope_x.x_detail_x.X_EntityName_XRepository; + +/** + * Abstract base class for all use-cases related to {@link X_EntityName_X}. + */ +@CobiGenTemplate(value = CobiGenJavaIncrements.LOGIC) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_BASE), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_CORE) }) +public abstract class AbstractUcX_EntityName_X { + + @Inject + private X_EntityName_XMapper beanMapper; + + @Inject + private X_EntityName_XRepository repository; + + /** + * @return the {@link X_EntityName_XRepository}. + */ + public X_EntityName_XRepository getRepository() { + + return this.repository; + } + + /** + * @return the {@link X_EntityName_XMapper} to map from {@link x_rootpackage_x.general.common.x_scope_x.AbstractEto + * ETO} to {@link x_rootpackage_x.general.dataaccess.x_scope_x.ApplicationPersistenceEntity entity} and vice + * versa. + */ + public X_EntityName_XMapper getBeanMapper() { + + return this.beanMapper; + } + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/UcDeleteX_EntityName_X.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/UcDeleteX_EntityName_X.java new file mode 100644 index 0000000000..a57c939d4f --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/UcDeleteX_EntityName_X.java @@ -0,0 +1,64 @@ +package x_rootpackage_x.x_component_x.logic.x_scope_x.x_detail_x; + +import javax.annotation.security.RolesAllowed; +import javax.inject.Named; +import javax.transaction.Transactional; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; + +import x_rootpackage_x.general.common.x_scope_x.security.ApplicationAccessControlConfig; +import x_rootpackage_x.x_component_x.common.x_scope_x.x_detail_x.X_EntityName_X; +import x_rootpackage_x.x_component_x.common.x_scope_x.x_detail_x.X_EntityName_XEto; + +/** + * Use-case to delete instances of {@link X_EntityName_X}. + */ +@Named +@Transactional +@CobiGenTemplate(value = CobiGenJavaIncrements.LOGIC) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_IMPL), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_CORE) }) +public class UcDeleteX_EntityName_X extends AbstractUcX_EntityName_X { + + /** Logger instance. */ + private static final Logger LOG = LoggerFactory.getLogger(UcDeleteX_EntityName_X.class); + + /** + * @param id the {@link X_EntityName_XEto#getId() primary key} of the {@link X_EntityName_XEto} to delete. + * @return {@code false} if the {@code id} was {@code null} and deletion was omitted, {@code true} otherwise. + */ + @RolesAllowed(ApplicationAccessControlConfig.PERMISSION_DELETE_X_ENTITY_NAME_X) + public boolean deleteX_EntityName_X(Long id) { + + if (id == null) { + LOG.info("ID of X_EntityName_X is null - omitting deletion."); + return false; + } + LOG.info("Deleting X_EntityName_X with ID {}.", id); + getRepository().deleteById(id); + return true; + } + + /** + * @param eto the {@link X_EntityName_XEto} to delete. + * @return {@code false} if the object was {@code null} and deletion was omitted, {@code true} otherwise. + */ + @RolesAllowed(ApplicationAccessControlConfig.PERMISSION_DELETE_X_ENTITY_NAME_X) + public boolean deleteX_EntityName_X(X_EntityName_XEto eto) { + + if (eto == null) { + LOG.info("X_EntityName_X is null - omitting deletion."); + return false; + } + Long id = eto.getId(); + return deleteX_EntityName_X(id); + } +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/UcFindX_EntityName_X.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/UcFindX_EntityName_X.java new file mode 100644 index 0000000000..749bcf7a08 --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/UcFindX_EntityName_X.java @@ -0,0 +1,56 @@ +package x_rootpackage_x.x_component_x.logic.x_scope_x.x_detail_x; + +import java.util.Optional; + +import javax.annotation.security.RolesAllowed; +import javax.inject.Named; +import javax.transaction.Transactional; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; + +import x_rootpackage_x.general.common.x_scope_x.security.ApplicationAccessControlConfig; +import x_rootpackage_x.x_component_x.common.x_scope_x.x_detail_x.X_EntityName_X; +import x_rootpackage_x.x_component_x.common.x_scope_x.x_detail_x.X_EntityName_XEto; +import x_rootpackage_x.x_component_x.dataaccess.x_scope_x.x_detail_x.X_EntityName_XEntity; + +/** + * Use-case to find instances of {@link X_EntityName_X}. + */ +@Named +@Transactional +@CobiGenTemplate(value = CobiGenJavaIncrements.LOGIC) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_IMPL), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_CORE) }) +public class UcFindX_EntityName_X extends AbstractUcX_EntityName_X { + + /** Logger instance. */ + private static final Logger LOG = LoggerFactory.getLogger(UcFindX_EntityName_X.class); + + /** + * @param id the {@link X_EntityName_XEntity#getId() primary key} of the requested {@link X_EntityName_XEto}. + * @return the {@link X_EntityName_XEto} or {@code null} if no such ETO exists. + */ + @RolesAllowed(ApplicationAccessControlConfig.PERMISSION_FIND_X_ENTITY_NAME_X) + public X_EntityName_XEto findX_EntityName_X(Long id) { + + LOG.debug("Get X_EntityName_X with id {} from database.", id); + if (id == null) { + return null; + } + Optional entity = getRepository().findById(id); + if (entity.isPresent()) { + return getBeanMapper().toEto(entity.get()); + } else { + return null; + } + } + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/UcSaveX_EntityName_X.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/UcSaveX_EntityName_X.java new file mode 100644 index 0000000000..ddd9997e47 --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/UcSaveX_EntityName_X.java @@ -0,0 +1,51 @@ +package x_rootpackage_x.x_component_x.logic.x_scope_x.x_detail_x; + +import java.util.Objects; + +import javax.annotation.security.RolesAllowed; +import javax.inject.Named; +import javax.transaction.Transactional; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; + +import x_rootpackage_x.general.common.x_scope_x.security.ApplicationAccessControlConfig; +import x_rootpackage_x.x_component_x.common.x_scope_x.x_detail_x.X_EntityName_X; +import x_rootpackage_x.x_component_x.common.x_scope_x.x_detail_x.X_EntityName_XEto; +import x_rootpackage_x.x_component_x.dataaccess.x_scope_x.x_detail_x.X_EntityName_XEntity; + +/** + * Use-case to save (insert or update) instances of {@link X_EntityName_X}. + */ +@Named +@Transactional +@CobiGenTemplate(value = CobiGenJavaIncrements.LOGIC) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_IMPL), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_CORE) }) +public class UcSaveX_EntityName_X extends AbstractUcX_EntityName_X { + + /** Logger instance. */ + private static final Logger LOG = LoggerFactory.getLogger(UcSaveX_EntityName_X.class); + + /** + * @param eto the {@link X_EntityName_XEto} to save. + * @return the {@link X_EntityName_XEntity#getId() primary key} of the saved {@link X_EntityName_XEto}. + */ + @RolesAllowed(ApplicationAccessControlConfig.PERMISSION_SAVE_X_ENTITY_NAME_X) + public Long saveX_EntityName_X(X_EntityName_XEto eto) { + + Objects.requireNonNull(eto); + LOG.debug("Saving X_EntityName_X with id {} to database.", eto.getId()); + X_EntityName_XEntity entity = getBeanMapper().toEntity(eto); + entity = getRepository().save(entity); + return entity.getId(); + } + +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/X_EntityName_XMapper.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/X_EntityName_XMapper.java new file mode 100644 index 0000000000..a4aa0eb17c --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/logic/x_scope_x/x_detail_x/X_EntityName_XMapper.java @@ -0,0 +1,65 @@ +package x_rootpackage_x.x_component_x.logic.x_scope_x.x_detail_x; + +import java.util.ArrayList; +import java.util.List; + +import org.mapstruct.Mapper; + +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; + +import x_rootpackage_x.x_component_x.common.x_scope_x.x_detail_x.X_EntityName_X; +import x_rootpackage_x.x_component_x.common.x_scope_x.x_detail_x.X_EntityName_XEto; +import x_rootpackage_x.x_component_x.dataaccess.x_scope_x.x_detail_x.X_EntityName_XEntity; + +/** + * {@link Mapper} for {@link X_EntityName_X}. + */ +@Mapper(componentModel = "cdi") +@CobiGenTemplate(value = CobiGenJavaIncrements.LOGIC) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_IMPL), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_CORE) }) +public interface X_EntityName_XMapper { + + /** + * @param items the {@link List} of {@link X_EntityName_XEntity}-objects to convert. + * @return the {@link List} of converted {@link X_EntityName_XEto}s. + */ + default List toEtos(List items) { + + List etos = new ArrayList<>(items.size()); + for (X_EntityName_XEntity item : items) { + etos.add(toEto(item)); + } + return etos; + } + + /** + * @param items the {@link List} of {@link X_EntityName_XEto}s to convert. + * @return the {@link List} of converted {@link X_EntityName_XEntity}-objects. + */ + default List toEntities(List items) { + + List entities = new ArrayList<>(items.size()); + for (X_EntityName_XEto item : items) { + entities.add(toEntity(item)); + } + return entities; + } + + /** + * @param item the {@link X_EntityName_XEntity} to map. + * @return the mapped {@link X_EntityName_XEto}. + */ + X_EntityName_XEto toEto(X_EntityName_XEntity item); + + /** + * @param item the {@link X_EntityName_XEto} to map. + * @return the mapped {@link X_EntityName_XEntity}. + */ + X_EntityName_XEntity toEntity(X_EntityName_XEto item); +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/service/x_scope_x/x_detail_x/X_EntityName_XRestService.java b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/service/x_scope_x/x_detail_x/X_EntityName_XRestService.java new file mode 100644 index 0000000000..496d273cdc --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/java/x_rootpackage_x/x_component_x/service/x_scope_x/x_detail_x/X_EntityName_XRestService.java @@ -0,0 +1,86 @@ +package x_rootpackage_x.x_component_x.service.x_scope_x.x_detail_x; + +import java.net.URI; +import java.util.Objects; + +import javax.inject.Inject; +import javax.validation.Valid; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +import com.devonfw.cobigen.api.annotation.CobiGenProperties; +import com.devonfw.cobigen.api.annotation.CobiGenProperty; +import com.devonfw.cobigen.api.annotation.CobiGenTemplate; +import com.devonfw.cobigen.api.template.CobiGenJavaIncrements; +import com.devonfw.cobigen.api.template.CobiGenJavaProperties; + +import x_rootpackage_x.x_component_x.common.x_scope_x.x_detail_x.X_EntityName_XEto; +import x_rootpackage_x.x_component_x.logic.x_scope_x.x_detail_x.UcDeleteX_EntityName_X; +import x_rootpackage_x.x_component_x.logic.x_scope_x.x_detail_x.UcFindX_EntityName_X; +import x_rootpackage_x.x_component_x.logic.x_scope_x.x_detail_x.UcSaveX_EntityName_X; + +/** + * REST-service for {@link X_EntityName_XEto}. + */ +@Path("/x_entity-name_x") +@CobiGenTemplate(value = CobiGenJavaIncrements.REST) +@CobiGenProperties({ +@CobiGenProperty(key = CobiGenJavaProperties.KEY_SCOPE, value = CobiGenJavaProperties.VALUE_SCOPE_IMPL), +@CobiGenProperty(key = CobiGenJavaProperties.KEY_MODULE, value = CobiGenJavaProperties.VALUE_MODULE_CORE) }) +public class X_EntityName_XRestService { + + @Inject + private UcFindX_EntityName_X ucFind; + + @Inject + private UcSaveX_EntityName_X ucSave; + + @Inject + private UcDeleteX_EntityName_X ucDelete; + + /** + * @param id the {@link X_EntityName_XEto#getId() primary key} of the requested {@link X_EntityName_XEto}. + * @return the {@link X_EntityName_XEto} for the given {@code id}. + */ + @GET + @Path("/{id}") + public X_EntityName_XEto findEto(@PathParam("id") Long id) { + + X_EntityName_XEto task = this.ucFind.findX_EntityName_X(id); + if (task == null) { + throw new NotFoundException("X_EntityName_X with id " + id + " does not exist."); + } + return task; + } + + /** + * @param eto the {@link X_EntityName_XEto} to save. + * @return the restful {@link Response}. + */ + @POST + @Path("/") + public Response saveEto(@Valid X_EntityName_XEto eto) { + + Long id = this.ucSave.saveX_EntityName_X(eto); + Long etoId = eto.getId(); + if (etoId == null || Objects.equals(etoId, id)) { + return Response.created(URI.create("/x_entity-name_x/" + id)).build(); + } + return Response.ok().build(); + } + + /** + * @param id the {@link X_EntityName_XEto#getId() primary key} of the {@link X_EntityName_XEto} to delete. + */ + @DELETE + @Path("/{id}") + public void deleteEto(@PathParam("id") Long id) { + + this.ucDelete.deleteX_EntityName_X(id); + } +} diff --git a/cobigen-templates/templates-devonfw-java/src/main/resources/META-INF/services/com.devonfw.cobigen.api.template.generator.CobiGenGenerator b/cobigen-templates/templates-devonfw-java/src/main/resources/META-INF/services/com.devonfw.cobigen.api.template.generator.CobiGenGenerator new file mode 100644 index 0000000000..4d825d804a --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/resources/META-INF/services/com.devonfw.cobigen.api.template.generator.CobiGenGenerator @@ -0,0 +1,4 @@ +com.devonfw.cobigen.api.template.generator.CobiGenGeneratorJavaTypeEtoProperties +com.devonfw.cobigen.api.template.generator.CobiGenGeneratorJavaTypeEtoSuperClass +com.devonfw.cobigen.api.template.generator.CobiGenGeneratorJavaTypeProperties +com.devonfw.cobigen.api.template.generator.CobiGenGeneratorJavaTypeEntitySuperInterface \ No newline at end of file diff --git a/cobigen-templates/templates-devonfw-java/src/main/resources/template-set.xml b/cobigen-templates/templates-devonfw-java/src/main/resources/template-set.xml new file mode 100644 index 0000000000..bd48d013ea --- /dev/null +++ b/cobigen-templates/templates-devonfw-java/src/main/resources/template-set.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cobigen/cobigen-core-api/pom.xml b/cobigen/cobigen-core-api/pom.xml index ddd6253af0..04a19190cf 100644 --- a/cobigen/cobigen-core-api/pom.xml +++ b/cobigen/cobigen-core-api/pom.xml @@ -21,6 +21,13 @@ commons-lang3 + + + io.github.m-m-m + mmm-base + 0.9.1 + + com.google.guava diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenCondition.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenCondition.java new file mode 100644 index 0000000000..26db81fa4a --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenCondition.java @@ -0,0 +1,28 @@ +package com.devonfw.cobigen.api.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import com.devonfw.cobigen.api.template.condition.CobiGenPredicate; + +import io.github.mmm.base.lang.Conjunction; + +/** + * Annotation for a condition in a {@link CobiGenTemplate}. Annotated types, methods, fields, constructors, etc. will + * only be generated, if the {@link #value() condition} applies and otherwise the entire annotated element will be + * omitted and does not occur in the generated output. + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface CobiGenCondition { + + /** + * @return the condition(s) that have to apply. + */ + Class[] value(); + + /** + * @return the {@link Conjunction} to combine multiple {@link CobiGenPredicate conditions}. + */ + Conjunction conjunction() default Conjunction.AND; + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenDynamicType.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenDynamicType.java new file mode 100644 index 0000000000..8d854a936b --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenDynamicType.java @@ -0,0 +1,24 @@ +package com.devonfw.cobigen.api.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.devonfw.cobigen.api.template.generator.CobiGenGenerator; + +/** + * Annotation to mark a type that is not a {@link CobiGenTemplate template} but a dynamic type. Such type allows to be + * extended or implemented while during instantiation it will be evaluated dynamically. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.TYPE_USE, ElementType.TYPE_PARAMETER, +ElementType.LOCAL_VARIABLE, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER }) +public @interface CobiGenDynamicType { + + /** + * @return the condition(s) that have to apply. + */ + Class value(); + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenProperties.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenProperties.java new file mode 100644 index 0000000000..173b0acfa0 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenProperties.java @@ -0,0 +1,17 @@ +package com.devonfw.cobigen.api.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Annotation for a set of {@link CobiGenProperty} annotations to be used in a {@link CobiGenTemplate}. + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface CobiGenProperties { + + /** + * @return the array of {@link CobiGenProperty} annotations to define. + */ + CobiGenProperty[] value(); + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenProperty.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenProperty.java new file mode 100644 index 0000000000..80fc81864d --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenProperty.java @@ -0,0 +1,24 @@ +package com.devonfw.cobigen.api.annotation; + +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Annotation for a property as {@link #key()} {@link #value()} pair for annotation in {@link CobiGenTemplate}. + */ +@Repeatable(CobiGenProperties.class) +@Retention(RetentionPolicy.RUNTIME) +public @interface CobiGenProperty { + + /** + * @return the property key. + */ + String key(); + + /** + * @return the property value. + */ + String value(); + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenTemplate.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenTemplate.java new file mode 100644 index 0000000000..f5e2bc519f --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/annotation/CobiGenTemplate.java @@ -0,0 +1,29 @@ +package com.devonfw.cobigen.api.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation to mark and configure a template written in Java. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE }) +public @interface CobiGenTemplate { + + /** + * @return the unique identifier of what is currently called "increment" in CobiGen. I would propose to use I18N for + * mapping this ID to a display title for CobiGen UI and template collections can ship with individual + * resource bundle properties providing these titles. Define a central type in your template collection + * defining all groups as constants and always reference a constant for this annotation property value. + */ + String value(); + + /** + * @return {@code true} if constant or static template for code artefact that does not depend on the input. It will be + * generated if triggered and not present. Once generated the file should never be touched. + */ + boolean constant() default false; + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/AbstractCobiGenCodeBlock.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/AbstractCobiGenCodeBlock.java new file mode 100644 index 0000000000..4b22d49614 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/AbstractCobiGenCodeBlock.java @@ -0,0 +1,320 @@ +package com.devonfw.cobigen.api.code; + +import java.io.IOException; +import java.util.List; + +/** + * Abstract base implementation of {@link CobiGenCodeBlock}. Typical usage shall work on the interface. However, all + * implementations need to extend this {@link AbstractCobiGenCodeBlock} class. Thus, it is legal to downcast if required + * to mutate the block structure. + */ +public abstract class AbstractCobiGenCodeBlock implements CobiGenCodeBlock { + + private static final String[] INDENTS = { // + " ", // 1 space + " ", // 2 spaces + " ", // 3 spaces + " ", // 4 spaces + " ", // 5 spaces + " ", // 6 spaces + " ", // 7 spaces + " ", // 8 spaces + " ", // 9 spaces + " ", // 10 spaces + " ", // 11 spaces + " ", // 12 spaces + " ", // 13 spaces + " ", // 14 spaces + " ", // 15 spaces + " ", // 16 spaces + }; + + private final String name; + + /** @see #getNext() */ + protected AbstractCobiGenCodeBlock next; + + /** @see #getIndent() */ + protected String indent; + + /** @see #getIndentFallbackWidth() */ + int indentFallbackWidth; + + /** + * The constructor. + * + * @param name the {@link #getName() name}. + */ + public AbstractCobiGenCodeBlock(String name) { + + super(); + this.name = name; + } + + @Override + public String getName() { + + return this.name; + } + + /** + * @return the indent for all lines in this block (that are added dynamically). + */ + public String getIndent() { + + return this.indent; + } + + /** + * @param indent the new value of {@link #getIndent()}. Can only be changed once. + */ + public void setIndent(String indent) { + + if ((this.indent != null) && !this.indent.equals(indent)) { + throw new IllegalStateException("Indent cannot be changed!"); + } + this.indent = indent; + } + + String getIndentWithFallback() { + + if (this.indent != null) { + return this.indent; + } + if (this.indentFallbackWidth > 0) { + int i = this.indentFallbackWidth - 1; + if (i < INDENTS.length) { + return INDENTS[i]; + } + char[] spaces = new char[this.indentFallbackWidth * 2]; + for (i = 0; i < spaces.length; i++) { + spaces[i] = ' '; + } + return new String(spaces); + } + return null; + } + + /** + * @return the indent width to use if {@link #getIndent() indent} is {@code null}. + */ + public int getIndentFallbackWidth() { + + return this.indentFallbackWidth; + } + + /** + * @param width the new value of {@link #getIndentFallbackWidth()}. + */ + public void setIndentFallbackWidth(int width) { + + this.indentFallbackWidth = width; + } + + @Override + public AbstractCobiGenCodeBlock getNext() { + + return this.next; + } + + @Override + public AbstractCobiGenCodeBlock getNext(String blockName) { + + AbstractCobiGenCodeBlock block = this; + while (block != null) { + if (block.getName().equals(blockName)) { + break; + } + block = block.next; + } + if (block == null) { + // build-in fallbacks + if (NAME_SETTERS.equals(blockName)) { + return getNext(NAME_GETTERS); + } + } + return block; + } + + @Override + public CobiGenAtomicCodeBlock addLine(String line) { + + return addLine(false, line); + } + + @Override + public CobiGenAtomicCodeBlock addLines(String... lines) { + + return addLines(false, lines); + } + + /** + * @param raw - {@code true} to add the given {@code line} unmodified, {@code false} otherwise (to auto-indent). + * @param line the source-code line to add to the end of this block. + * @return the {@link CobiGenAtomicCodeBlock} where the given {@code line} has been added. + */ + public abstract CobiGenAtomicCodeBlock addLine(boolean raw, String line); + + /** + * @param raw - {@code true} to add the given {@code lines} unmodified, {@code false} otherwise (to auto-indent). + * @param lines the source-code lines to add to the end of this block. + * @return the {@link CobiGenAtomicCodeBlock} where the given {@code lines} have been added. + */ + public abstract CobiGenAtomicCodeBlock addLines(boolean raw, String... lines); + + /** + * @param raw - {@code true} to add the given {@code lines} unmodified, {@code false} otherwise (to auto-indent). + * @param lines the source-code lines to add to the end of this block. + * @return the {@link CobiGenAtomicCodeBlock} where the given {@code lines} have been added. + */ + public CobiGenAtomicCodeBlock addLines(boolean raw, List lines) { + + String[] linesArray = null; + if ((lines != null) && !lines.isEmpty()) { + linesArray = lines.toArray(new String[lines.size()]); + } + return addLines(raw, linesArray); + } + + @Override + public abstract AbstractCobiGenCodeBlock getChild(); + + @Override + public AbstractCobiGenCodeBlock getChild(String blockName) { + + AbstractCobiGenCodeBlock child = getChild(); + if (child == null) { + return null; + } + return child.getNext(blockName); + } + + @Override + public AbstractCobiGenCodeBlock getLast() { + + AbstractCobiGenCodeBlock block = this; + while (block.next != null) { + block = block.next; + } + return block; + } + + /** + * Appends as {@link #getLast() last} {@link #getNext() sibling} so to the very end of the code. In most cases you + * want to use {@link CobiGenCompositeCodeBlock#appendChild(AbstractCobiGenCodeBlock)} instead.
+ * ATTENTION: It is highly recommended to only have {@link #getNext() siblings} of the same kind. So + * {@link CobiGenCompositeCodeBlock}s should only have the same type of {@link #getNext() siblings} as the same + * applies for {@link CobiGenAtomicCodeBlock}s. + * + * @param last the {@link AbstractCobiGenCodeBlock} to append as the {@link #getLast() last} {@link #getNext() + * sibling}. + */ + public void appendLast(AbstractCobiGenCodeBlock last) { + + getLast().next = last; + } + + /** + * @param blockName the {@link #getName() name} of the next block to insert. + * @return the new {@link CobiGenCompositeCodeBlock} that has been inserted. + */ + public abstract AbstractCobiGenCodeBlock insertNext(String blockName); + + /** + * @param block the {@link AbstractCobiGenCodeBlock} to insert as {@link #getNext() next sibling}. + */ + protected void insertNext(AbstractCobiGenCodeBlock block) { + + block.next = this.next; + this.next = block; + adopt(block); + } + + void adopt(AbstractCobiGenCodeBlock block) { + + if (block.indent == null) { + block.indent = this.indent; + } + if (block.indentFallbackWidth == 0) { + block.indentFallbackWidth = this.indentFallbackWidth; + } + } + + /** + * @return {@code true} if entirely empty meaning it has no {@link #getChild() child}ren nor + * {@link CobiGenAtomicCodeBlock#getLineCount() lines}. + */ + public abstract boolean isEmpty(); + + /** + * Clears this block so it is empty. It will remove the {@link #getChild() children} and all code-lines. + */ + public abstract void clear(); + + /** + * @param writer the {@link Appendable} to write to. + * @throws IOException if thrown by {@link Appendable}. + */ + public void write(Appendable writer) throws IOException { + + write(writer, true); + } + + /** + * @param writer the {@link Appendable} to write to. + * @param withSiblings - {@code true} to include all {@link #getNext() next} siblings, {@code false} to only write + * this block itself. + * @throws IOException if thrown by {@link Appendable}. + */ + public void write(Appendable writer, boolean withSiblings) throws IOException { + + writeLines(writer); + AbstractCobiGenCodeBlock child = getChild(); + if (child != null) { + child.write(writer, true); + } + if (withSiblings && (this.next != null)) { + this.next.write(writer, true); + } + } + + /** + * Writes the direct source-code lines of this block. + * + * @param writer the {@link Appendable} to write to. + * @throws IOException if thrown by {@link Appendable}. + */ + protected void writeLines(Appendable writer) throws IOException { + + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + toString(sb, "|-"); + return sb.toString(); + } + + private void toString(StringBuilder sb, String prefix) { + + try { + sb.append(prefix); + sb.append(this.name); + sb.append(" "); + sb.append(getClass().getSimpleName()); + sb.append('\n'); + writeLines(sb); + AbstractCobiGenCodeBlock child = getChild(); + if (child != null) { + child.toString(sb, prefix + "-"); + } + if (this.next != null) { + this.next.toString(sb, prefix); + } + } catch (IOException e) { + sb.append(e.toString()); + } + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/CobiGenAtomicCodeBlock.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/CobiGenAtomicCodeBlock.java new file mode 100644 index 0000000000..6ce6e5aec6 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/CobiGenAtomicCodeBlock.java @@ -0,0 +1,109 @@ +package com.devonfw.cobigen.api.code; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Base class for an atomic {@link CobiGenCodeBlock}. It will have source-code but can not have children. + */ +public class CobiGenAtomicCodeBlock extends AbstractCobiGenCodeBlock { + + private final List lines; + + /** + * The constructor. + * + * @param name the {@link #getName() name}. + */ + public CobiGenAtomicCodeBlock(String name) { + + super(name); + this.lines = new ArrayList<>(); + } + + @Override + public final AbstractCobiGenCodeBlock getChild() { + + return null; + } + + @Override + public boolean isEmpty() { + + return getLineCount() == 0; + } + + /** + * @return the number of lines in this section. + */ + public int getLineCount() { + + return this.lines.size(); + } + + @Override + public CobiGenAtomicCodeBlock insertNext(String blockName) { + + CobiGenAtomicCodeBlock block = new CobiGenAtomicCodeBlock(blockName); + insertNext(block); + return block; + } + + @Override + public CobiGenAtomicCodeBlock addAtomicChild(String blockName) { + + return this; + } + + @Override + public CobiGenAtomicCodeBlock addLine(boolean raw, String line) { + + assert (line != null); + if (!raw && !line.isEmpty()) { + String prefix = getIndentWithFallback(); + if (prefix != null) { + line = prefix + line; + } + } + this.lines.add(line); + return this; + } + + @Override + public CobiGenAtomicCodeBlock addLines(boolean raw, String... codeLines) { + + if (codeLines != null) { + for (String line : codeLines) { + addLine(raw, line); + } + } + return this; + } + + @Override + public void clear() { + + this.lines.clear(); + } + + @Override + protected void writeLines(Appendable writer) throws IOException { + + for (String line : this.lines) { + writeLine(writer, line); + } + } + + /** + * @param writer the {@link Appendable} to write to. + * @param line the line to {@link Appendable#append(CharSequence) write}. + * @throws IOException if thrown by {@link Appendable}. + */ + protected void writeLine(Appendable writer, String line) throws IOException { + + writer.append(line); + writer.append('\n'); + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/CobiGenCodeBlock.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/CobiGenCodeBlock.java new file mode 100644 index 0000000000..d401521114 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/CobiGenCodeBlock.java @@ -0,0 +1,127 @@ +package com.devonfw.cobigen.api.code; + +import com.devonfw.cobigen.api.template.out.CobiGenOutput; + +/** + * Interface for a section of the {@link CobiGenOutput}. + * + * @see CobiGenOutput#getCode() + */ +public interface CobiGenCodeBlock { + + // top-level + + /** @{@link #getName() Name} for the file header. */ + String NAME_HEADER = "header"; + + /** @{@link #getName() Name} for the package. */ + String NAME_PACKAGE = "package"; + + /** @{@link #getName() Name} for the imports. */ + String NAME_IMPORTS = "imports"; + + /** @{@link #getName() Name} for the type declaration including doc. */ + String NAME_DECLARATION = "declaration"; + + /** @{@link #getName() Name} for the fields. */ + String NAME_FIELDS = "fields"; + + /** @{@link #getName() Name} for the constructors. */ + String NAME_CONSTRUCTORS = "constructors"; + + /** @{@link #getName() Name} for the methods. */ + String NAME_METHODS = "methods"; + + /** @{@link #getName() Name} for the getters. */ + String NAME_GETTERS = "getters"; + + /** @{@link #getName() Name} for the setters. */ + String NAME_SETTERS = "setters"; + + /** @{@link #getName() Name} for the nests (inner types). */ + String NAME_NESTS = "nests"; + + /** @{@link #getName() Name} for the footer (typically just "}"). */ + String NAME_FOOTER = "footer"; + + // children + + /** + * @{@link #getName() Name} for the "intro" of a block like a field, constructor, method, etc. containing potential + * {@link #NAME_APIDOC apidoc}, {@link #NAME_COMMENT comment}(s), or {@link #NAME_ANNOTATIONS annotations}. + */ + String NAME_INTRO = "intro"; + + // atomics (leaves) + + /** @{@link #getName() Name} for the api-doc(s). */ + String NAME_APIDOC = "comment"; + + /** @{@link #getName() Name} for the comment(s). */ + String NAME_COMMENT = "comment"; + + /** @{@link #getName() Name} for the annotations(s). */ + String NAME_ANNOTATIONS = "annotations"; + + /** + * @{@link #getName() Name} for the actual code (field, constructor, method, etc.) without {@link #NAME_INTRO intro}. + */ + String NAME_CODE = "code"; + + /** + * @return the name of this code-block. Top-level blocks will have names for the according section such as + * {@link #NAME_HEADER}, {@link #NAME_PACKAGE}, {@link #NAME_IMPORTS}, {@link #NAME_DECLARATION}, + * {@link #NAME_FIELDS}, {@link #NAME_CONSTRUCTORS}, {@link #NAME_METHODS}, etc. Child blocks such as fields + * or methods will have the according field name. They may even have {@link #getChild() children} named + */ + String getName(); + + /** + * @param blockName the {@link #getName() name} of the {@link #getChild() child block} to create and append in case of + * a {@link CobiGenCompositeCodeBlock composite block}. + * @return the {@link CobiGenAtomicCodeBlock}. Will be this block itself if already {@link CobiGenAtomicCodeBlock + * atomic}. + */ + CobiGenAtomicCodeBlock addAtomicChild(String blockName); + + /** + * @param line the source-code line to add to the end of this block. + * @return the {@link CobiGenAtomicCodeBlock} where the given {@code line} has been added. + */ + CobiGenAtomicCodeBlock addLine(String line); + + /** + * @param lines the source-code lines to add to the end of this block. + * @return the {@link CobiGenAtomicCodeBlock} where the given {@code lines} have been added. + */ + CobiGenAtomicCodeBlock addLines(String... lines); + + /** + * @return the next {@link CobiGenCodeBlock code-block}. + */ + CobiGenCodeBlock getNext(); + + /** + * @param name the {@link #getName() name} of the requested {@link #getNext() sibling} {@link CobiGenCodeBlock}. + * @return this {@link CobiGenCodeBlock} or any {@link #getNext() next} successor with the given {@link #getName() + * name} or {@code null} if not found. + */ + CobiGenCodeBlock getNext(String name); + + /** + * @return the last {@link #getNext() sibling}. Will be this block itself if {@link #getNext() next} is {@code null}. + */ + AbstractCobiGenCodeBlock getLast(); + + /** + * @return the first child or {@code null} if this {@link CobiGenCodeBlock} does not have children. + */ + CobiGenCodeBlock getChild(); + + /** + * @param name the {@link #getName() name} of the requested {@link #getChild() child} {@link CobiGenCodeBlock}. + * @return the first {@link #getChild()} with the given {@link #getName() name} or {@code null} if not found. + */ + CobiGenCodeBlock getChild(String name); + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/CobiGenCodeProperty.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/CobiGenCodeProperty.java new file mode 100644 index 0000000000..dce9d7838d --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/CobiGenCodeProperty.java @@ -0,0 +1,84 @@ +package com.devonfw.cobigen.api.code; + +import java.util.Objects; + +/** + * Simple container for property of a code-type. + */ +public final class CobiGenCodeProperty { + + private final String name; + + private final String type; + + private final String description; + + /** + * The constructor. + * + * @param name the {@link #getName() property name}. + * @param type the {@link #getType() qualified name of the property type}. + * @param description the {@link #getDescription() description}. + */ + public CobiGenCodeProperty(String name, String type, String description) { + + super(); + this.name = name; + this.type = type; + this.description = description; + } + + /** + * @return name the name of the property (e.g. "id", "firstName", etc.). + * @see java.lang.reflect.Field#getName() + */ + public String getName() { + + return this.name; + } + + /** + * @return type the {@link com.devonfw.cobigen.api.template.out.QualifiedName#getQualifiedName() qualified name} of + * the property type. + * @see java.lang.reflect.Field#getType() + */ + public String getType() { + + return this.type; + } + + /** + * @return description the optional property description for API documentation. May be {@code null} what will suppress + * generation of API documentation (e.g. JavaDoc). + */ + public String getDescription() { + + return this.description; + } + + @Override + public int hashCode() { + + return Objects.hash(this.description, this.name, this.type); + } + + @Override + public boolean equals(Object obj) { + + if (this == obj) { + return true; + } else if ((obj == null) || (getClass() != obj.getClass())) { + return false; + } + CobiGenCodeProperty other = (CobiGenCodeProperty) obj; + return Objects.equals(this.description, other.description) && Objects.equals(this.name, other.name) + && Objects.equals(this.type, other.type); + } + + @Override + public String toString() { + + return this.name + ":" + this.type + "(" + this.description + ")"; + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/CobiGenCompositeCodeBlock.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/CobiGenCompositeCodeBlock.java new file mode 100644 index 0000000000..699bb25895 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/code/CobiGenCompositeCodeBlock.java @@ -0,0 +1,114 @@ +package com.devonfw.cobigen.api.code; + +/** + * Base class for a composite {@link CobiGenCodeBlock}. It has children but no direct source-code. + */ +public class CobiGenCompositeCodeBlock extends AbstractCobiGenCodeBlock { + + private AbstractCobiGenCodeBlock child; + + /** + * The constructor. + * + * @param name the {@link #getName() name}. + */ + public CobiGenCompositeCodeBlock(String name) { + + super(name); + } + + @Override + public final AbstractCobiGenCodeBlock getChild() { + + return this.child; + } + + void setChild(AbstractCobiGenCodeBlock child) { + + adopt(child); + this.child = child; + } + + @Override + public CobiGenCompositeCodeBlock insertNext(String blockName) { + + CobiGenCompositeCodeBlock composite = new CobiGenCompositeCodeBlock(blockName); + insertNext(composite); + return composite; + } + + @Override + public CobiGenAtomicCodeBlock addAtomicChild(String blockName) { + + CobiGenAtomicCodeBlock block = new CobiGenAtomicCodeBlock(blockName); + appendChild(block); + return block; + } + + /** + * @param blockName the {@link #getName() name} of the new block. + * @return the new {@link CobiGenCompositeCodeBlock} with the given {@link #getName() name} appended as last child. + */ + public CobiGenCompositeCodeBlock addCompositeChild(String blockName) { + + CobiGenCompositeCodeBlock block = new CobiGenCompositeCodeBlock(blockName); + appendChild(block); + return block; + } + + private CobiGenAtomicCodeBlock getOrCreateLastAtomicChild() { + + if (this.child == null) { + return addAtomicChild(NAME_CODE); + } + AbstractCobiGenCodeBlock lastChild = this.child.getLast(); + if (lastChild instanceof CobiGenAtomicCodeBlock) { + return (CobiGenAtomicCodeBlock) lastChild; + } else { + return ((CobiGenCompositeCodeBlock) lastChild).getOrCreateLastAtomicChild(); + } + + } + + @Override + public CobiGenAtomicCodeBlock addLine(boolean raw, String codeLine) { + + CobiGenAtomicCodeBlock block = getOrCreateLastAtomicChild(); + block.addLine(raw, codeLine); + return block; + } + + @Override + public CobiGenAtomicCodeBlock addLines(boolean raw, String... codeLines) { + + CobiGenAtomicCodeBlock block = getOrCreateLastAtomicChild(); + block.addLines(raw, codeLines); + return block; + } + + /** + * @param lastChild the {@link AbstractCobiGenCodeBlock} to append as {@link #getLast() last} {@link #getChild() + * child} so to the end of this block. + */ + public void appendChild(AbstractCobiGenCodeBlock lastChild) { + + if (this.child == null) { + setChild(lastChild); + } else { + this.child.getLast().insertNext(lastChild); + } + } + + @Override + public boolean isEmpty() { + + return this.child == null; + } + + @Override + public final void clear() { + + this.child = null; + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/AbstractCobiGenModel.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/AbstractCobiGenModel.java new file mode 100644 index 0000000000..7752f7c781 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/AbstractCobiGenModel.java @@ -0,0 +1,246 @@ +package com.devonfw.cobigen.api.model; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Implementation of {@link CobiGenModel}. + */ +public abstract class AbstractCobiGenModel implements CobiGenModel { + + private static final Logger LOG = LoggerFactory.getLogger(AbstractCobiGenModel.class); + + private final AbstractCobiGenModel parent; + + private final Map map; + + /** + * The constructor. + * + * @param parent the parent model or {@code null} if this is the root model. + */ + public AbstractCobiGenModel(CobiGenModel parent) { + + this(parent, new HashMap<>()); + } + + /** + * The constructor. + * + * @param parent the parent model or {@code null} if this is the root model. + * @param map the underlying {@link Map}. + */ + protected AbstractCobiGenModel(CobiGenModel parent, Map map) { + + super(); + this.parent = (AbstractCobiGenModel) parent; + this.map = map; + } + + /** + * @return the inherited parent {@link AbstractCobiGenModel model} or {@code null} if this is the root model. + */ + @Override + public AbstractCobiGenModel getParent() { + + return this.parent; + } + + /** + * This method is only for CobiGen internal use! + * + * @return the original {@link Map} with variables that preserves the original syntax and case of the variables. + */ + public Map getOriginalMap() { + + return this.map; + } + + @Override + public Object get(String name) { + + Object value = getInternal(name); + if (value == null) { + String normalizeKey = CobiGenVariableDefinition.normalizeName(name); + if (!normalizeKey.equals(name)) { + value = getInternal(normalizeKey); + } + } + return value; + } + + private Object getInternal(String key) { + + Object value = this.map.get(key); + if ((value == null) && (this.parent != null) && !this.map.containsKey(key)) { + value = this.parent.getInternal(key); + } + return value; + } + + @Override + public boolean containsKey(String name) { + + if (containsKeyInternal(name)) { + return true; + } + String normalizedName = CobiGenVariableDefinition.normalizeName(name); + if (normalizedName.equals(name)) { + return false; + } + return containsKeyInternal(normalizedName); + } + + /** + * @param key the raw key to check. + * @return {@code true} if {@link #containsKeyInternal(String) this model itself contains} the given {@code key} or + * one of its parents does, {@code false} otherwise. + */ + private boolean containsKeyInternal(String key) { + + if (this.map.containsKey(key)) { + return true; + } + if (this.parent != null) { + return this.parent.containsKeyInternal(key); + } + return false; + } + + /** + * @param name the name of the variable to set. + * @param value the value of the variable to set. + * @return the previous value that has been replaced because it has the same + * {@link CobiGenVariableDefinition#normalizeName(String) normalized name} or {@code null} if this variable + * has been initially defined in this model. + * @see java.util.Map#put(Object, Object) + */ + @Override + public Object put(String name, Object value) { + + return put(name, value, false); + } + + /** + * @param name the name of the variable to set. + * @param value the value of the variable to set. + * @param skipOriginalMap - {@code true} to skip putting the value also into {@link #getOriginalMap() original map} + * (e.g. from Constructor), {@code false} otherwise. + * @return the previous value that has been replaced because it has the same + * {@link CobiGenVariableDefinition#normalizeName(String) normalized name} or {@code null} if this variable + * has been initially defined in this model. + * @see java.util.Map#put(Object, Object) + */ + protected Object put(String name, Object value, boolean skipOriginalMap) { + + String normalizedName = CobiGenVariableDefinition.normalizeName(name); + Object old = this.map.put(normalizedName, value); + if (!skipOriginalMap) { + Map originalMap = getOriginalMap(); + if (originalMap != this.map) { + originalMap.put(name, value); + } + } + return old; + } + + /** + * @param modelAsMap the raw model as plain {@link Map}. + * @see Map#putAll(Map) + */ + public void putAll(Map modelAsMap) { + + putAll(modelAsMap, false); + } + + /** + * @param modelAsMap the raw model as plain {@link Map}. + * @param skipOriginalMap - {@code true} to skip putting the value also into {@link #getOriginalMap() original map} + * (e.g. from Constructor), {@code false} otherwise. + * @see #putAll(Map) + */ + protected void putAll(Map modelAsMap, boolean skipOriginalMap) { + + for (Entry entry : modelAsMap.entrySet()) { + String name = entry.getKey(); + Object value = entry.getValue(); + put(name, value, skipOriginalMap); + } + } + + @Override + public String resolve(String string, char replacementForDot, VariableSyntax syntax) { + + Pattern pattern = syntax.getPattern(); + Matcher matcher = pattern.matcher(string); + if (!matcher.find()) { + return string; + } + StringBuilder sb = new StringBuilder(string.length()); + do { + String variableName = syntax.getVariable(matcher); + String variableValue = getVariable(variableName); + String replacement; + if (variableValue == null) { + LOG.warn("Undefined variable {}", variableName); + replacement = ""; + } else { + replacement = syntax.resolve(variableValue, matcher, variableName); + } + if (replacementForDot != '.') { + replacement = replacement.replace('.', replacementForDot); + } + matcher.appendReplacement(sb, replacement); + } while (matcher.find()); + matcher.appendTail(sb); + String resolved = sb.toString(); + if (replacementForDot == '/') { + // Cleanup empty path segments + resolved = resolved.replaceAll("/+", "/"); + } + return resolved; + } + + /** + * @return this model as {@link Map}. Further changes to this model or one of its ancestors are NOT reflected by the + * returned {@link Map}. This is an expensive operation that may only be called to pass the model to a + * template-engine that cannot support {@link CobiGenModel} directly. + */ + public Map asMap() { + + HashMap result = new HashMap<>(this.map.size()); + asMap(result); + return result; + } + + /** + * @see #asMap() + * @param result the {@link Map} to populate. + */ + private void asMap(Map result) { + + if (this.parent != null) { + this.parent.asMap(result); + } + result.putAll(getOriginalMap()); + } + + @Override + public CobiGenModel copy() { + + Map newMap = new HashMap<>(this.map.size()); + AbstractCobiGenModel model = this; + while (model != null) { + newMap.putAll(model.getOriginalMap()); + model = model.parent; + } + return new CobiGenModelDefault(newMap); + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/CobiGenModel.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/CobiGenModel.java new file mode 100644 index 0000000000..fa66139985 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/CobiGenModel.java @@ -0,0 +1,136 @@ +package com.devonfw.cobigen.api.model; + +import java.lang.reflect.Type; + +/** + * Interface for the model of CobiGen. It is similar to {@link java.util.Map} or {@link java.util.Properties}. However, + * {@link #get(String) retrieval} is case-insensitive. Also is provides the ability to {@link #resolve(String) resolve} + * variables from any given {@link String} replacing them with the values from this model according to different + * variants of supported {@link VariableSyntax} including case-conversions and other advanced features. Also a + * {@link CobiGenModel} may inherit from a parent model. + */ +public interface CobiGenModel { + + /** + * @param variableName the {@link CobiGenVariableDefinition#getName() name} of the variable to resolve. + * @return the value of the requested variable or {@code null} if not defined. + * @see java.util.Map#get(Object) + */ + Object get(String variableName); + + /** + * @param type of the requested variable. + * @param variable the {@link CobiGenVariableDefinition}. + * @return the value of the specified variable. + * @see CobiGenVariableDefinition#getValue(CobiGenModel) + */ + default T get(CobiGenVariableDefinition variable) { + + return variable.getValue(this); + } + + /** + * @param variableName the name of the variable to resolve. + * @return the value of the requested variable or {@code null} if not defined. + * @throws IllegalArgumentException if the requested variable exists but its {@link #get(String) value} is not a + * {@link String}. + * @see #get(String) + */ + default String getVariable(String variableName) throws IllegalArgumentException { + + Object value = get(variableName); + if (value == null) { + return null; + } else if ((value instanceof CharSequence) || (value instanceof Number) || (value instanceof Boolean)) { + return value.toString(); + } else if (value instanceof Class) { + Class type = (Class) value; + if ("java.lang".equals(type.getPackageName())) { + return type.getSimpleName(); + } else { + return type.getName(); + } + } else if (value instanceof Type) { + return ((Type) value).getTypeName(); + } else { + throw new IllegalArgumentException("The variable '" + variableName + + "' was requested as String but is actually of type " + value.getClass().getName()); + } + } + + /** + * @param string the {@link String} where to resolve all variables. + * @return the given {@code string} with all variables (e.g. ${variableName#uncapfirst} or + * X_VariableName_X) replaced with those defined by this model. + */ + default String resolve(String string) { + + return resolve(string, '.'); + } + + /** + * @param string the {@link String} where to resolve all variables. + * @param replacementForDot the character used as replacement for the dot character ('.') or '\0' for no replacement + * (remove dots according to case syntax). + * @return the given {@code string} with all variables (e.g. ${variableName#uncapfirst} or + * X_VariableName_X) replaced with those defined by this model. + */ + default String resolve(String string, char replacementForDot) { + + String result = string; + for (VariableSyntax syntax : VariableSyntax.values()) { + result = resolve(result, replacementForDot, syntax); + } + return result; + } + + /** + * @param string the {@link String} where to resolve all variables. + * @param replacementForDot the character used as replacement for the dot character ('.') or '\0' for no replacement + * (remove dots according to case syntax). + * @param syntax the {@link VariableSyntax}. + * @return the given {@code string} with all variables (e.g. ${variableName#uncapfirst} or + * X_VariableName_X) replaced with those defined by this model. + */ + String resolve(String string, char replacementForDot, VariableSyntax syntax); + + /** + * @param variableName the name of the variable to check. + * @return {@code true} if the requested variable is defined, {@code false} otherwise. + * @see java.util.Map#containsKey(Object) + */ + boolean containsKey(String variableName); + + /** + * @param name the name of the variable to set. + * @param value the value of the variable to set. + * @return the previous value that has been replaced because it has the same normalized + * {@link CobiGenVariableDefinition#getName() name} or {@code null} if this variable has been initially + * defined in this model. + * @see java.util.Map#put(Object, Object) + */ + Object put(String name, Object value); + + /** + * @param type of the variable value. + * @param variableDefinition the {@link CobiGenVariableDefinition} of the variable to set. + * @param value the value of the variable to set. + * @return the previous value that has been replaced because it has the same normalized name or {@code null} if this + * variable has been initially defined in this model. + */ + default Object put(CobiGenVariableDefinition variableDefinition, T value) { + + return variableDefinition.setValue(this, value); + } + + /** + * @return the parent {@link CobiGenModel model} to inherit from or {@code null} if this is the root model. + */ + CobiGenModel getParent(); + + /** + * @return a new {@link CobiGenModel} instance that is a flat copy of this model. + */ + CobiGenModel copy(); + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/CobiGenModelDefault.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/CobiGenModelDefault.java new file mode 100644 index 0000000000..9ee4d2f781 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/CobiGenModelDefault.java @@ -0,0 +1,81 @@ +package com.devonfw.cobigen.api.model; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +/** + * Implementation of {@link CobiGenModel}. + */ +public class CobiGenModelDefault extends AbstractCobiGenModel { + + private final Map originalMap; + + /** + * The constructor. + */ + public CobiGenModelDefault() { + + this(null, new HashMap<>()); + } + + /** + * The constructor. + * + * @param originalMap the {@link #getOriginalMap() original map} with the variables. + */ + public CobiGenModelDefault(Map originalMap) { + + this(null, originalMap); + } + + /** + * The constructor. + * + * @param parent the {@link #getParent() parent model} to inherit from. + */ + public CobiGenModelDefault(CobiGenModel parent) { + + this(parent, new HashMap<>()); + } + + /** + * The constructor. + * + * @param parent the {@link #getParent() parent model} to inherit from. + * @param originalMap the {@link #getOriginalMap() original map} with the variables. + */ + public CobiGenModelDefault(CobiGenModel parent, Map originalMap) { + + super(parent); + this.originalMap = originalMap; + putAll(originalMap); + } + + @Override + public Map getOriginalMap() { + + return this.originalMap; + } + + public static CobiGenModelDefault fromLegacyMap(Map legacyModel) { + + Map map = new HashMap<>(); + Map variables = null; + for (Entry entry : legacyModel.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + if (CobiGenVariableDefinitions.VARIABLES.getName().equals(key)) { + variables = (Map) value; + } else { + map.put(key, value); + } + } + if (variables != null) { + map.putAll(variables); + } + CobiGenModelDefault model = new CobiGenModelDefault(map); + return model; + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/CobiGenVariableDefinition.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/CobiGenVariableDefinition.java new file mode 100644 index 0000000000..0cd71052df --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/CobiGenVariableDefinition.java @@ -0,0 +1,200 @@ +package com.devonfw.cobigen.api.model; + +import java.util.function.Supplier; + +import io.github.mmm.base.text.CaseSyntax; + +/** + * Class for the definition of a variable of the {@link CobiGenModel}. + * + * @param the {@link #getType() value type}. + */ +public class CobiGenVariableDefinition { + + @SuppressWarnings("rawtypes") + private static final Supplier NO_DEFAULT_VALUE = () -> null; + + private final String name; + + private final String[] synonyms; + + private final Class type; + + private final Supplier defaultValueSupplier; + + /** + * The constructor. + * + * @param name the {@link #getName() variable name}. + * @param type the {@link #getType() variable type}. + */ + public CobiGenVariableDefinition(String name, Class type) { + + this(name, type, NO_DEFAULT_VALUE); + } + + /** + * The constructor. + * + * @param name the {@link #getName() variable name}. + * @param type the {@link #getType() variable type}. + * @param defaultValueSupplier the {@link Supplier} for the {@link #getDefaultValue() default value}. + * @param synonyms the optional synonyms for the {@link #getName() variable name}. Synonyms are legacy names that are + * still supported for backwards compatibility. They are considered deprecated in case they are still used. + */ + public CobiGenVariableDefinition(String name, Class type, Supplier defaultValueSupplier, String... synonyms) { + + super(); + this.name = name; + this.type = type; + this.defaultValueSupplier = defaultValueSupplier; + this.synonyms = synonyms; + } + + @SuppressWarnings("unchecked") + private static Class getType(V value) { + + if (value == null) { + return null; + } + return (Class) value.getClass(); + } + + /** + * @return the name of the variable. + * @see CobiGenModel#get(String) + */ + public String getName() { + + return this.name; + } + + /** + * @return the {@link Class} reflecting the value of the variable. + */ + public Class getType() { + + return this.type; + } + + /** + * @return the optional default value to use if the variable is not explicitly configured. + */ + public T getDefaultValue() { + + return this.defaultValueSupplier.get(); + } + + /** + * @param model the {@link CobiGenModel}. + * @return the value of the variable from the given {@link CobiGenModel}. If undefined the {@link #getDefaultValue() + * default value} is returned, what may also be {@code null}. + */ + @SuppressWarnings("unchecked") + public T getValue(CobiGenModel model) { + + Object value = model.get(this.name); + if (value == null) { + return getDefaultValue(); + } + if (this.type == null) { + return (T) value; + } else { + return this.type.cast(value); + } + } + + /** + * @param model the {@link CobiGenModel}. + * @param value the new value of the variable for the given {@link CobiGenModel}. + * @return the previous value that has been replaced because it has the same {@link #normalizeName(String) normalized} + * {@link #getName() name} or {@code null} if this variable has been initially defined in the given + * {@code model}. + */ + public Object setValue(CobiGenModel model, T value) { + + Object old = model.put(this.name, value); + for (String synonym : this.synonyms) { + model.put(synonym, value); + } + return old; + } + + /** + * @param name the variable name to normalize. + * @return the normalized name. + */ + public static String normalizeName(String name) { + + return CaseSyntax.normalizeExample(name); + } + + @Override + public String toString() { + + return this.name; + } + + /** + * @param type of the variable value. + * @param name the {@link #getName() variable name}. + * @param type the {@link #getType() type} of the {@link #getValue(CobiGenModel) variable value}. + * @return the new {@link CobiGenVariableDefinition} created from the given arguments. + */ + public static CobiGenVariableDefinition ofType(String name, Class type) { + + return new CobiGenVariableDefinition<>(name, type); + } + + /** + * @param type of the variable value. + * @param name the {@link #getName() variable name}. + * @param defaultValue the {@link #getDefaultValue() default value}. + * @return the new {@link CobiGenVariableDefinition} created from the given arguments. + */ + public static CobiGenVariableDefinition ofDefaultValue(String name, T defaultValue) { + + return new CobiGenVariableDefinition<>(name, getType(defaultValue), () -> defaultValue); + } + + /** + * @param name the {@link #getName() variable name}. + * @return the new {@link CobiGenVariableDefinition} created from the given arguments. + */ + public static CobiGenVariableDefinition ofString(String name) { + + return ofType(name, String.class); + } + + /** + * @param name the {@link #getName() variable name}. + * @param defaultValue the {@link #getDefaultValue() default value}. + * @return the new {@link CobiGenVariableDefinition} created from the given arguments. + */ + public static CobiGenVariableDefinition ofString(String name, String defaultValue) { + + return new CobiGenVariableDefinition<>(name, String.class, () -> defaultValue); + } + + /** + * @param name the {@link #getName() variable name}. + * @return the new {@link CobiGenVariableDefinition} created from the given arguments. + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public static CobiGenVariableDefinition> ofClass(String name) { + + return new CobiGenVariableDefinition(name, Class.class); + } + + /** + * @param name the {@link #getName() variable name}. + * @param defaultValue the {@link #getDefaultValue() default value}. + * @return the new {@link CobiGenVariableDefinition} created from the given arguments. + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public static CobiGenVariableDefinition> ofClass(String name, Class defaultValue) { + + return new CobiGenVariableDefinition(name, Class.class, () -> defaultValue); + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/CobiGenVariableDefinitions.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/CobiGenVariableDefinitions.java new file mode 100644 index 0000000000..fdd9196d8e --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/CobiGenVariableDefinitions.java @@ -0,0 +1,55 @@ +package com.devonfw.cobigen.api.model; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.devonfw.cobigen.api.template.out.CobiGenOutput; + +/** + * Central definition of {@link CobiGenVariableDefinition}s. + */ +public final class CobiGenVariableDefinitions { + + /** {@link CobiGenVariableDefinition} for the Java {@link Class} reflecting the type of the input. */ + public static final CobiGenVariableDefinition> JAVA_TYPE = CobiGenVariableDefinition.ofClass("classObject"); + + /** {@link CobiGenVariableDefinition} for the fields of {@link #JAVA_TYPE}. */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public static final CobiGenVariableDefinition>> JAVA_FIELDS = new CobiGenVariableDefinition( + "fields", List.class, () -> new ArrayList<>(), "attributes"); + + /** {@link CobiGenVariableDefinition} for the variables. */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public static final CobiGenVariableDefinition> VARIABLES = new CobiGenVariableDefinition( + "variables", Map.class, () -> new HashMap<>()); + + /** The entity name for generations from an entity as input (e.g. "MyExample" for "MyExampleEntity" as input). */ + public static final CobiGenVariableDefinition ENTITY_NAME = CobiGenVariableDefinition.ofString("EntityName"); + + /** The root package namespace (e.g. "com.customer.app"). */ + public static final CobiGenVariableDefinition ROOT_PACKAGE = CobiGenVariableDefinition + .ofString("RootPackage"); + + /** The component name (e.g. "mycomponent"). */ + public static final CobiGenVariableDefinition COMPONENT_NAME = CobiGenVariableDefinition + .ofString("Component"); + + /** The detail sub-package(s) (typically empty but can be anything like "special" or "detail.extra"). */ + public static final CobiGenVariableDefinition DETAIL_NAME = CobiGenVariableDefinition.ofString("Detail"); + + /** The scope package segment (typically empty but can be the scope as "api", "base", or "impl"). */ + public static final CobiGenVariableDefinition SCOPE_NAME = CobiGenVariableDefinition.ofString("Scope"); + + /** + * The module path (typically empty but can be the relativ path to the module of a multi-module project where to put + * the generated code). + */ + public static final CobiGenVariableDefinition MODULE_PATH = CobiGenVariableDefinition.ofString("Module"); + + /** The {@link CobiGenOutput} of the currently generated artifact (template). */ + public static final CobiGenVariableDefinition OUT = CobiGenVariableDefinition.ofType("out", + CobiGenOutput.class); + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/JavaStringType.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/JavaStringType.java new file mode 100644 index 0000000000..7083407710 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/JavaStringType.java @@ -0,0 +1,35 @@ +package com.devonfw.cobigen.api.model; + +import java.lang.reflect.Type; + +/** + * Implementation of {@link Type} as a simple container for its {@link #getTypeName() type name}. + */ +public class JavaStringType implements Type { + + private final String typeName; + + /** + * The constructor. + * + * @param typeName the {@link #getTypeName() type name}. + */ + public JavaStringType(String typeName) { + + super(); + this.typeName = typeName; + } + + @Override + public String getTypeName() { + + return this.typeName; + } + + @Override + public String toString() { + + return this.typeName; + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/VariableSyntax.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/VariableSyntax.java new file mode 100644 index 0000000000..fbc9c0c211 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/model/VariableSyntax.java @@ -0,0 +1,256 @@ +package com.devonfw.cobigen.api.model; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.devonfw.cobigen.api.exception.UnknownExpressionException; +import com.devonfw.cobigen.api.util.StringUtil; + +import io.github.mmm.base.text.CaseConversion; +import io.github.mmm.base.text.CaseSyntax; + +/** + * Enum with the available syntax for variables supported by CobiGen. + */ +public enum VariableSyntax { + + /** Variables are surrounded with "${" and "}" such as ${variableName#uncapfirst}. */ + // .....1......2........345 + DOLLAR("(\\$\\{([^?#}]+)(((\\?|#)[^}?#]+)*)\\})") { + + @Override + public String getVariable(Matcher matcher) { + + String variable = matcher.group(2); + String nameVariables = CobiGenVariableDefinitions.VARIABLES.getName(); + if (variable.startsWith(nameVariables)) { + variable = variable.substring(nameVariables.length()); + } + return variable; + } + + @Override + public String resolve(String value, Matcher matcher, String name) { + + return resolveFunction(value, matcher.group(3)); + } + + /** + * Legacy support for freemarker function syntax. + * + * @param value the value of the variable to resolve. + * @param function the freemarker function(s) to simulate and apply. + * @return the resolved {@code value} with the given freemarker function(s) applied. + */ + private String resolveFunction(String value, String function) { + + if (function != null) { + boolean first = true; + for (String modifier : function.split("(\\?|#)")) { + if (first) { + first = false; + // ignore first as always empty due to beginning '?' + continue; + } + value = applyStringModifier(modifier, value); + } + } + return value; + } + + /** + * Applies the given {@link String} modifier defined by ?modifier behind the variable reference + * + * @param modifierName name of the {@link String} modifier to be applied + * @param string {@link String} the modifier should be applied on + * @return the modified {@link String} + * @throws UnknownExpressionException if there is an unknown variable modifier + */ + private String applyStringModifier(String modifierName, String string) throws UnknownExpressionException { + + // simple operators + if (modifierName.equals("cap_first")) { + return StringUtil.capFirst(string); + } else if (modifierName.equals("uncap_first")) { + return StringUtil.uncapFirst(string); + } else if (modifierName.equals("lower_case")) { + return string.toLowerCase(); + } else if (modifierName.equals("upper_case")) { + return string.toUpperCase(); + } + + String parameterRegex = "\\s*'([^']*)'\\s*"; + + // ?replace(String regex, String replacement) + Pattern p = Pattern.compile("replace\\(" + parameterRegex + "," + parameterRegex + "\\)"); + Matcher m = p.matcher(modifierName); + + if (m.matches()) { + return string.replaceAll(m.group(1), m.group(2)); + } + + // ?removeSuffix(String suffix) + p = Pattern.compile("removeSuffix\\(" + parameterRegex + "\\)"); + m = p.matcher(modifierName); + + if (m.matches() && string.endsWith(m.group(1))) { + return string.substring(0, string.length() - m.group(1).length()); + } + + // ?removePrefix(String prefix) + p = Pattern.compile("removePrefix\\(" + parameterRegex + "\\)"); + m = p.matcher(modifierName); + + if (m.matches() && string.startsWith(m.group(1))) { + return string.substring(m.group(1).length(), string.length()); + } + + throw new UnknownExpressionException("?" + modifierName); + } + + }, + + /** + * Variables are surrounded with "X_" and "_X" respectively "x_" and "_x" and the {@link CaseSyntax} is used for + * automatic conversion. The following table gives examples that illustrate the behavior. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
VariableRaw valueResolved value
X_VariableName_XMyExampleMyExample
x_variableName_xMyExamplemyExample
x_variablename_xMyExamplemyexample
X_VARIABLE_NAME_XMyExampleMY_EXAMPLE
x_variable-name_xMyExamplemy-example
+ */ + // .......1.....23......4.........................5 + AGNOSTIC("(\\.?)(([xX][_.-])([a-zA-Z_][a-zA-Z0-9_.$-]*?)([_.-][xX]))") { + + @Override + public String getVariable(Matcher matcher) { + + return matcher.group(4); + } + + @Override + public String resolve(String value, Matcher matcher, String name) { + + String dot = matcher.group(1); + if (value.isEmpty()) { + // TODO this should actually depend on the location of the variable and the CaseSyntax + // So looking at the following example: + // package x_rootpackage_x.x_component_x.dataaccess.x_scope_x.x_detail_x; + // In case that the variable "scope" or "detail" resolves to the empty string, then this package segment shall + // be omitted however resolving only the variable to the empty String would result in trailing dots at the end: + // com.customer.app.mycomponent.dataaccess..; + // As we already have another edge-case for package segment variables that if the variable contains dots + // (e.g. rootpackage="com.customer.app") then CaseSyntax.LOWER_CASE would remove the dot as undesired separators + // As I implemented CaseSyntax mainly for CobiGen and Language-Agnostic-Templates I am more than happy to change + // it (even incompatible) to fit CobiGen's needs. So if the first character is a special character (no letter) + // then separators should be preserved. Therefore we would then need to write this instead: + // package x__rootpackage_x.x__component_x.dataaccess.x__scope_x.x__detail_x; + // Even though kind of cryptic, but still easy to hanlde once you learned how to do it in Java packages. + // This is IMHO better than writing this (causing variables split across folder names): + // package x__root.package_x.x_component_x.dataaccess.x_det.ail_x; + return ""; + } + CaseSyntax caseSyntax = CaseSyntax.ofExample(name, true); + verifySyntax(caseSyntax, matcher); + if (caseSyntax == CaseSyntax.LOWERCASE) { + // see comment above + value = CaseConversion.LOWER_CASE.convert(value); + } else { + value = caseSyntax.convert(value); + } + if (!dot.isEmpty()) { + value = dot + value; + } + return value; + } + + void verifySyntax(CaseSyntax caseSyntax, Matcher matcher) { + + // x_entityname_x + // X_EntityName_X + // X_Entityname_x + String prefix = matcher.group(3); + String suffix = matcher.group(5); + CaseConversion firstCase = caseSyntax.getFirstCase(); + String prefixCased = firstCase.convert(prefix); + String suffixCased = firstCase.convert(suffix); + if (prefix.equals(prefixCased) && (prefix.charAt(1) == suffix.charAt(0))) { + if (suffix.equals(suffixCased)) { + return; + } + // edge-cases but lets consider syntax like X_Caplowercase_x as valid... + suffixCased = caseSyntax.getWordStartCase().convert(suffix); + if (suffix.equals(suffixCased)) { + return; + } + suffixCased = caseSyntax.getOtherCase().convert(suffix); + if (suffix.equals(suffixCased)) { + return; + } + } + LOG.warn("Inconsistent variable syntax: {}", matcher.group(2)); + } + }; + + private static final Logger LOG = LoggerFactory.getLogger(VariableSyntax.class); + + private final Pattern pattern; + + VariableSyntax(String regex) { + + this.pattern = Pattern.compile(regex); + } + + /** + * @return the regular expression {@link Pattern} for this {@link VariableSyntax}. + */ + public Pattern getPattern() { + + return this.pattern; + } + + /** + * @param matcher the current {@link Matcher}. + * @return the variable name. + */ + public abstract String getVariable(Matcher matcher); + + /** + * @param value the {@link String} with the variable value to resolve. + * @param matcher the current {@link Matcher}. + * @param name the variable name as before returned by {@link #getVariable(Matcher)}. + * @return the resolved {@link String}. May be the given {@code value} itself, but can also be a transformation. + */ + public abstract String resolve(String value, Matcher matcher, String name); + +} \ No newline at end of file diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/condition/CobiGenPredicate.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/condition/CobiGenPredicate.java new file mode 100644 index 0000000000..782bf87aa6 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/condition/CobiGenPredicate.java @@ -0,0 +1,16 @@ +package com.devonfw.cobigen.api.template.condition; + +import com.devonfw.cobigen.api.model.CobiGenModel; + +/** + * Interface for a condition. Implementations must have a public non-arg constructor. + */ +public interface CobiGenPredicate { + + /** + * @param model the {@link CobiGenModel}. + * @return {@code true} if the condition applies, {@code false} otherwise. + */ + boolean test(CobiGenModel model); + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/condition/CobiGenPredicateTrue.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/condition/CobiGenPredicateTrue.java new file mode 100644 index 0000000000..3fc3a9f69e --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/condition/CobiGenPredicateTrue.java @@ -0,0 +1,16 @@ +package com.devonfw.cobigen.api.template.condition; + +import com.devonfw.cobigen.api.model.CobiGenModel; + +/** + * Implementation of {@link CobiGenPredicate} that always returns {@code true}. + */ +public class CobiGenPredicateTrue implements CobiGenPredicate { + + @Override + public boolean test(CobiGenModel model) { + + return true; + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGenerator.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGenerator.java new file mode 100644 index 0000000000..7dfc36e41c --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGenerator.java @@ -0,0 +1,39 @@ +package com.devonfw.cobigen.api.template.generator; + +import java.io.IOException; + +import com.devonfw.cobigen.api.model.CobiGenModel; + +/** + * Interface for a code generator of a specific aspect such as generation of properties (fields, getters, setters). + * Lines in a template referencing a {@link CobiGenGenerator} will be replaced with the {@link #generate(CobiGenModel) + * generated output}. Implementations have to be stateless. + * + * @see CobiGenGeneratorProvider + * @see CobiGenOutputGenerator + */ +public interface CobiGenGenerator { + + /** + * @param model the {@link CobiGenModel} with the variables and metadata of the generation. + * @return the generated code as {@link String}. + */ + default String generate(CobiGenModel model) { + + try { + StringBuilder sb = new StringBuilder(); + generate(model, sb); + return sb.toString(); + } catch (IOException e) { + throw new IllegalStateException("Generator produced I/O exception.", e); + } + } + + /** + * @param model the {@link CobiGenModel} with the variables and metadata of the generation. + * @param code the {@link Appendable} where to {@link Appendable#append(CharSequence) write} the generated code to. + * @throws IOException in case of an I/O error. + */ + void generate(CobiGenModel model, Appendable code) throws IOException; + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorProvider.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorProvider.java new file mode 100644 index 0000000000..5dc65a6159 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenGeneratorProvider.java @@ -0,0 +1,102 @@ +package com.devonfw.cobigen.api.template.generator; + +import java.util.HashMap; +import java.util.Map; +import java.util.ServiceLoader; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.devonfw.cobigen.api.model.CobiGenModel; + +/** + * This is the central provider for any {@link CobiGenGenerator}. + * + * @see #getGenerator(String) + */ +public class CobiGenGeneratorProvider { + + private static final Logger LOG = LoggerFactory.getLogger(CobiGenGeneratorProvider.class); + + private static final CobiGenGeneratorProvider INSTANCE = new CobiGenGeneratorProvider(); + + private final Map generators; + + private CobiGenGeneratorProvider() { + + super(); + this.generators = new HashMap<>(); + ServiceLoader loader = ServiceLoader.load(CobiGenGenerator.class); + for (CobiGenGenerator generator : loader) { + String simpleName = generator.getClass().getSimpleName(); + CobiGenGenerator duplicate = this.generators.put(simpleName, generator); + if (duplicate != null) { + LOG.warn("Duplicate Generator name {}: Replaced generator {} with {} assuming override.", simpleName, + duplicate.getClass().getName(), generator.getClass().getName()); + } + } + } + + /** + * @param simpleName the {@link Class#getSimpleName() simple name} of the {@link CobiGenGenerator} to invoke. + * @param model the {@link CobiGenModel}. + * @return the generated code. + */ + public String generate(String simpleName, CobiGenModel model) { + + CobiGenGenerator generator = getGenerator(simpleName); + try { + return generator.generate(model); + } catch (Throwable e) { + throw new IllegalStateException(simpleName + " failed.", e); + } + } + + /** + * @param simpleName the {@link Class#getSimpleName() simple name} of the {@link CobiGenGenerator} to invoke. + * @param model the {@link CobiGenModel}. + * @param code the {@link Appendable} where to {@link Appendable#append(CharSequence) write} the generated code to. + */ + public void generate(String simpleName, CobiGenModel model, Appendable code) { + + CobiGenGenerator generator = getGenerator(simpleName); + try { + generator.generate(model, code); + } catch (Throwable e) { + throw new IllegalStateException(simpleName + " failed.", e); + } + } + + /** + * @param simpleName the {@link Class#getSimpleName() simple name} of the requested {@link CobiGenGenerator}. + * @return {@code true} if such {@link CobiGenGenerator} is registered and {@link #getGenerator(String) retrievable}, + * {@code false} otherwise. + */ + boolean hasGenerator(String simpleName) { + + return this.generators.containsKey(simpleName); + } + + /** + * @param simpleName the {@link Class#getSimpleName() simple name} of the requested {@link CobiGenGenerator}. + * @return the requested {@link CobiGenGenerator}. + * @throws IllegalArgumentException if no such generator exists. + */ + public CobiGenGenerator getGenerator(String simpleName) { + + CobiGenGenerator generator = this.generators.get(simpleName); + if (generator == null) { + throw new IllegalArgumentException("Undefined generator " + simpleName); + } + return generator; + } + + /** + * @return the singleton instance. + */ + public static CobiGenGeneratorProvider get() { + + return INSTANCE; + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenOutputGenerator.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenOutputGenerator.java new file mode 100644 index 0000000000..8c52dcffac --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/generator/CobiGenOutputGenerator.java @@ -0,0 +1,35 @@ +package com.devonfw.cobigen.api.template.generator; + +import java.io.IOException; + +import com.devonfw.cobigen.api.model.CobiGenModel; +import com.devonfw.cobigen.api.model.CobiGenVariableDefinitions; +import com.devonfw.cobigen.api.template.out.CobiGenOutput; + +/** + * Abstract base implementation for {@link CobiGenGenerator} that only generates into {@link CobiGenOutput}. + */ +public abstract class CobiGenOutputGenerator implements CobiGenGenerator { + + @Override + public final String generate(CobiGenModel model) { + + CobiGenOutput out = CobiGenVariableDefinitions.OUT.getValue(model); + doGenerate(out, model); + return ""; + } + + @Override + public final void generate(CobiGenModel model, Appendable code) throws IOException { + + CobiGenOutput out = CobiGenVariableDefinitions.OUT.getValue(model); + doGenerate(out, model); + } + + /** + * @param out the {@link CobiGenOutput} where to write to. + * @param model the {@link CobiGenModel}. + */ + protected abstract void doGenerate(CobiGenOutput out, CobiGenModel model); + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/AbstractCobiGenOutput.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/AbstractCobiGenOutput.java new file mode 100644 index 0000000000..ebc78510d0 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/AbstractCobiGenOutput.java @@ -0,0 +1,112 @@ +package com.devonfw.cobigen.api.template.out; + +import java.io.IOException; +import java.util.Objects; + +import com.devonfw.cobigen.api.code.CobiGenCodeBlock; +import com.devonfw.cobigen.api.code.CobiGenCompositeCodeBlock; + +/** + * Abstract base implementation of {@link CobiGenOutput}. + */ +public abstract class AbstractCobiGenOutput implements CobiGenOutput { + + /** @see #getFilename() */ + protected final String filename; + + /** The {@link CobiGenCodeBlock}. */ + protected final CobiGenCompositeCodeBlock code; + + private final AbstractCobiGenOutput parent; + + /** + * The constructor. + * + * @param parent the parent {@link CobiGenOutputCode}. + */ + public AbstractCobiGenOutput(AbstractCobiGenOutput parent) { + + this(parent.filename, parent); + } + + /** + * The constructor. + * + * @param filename the {@link #getFilename() filename}. + */ + public AbstractCobiGenOutput(String filename) { + + this(filename, null); + Objects.requireNonNull(filename); + } + + private AbstractCobiGenOutput(String filename, AbstractCobiGenOutput parent) { + + super(); + this.filename = filename; + this.parent = parent; + this.code = createCode(); + } + + /** + * @return the {@link CobiGenCompositeCodeBlock} with the code structure of this output. + */ + protected CobiGenCompositeCodeBlock createCode() { + + return new CobiGenCompositeCodeBlock(CobiGenCodeBlock.NAME_HEADER); + } + + @Override + public String getFilename() { + + return this.filename; + } + + @Override + public CobiGenCodeBlock getCode() { + + return this.code; + } + + /** + * @return the parent {@link AbstractCobiGenOutput} or {@code null} if this is the root. + */ + public AbstractCobiGenOutput getParent() { + + return this.parent; + } + + /** + * @return the root output node. + */ + protected AbstractCobiGenOutput getRoot() { + + AbstractCobiGenOutput current = this; + while (current.parent != null) { + current = current.parent; + } + return current; + } + + /** + * @param line the resolved line from the template to add. + * @return this {@link AbstractCobiGenOutput output} or potentially a child of it (e.g. for nested structures like + * inner classes). + */ + public abstract AbstractCobiGenOutput addLine(String line); + + /** + * Actually writes the generated output. + * + * @param out the {@link Appendable} where to write to. + */ + public void write(Appendable out) { + + try { + this.code.write(out); + } catch (IOException e) { + throw new IllegalStateException("Failed to write output file for template " + this.filename, e); + } + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutput.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutput.java new file mode 100644 index 0000000000..858a9c9960 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutput.java @@ -0,0 +1,159 @@ +package com.devonfw.cobigen.api.template.out; + +import com.devonfw.cobigen.api.code.CobiGenCodeBlock; + +/** + * Interface for the output artifact currently generated by CobiGen.
+ * ATTENTION: The output artifact can be of any type. Methods offered by this interface may only be supported + * depending on that type. So when data or text is generated (XML, JSON, YAML, AsciiDoc, TXT, etc.) there are no import + * statements and hence methods like {@link #addImport(String)} will fail. + */ +public interface CobiGenOutput { + + /** {@link #getCategory() Category} for a regular class. */ + String CATEGORY_CLASS = "class"; + + /** {@link #getCategory() Category} for a an interface. */ + String CATEGORY_INTERFACE = "interface"; + + /** {@link #getCategory() Category} for a an enumeration type. */ + String CATEGORY_ENUMERATION = "enumeration"; + + /** {@link #getCategory() Category} for a a record type. */ + String CATEGORY_RECORD = "record"; + + /** {@link #getCategory() Category} for a an annotation type. */ + String CATEGORY_ANNOTATION = "annotation"; + + /** {@link #getCategory() Category} if undefined (e.g. textual output). */ + String CATEGORY_UNDEFINED = "undefined"; + + /** + * @return the resolved filename of the generated output. + */ + String getFilename(); + + /** + * @return the category of the generated output type. + */ + default String getCategory() { + + return CATEGORY_UNDEFINED; + } + + /** + * @return {@code true} if {@link #getCategory() category} is {@link CobiGenOutput#CATEGORY_INTERFACE interface}. + */ + default boolean isInterface() { + + return CATEGORY_INTERFACE.equals(getCategory()); + } + + /** + * @return {@code true} if {@link #getCategory() category} is {@link CobiGenOutput#CATEGORY_RECORD record}. + */ + default boolean isRecord() { + + return CATEGORY_RECORD.equals(getCategory()); + } + + /** + * @return {@code true} if {@link #getCategory() category} is {@link CobiGenOutput#CATEGORY_ENUMERATION enumeration}. + */ + default boolean isEnumeration() { + + return CATEGORY_ENUMERATION.equals(getCategory()); + } + + /** + * @return {@code true} if {@link #getCategory() category} is {@link CobiGenOutput#CATEGORY_ANNOTATION annotation}. + */ + default boolean isAnnotation() { + + return CATEGORY_ANNOTATION.equals(getCategory()); + } + + /** + * @return {@code true} if {@link #getCategory() category} is {@link CobiGenOutput#CATEGORY_CLASS class}. + */ + default boolean isClass() { + + return CATEGORY_CLASS.equals(getCategory()); + } + + /** + * @return the {@link CobiGenCodeBlock} with the source-code of this output. + */ + CobiGenCodeBlock getCode(); + + /** + * @param name the {@link Class#getSimpleName() simple name} of the type to check. + * @return {@code true} if the specified type name is imported, {@code false} otherwise. + */ + default boolean hasImport(String name) { + + return getImport(name) != null; + } + + /** + * @param name the {@link QualifiedName#getSimpleName() simple name} of the type to resolve. + * @return the {@link ImportStatement} for the given {@link QualifiedName#getSimpleName() simple name} or {@code null} + * if no such import exists. + */ + ImportStatement getImport(String name); + + /** + * @param qualifiedName the fully qualified name. + * @return {@code true} if the {@link ImportStatement} has been added, {@code false} otherwise (it was already present + * before). + * @throws UnsupportedOperationException if the import is not supported. + */ + boolean addImport(String qualifiedName); + + /** + * @param qualifiedName the {@link QualifiedName}. + * @return {@code true} if the {@link ImportStatement} has been added, {@code false} otherwise (it was already present + * before). + * @throws UnsupportedOperationException if the import is not supported. + */ + boolean addImport(QualifiedName qualifiedName); + + /** + * @param importStatement the {@link ImportStatement} to add. + * @return {@code true} if the {@link ImportStatement} has been added, {@code false} otherwise (it was already present + * before). + * @throws UnsupportedOperationException if the import is not supported. + */ + boolean addImport(ImportStatement importStatement); + + /** + * @param name the name of the property (field). + * @param qualifiedTypeName the {@link QualifiedName} of the property type as {@link String}. + * @param description the description of the property used for documentation generation. Simply provide {@code name} + * if unknown. May also be {@code null} to suppress documentation generation. + */ + void addProperty(String name, String qualifiedTypeName, String description); + + /** + * @param name the name of the property (field). + * @param type the {@link QualifiedName} of the property type. + * @param description the description of the property used for documentation generation. Simply provide {@code name} + * if unknown. May also be {@code null} to suppress documentation generation. + */ + void addProperty(String name, QualifiedName type, String description); + + /** + * @param name the name of the property (field). + * @param type the {@link QualifiedName} of the property type. + * @param description the description of the property used for documentation generation. Simply provide {@code name} + * if unknown. May also be {@code null} to suppress documentation generation. + * @param addImport - {@code true} to automatically {@link #addImport(String) add an import}, {@code false} otherwise. + * @param addField - {@code true} to automatically add a field declaration (will still be omitted in interface), + * {@code false} otherwise. + * @param addGetter - {@code true} to automatically add a getter method. + * @param addSetter - {@code true} to automatically add a setter method. + */ + void addProperty(String name, QualifiedName type, String description, boolean addImport, boolean addField, + boolean addGetter, boolean addSetter); + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutputCode.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutputCode.java new file mode 100644 index 0000000000..79a887d478 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutputCode.java @@ -0,0 +1,842 @@ +package com.devonfw.cobigen.api.template.out; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.devonfw.cobigen.api.code.AbstractCobiGenCodeBlock; +import com.devonfw.cobigen.api.code.CobiGenAtomicCodeBlock; +import com.devonfw.cobigen.api.code.CobiGenCodeBlock; +import com.devonfw.cobigen.api.code.CobiGenCompositeCodeBlock; +import com.devonfw.cobigen.api.util.StringUtil; + +/** + * Extends {@link AbstractCobiGenOutput} for source-code for programming language. For languages other than Java, + * various methods need to be overridden. + */ +public abstract class CobiGenOutputCode extends AbstractCobiGenOutput { + + /** Keyword modifier {@value}. */ + protected static final String KEYWORD_PUBLIC = "public"; + + /** Keyword modifier {@value}. */ + protected static final String KEYWORD_PROTECTED = "protected"; + + /** Keyword modifier {@value}. */ + protected static final String KEYWORD_PRIVATE = "private"; + + /** Keyword modifier {@value}. */ + protected static final String KEYWORD_ABSTRACT = "abstract"; + + /** Keyword modifier {@value}. */ + protected static final String KEYWORD_STATIC = "static"; + + /** Keyword modifier {@value}. */ + protected static final String KEYWORD_FINAL = "final"; + + /** Keyword modifier {@value}. */ + protected static final String KEYWORD_SYNCHRONIZED = "synchronized"; + + /** Keyword modifier {@value}. */ + protected static final String KEYWORD_NATIVE = "native"; + + /** Keyword modifier {@value}. */ + protected static final String KEYWORD_VOLATILE = "volatile"; + + /** Keyword modifier {@value}. */ + protected static final String KEYWORD_STRICTFP = "strictfp"; + + /** Keyword type {@value}. */ + protected static final String KEYWORD_CLASS = "class"; + + /** Keyword type {@value}. */ + protected static final String KEYWORD_INTERFACE = "interface"; + + /** Keyword type {@value}. */ + protected static final String KEYWORD_ENUM = "enum"; + + /** Keyword type {@value}. */ + protected static final String KEYWORD_ANNOTATION = "@interface"; + + /** Keyword type {@value}. */ + protected static final String KEYWORD_RECORD = "record"; + + /** Keyword {@value}. */ + protected static final String KEYWORD_IMPORT = "import"; + + /** Keyword {@value}. */ + protected static final String KEYWORD_PACKAGE = "package"; + + private static final Logger LOG = LoggerFactory.getLogger(CobiGenOutputCode.class); + + private static final Set JAVA_MODIFIERS = Set.of(KEYWORD_PUBLIC, KEYWORD_PROTECTED, KEYWORD_PRIVATE, + KEYWORD_ABSTRACT, KEYWORD_STATIC, KEYWORD_FINAL, KEYWORD_SYNCHRONIZED, KEYWORD_VOLATILE, KEYWORD_NATIVE, + KEYWORD_STRICTFP); + + private static final Map JAVA_TYPES = Map.of(KEYWORD_CLASS, CATEGORY_CLASS, KEYWORD_INTERFACE, + CATEGORY_INTERFACE, KEYWORD_ENUM, CATEGORY_ENUMERATION, KEYWORD_ANNOTATION, CATEGORY_ANNOTATION, KEYWORD_RECORD, + CATEGORY_RECORD); + + private static final int MULTILINE_BLOCK = -42; + + private final Map imports; + + private final List buffer = new ArrayList<>(); + + private int bufferIndent = -1; + + /** @see #getCategory() */ + protected String category; + + private String typeName; + + private CobiGenCompositeCodeBlock block; + + private CobiGenAtomicCodeBlock member; + + /** + * The constructor for a nested-type output. + * + * @param parent the parent output. + */ + public CobiGenOutputCode(CobiGenOutputCode parent) { + + super(parent); + this.imports = parent.imports; + this.category = CATEGORY_CLASS; // fallback + } + + /** + * The constructor. + * + * @param filename the {@link #getFilename() filename}. + */ + public CobiGenOutputCode(String filename) { + + super(filename); + this.imports = new HashMap<>(); + this.category = CATEGORY_CLASS; // fallback + } + + @Override + protected CobiGenCompositeCodeBlock createCode() { + + CobiGenCompositeCodeBlock start; + CobiGenCompositeCodeBlock current; + int widthMain = 0; + AbstractCobiGenOutput parent = getParent(); + if (parent == null) { + start = new CobiGenCompositeCodeBlock(CobiGenCodeBlock.NAME_HEADER); + current = start; + current = current.insertNext(CobiGenCodeBlock.NAME_PACKAGE); + current = current.insertNext(CobiGenCodeBlock.NAME_IMPORTS); + current = current.insertNext(CobiGenCodeBlock.NAME_DECLARATION); + } else { + current = (CobiGenCompositeCodeBlock) parent.code.getNext(CobiGenCodeBlock.NAME_NESTS); + widthMain = current.getIndentFallbackWidth(); + start = current.addCompositeChild(CobiGenCodeBlock.NAME_DECLARATION); + current = start; + } + int widthBody = widthMain + 2; + current = appendBlock(current, CobiGenCodeBlock.NAME_FIELDS, widthBody); + current = appendBlock(current, CobiGenCodeBlock.NAME_CONSTRUCTORS, widthBody); + current = appendBlock(current, CobiGenCodeBlock.NAME_GETTERS, widthBody); // mix getterns and setters by default + current = appendBlock(current, CobiGenCodeBlock.NAME_METHODS, widthBody); + current = appendBlock(current, CobiGenCodeBlock.NAME_NESTS, widthBody); + current = appendBlock(current, CobiGenCodeBlock.NAME_FOOTER, widthMain); + return start; + } + + /** + * @param current the current {@link CobiGenCompositeCodeBlock} to append to. + * @param blockName the {@link CobiGenCompositeCodeBlock#getName() block name}. + * @param width the indent width (number of spaces). + * @return the created and appended {@link CobiGenCompositeCodeBlock}. + */ + protected CobiGenCompositeCodeBlock appendBlock(CobiGenCompositeCodeBlock current, String blockName, int width) { + + current = current.insertNext(blockName); + current.setIndentFallbackWidth(width); + return current; + } + + /** + * @return the {@link QualifiedName#getSimpleName() simple name} of this type. + */ + public String getTypeName() { + + return this.typeName; + } + + @Override + public String getCategory() { + + return this.category; + } + + /** + * @param qualifiedName the qualified name. + * @return the parsed {@link QualifiedName}. + */ + protected QualifiedName parseName(String qualifiedName) { + + return QualifiedName.of(qualifiedName); + } + + @Override + public void addProperty(String name, String qualifiedTypeName, String description) { + + addProperty(name, parseName(qualifiedTypeName), description); + } + + @Override + public void addProperty(String name, QualifiedName type, String description) { + + boolean annotation = isAnnotation(); + addProperty(name, type, description, true, !(isInterface() || annotation), true, !annotation); + } + + @Override + public void addProperty(String name, QualifiedName type, String description, boolean addImport, boolean addField, + boolean addGetter, boolean addSetter) { + + String typeSimpleName = type.getSimpleName(); + if (isImportRequired(type)) { + boolean imported = false; + if (addImport) { + imported = addImport(type); + } + if (!imported) { + ImportStatement importStatement = getImport(typeSimpleName); + if ((importStatement == null) || !importStatement.getTarget().equals(type.getQualifiedName())) { + typeSimpleName = type.getQualifiedName(); + } + } + } + if (addField) { + addField(name, typeSimpleName, description); + } + if (addGetter) { + addGetter(name, typeSimpleName, description); + } + if (addSetter) { + addSetter(name, typeSimpleName, description); + } + } + + /** + * @param name the name of the field to add. + * @param type the (local) property type. + * @param description the description of the property used for documentation generation. + */ + protected void addField(String name, String type, String description) { + + if (isInterface()) { + LOG.warn("Interface can not declare fields - omitting field {}", name); + return; + } + CobiGenCodeBlock fields = this.code.getNext(CobiGenCodeBlock.NAME_FIELDS).addAtomicChild(name); + fields.addLine(""); + if (isAnnotation()) { + addGetterDoc(description, fields); + fields.addLine(type + " " + name + "();"); + } else { + fields.addLine("private " + type + " " + name + ";"); + } + } + + /** + * @param name the name of the property. + * @param type the (local) property type. + * @param description the description of the property used for documentation generation. + */ + protected void addGetter(String name, String type, String description) { + + String methodPrefix = "get"; + if ("boolean".equals(type)) { + methodPrefix = "is"; + } + String methodName = methodPrefix + StringUtil.capFirst(name); + CobiGenCodeBlock getters = this.code.getNext(CobiGenCodeBlock.NAME_GETTERS).addAtomicChild(methodName); + getters.addLine(""); + if (description == null) { + if (isClass()) { + getters.addLine("@Override"); + } + } else if (!description.isEmpty()) { + addGetterDoc(description, getters); + } + String visibility = "public "; + if (isAnnotation()) { + getters.addLine(type + " " + name + "();"); + return; + } else if (isInterface()) { + visibility = ""; + } + String signatureSuffix = ";"; + if (!isInterface()) { + signatureSuffix = " {"; + } + getters.addLine(visibility + type + " " + methodName + "()" + signatureSuffix); + if (!isInterface()) { + getters.addLines(" return this." + name + ";", "}"); + } + } + + /** + * @param name the name of the property. + * @param type the (local) property type. + * @param description the description of the property used for documentation generation. + */ + protected void addSetter(String name, String type, String description) { + + if (isAnnotation()) { + LOG.warn("Annotation can not declare setter - omitting property {}.", name); + return; + } + String methodName = "set" + StringUtil.capFirst(name); + CobiGenCodeBlock setters = this.code.getNext(CobiGenCodeBlock.NAME_SETTERS).addAtomicChild(methodName); + setters.addLine(""); + String visibility = "public "; + if ((description == null) && isClass()) { + setters.addLine("@Override"); + } + String signatureSuffix = ";"; + if (!isInterface()) { + signatureSuffix = " {"; + } + setters.addLine(visibility + "void " + methodName + "(" + type + " " + name + ")" + signatureSuffix); + if (!isInterface()) { + setters.addLines(" this." + name + " = " + name + ";", "}"); + } + } + + /** + * @param description the documentation of the property. + * @param getters the {@link CobiGenCodeBlock} where to append the documentation. + */ + protected void addGetterDoc(String description, CobiGenCodeBlock getters) { + + if (description != null) { + int newline = description.indexOf('\n'); + if (newline >= 0) { + String[] descriptions = description.split("\n"); + String[] lines = new String[descriptions.length + 2]; + int lineIndex = 0; + lines[lineIndex++] = "/**"; + String prefix = " * @return "; + for (String d : descriptions) { + lines[lineIndex++] = prefix + d; + prefix = " * "; + } + lines[lineIndex++] = " */"; + } else { + getters.addLines("/**", " * @return " + description, " */"); + } + } + } + + @Override + public ImportStatement getImport(String name) { + + return this.imports.get(name); + } + + @Override + public boolean addImport(String qualifiedName) { + + return addImport(parseName(qualifiedName)); + } + + /** + * @param qualifiedName the {@link QualifiedName} to check. + * @return {@code true} if an {@link ImportStatement} is required for the type identified by the given + * {@link QualifiedName}, {@code false} otherwise (e.g. for "String" or "java.lang.String" in case of Java). + */ + protected abstract boolean isImportRequired(QualifiedName qualifiedName); + + @Override + public boolean addImport(ImportStatement importStatement) { + + boolean added = doAddImport(importStatement); + if (added) { + getRoot().code.getNext(CobiGenCodeBlock.NAME_IMPORTS).addLine(true, importStatement.toString()); + } + return added; + } + + /** + * @param importStatement the {@link ImportStatement} to add. + * @return {@code true} if added as new import, {@code false} otherwise (already present before hence ignoring). + */ + protected boolean doAddImport(ImportStatement importStatement) { + + boolean added = false; + int count = importStatement.getKeyCount(); + assert (count > 0); + for (int i = 0; i < count; i++) { + String key = importStatement.getKey(i); + ImportStatement existing = this.imports.get(key); + if (existing == null) { + this.imports.put(key, importStatement); + added = true; + } else { + if (existing.equals(importStatement)) { + LOG.debug("Omitting duplicated import for '{}'.", key); + } else { + LOG.warn("Duplicate import for '{}': Having '{}' thus omitting '{}'.", key, existing, importStatement); + } + } + } + return added; + } + + /** + * @param tokenizer the {@link LineTokenizer} after the "import" keyword has been {@link LineTokenizer#next() + * consumed}. + * @return the parsed {@link ImportStatement}. + */ + protected abstract ImportStatement createImportStatement(LineTokenizer tokenizer); + + private void addImportInternal(LineTokenizer tokenizer) { + + doAddImport(createImportStatement(tokenizer)); + } + + /** + * Override if other than Java. + * + * @param token the token (single word) to check. + * @return {@code true} if modifier keyword, {@code false} otherwise. + */ + protected boolean isModifierKeyword(String token) { + + return JAVA_MODIFIERS.contains(token); + } + + /** + * Override if other than Java. + * + * @param token the token (single word) to check. + * @return the {@link #getCategory() category} or {@code null} if not a type keyword. + */ + protected String getCategory(String token) { + + return JAVA_TYPES.get(token); + } + + /** + * Creates a new child type (nested type). + * + * @return the new {@link CobiGenOutputCode} instance. + */ + protected abstract CobiGenOutputCode createChild(); + + @Override + public CobiGenOutputCode addLine(String line) { + + if (this.block == null) { + this.block = this.code; + } + if (line == null) { + // EOF + addLine2Block(CobiGenCodeBlock.NAME_FOOTER, null, 0, null); + return (CobiGenOutputCode) getRoot(); + } + if (this.bufferIndent == MULTILINE_BLOCK) { + this.buffer.add(line); + if (line.trim().endsWith("*/")) { + this.bufferIndent = -1; + } + return this; + } + LineTokenizer tokenizer = new LineTokenizer(line); + if (this.bufferIndent != -1) { + int tokenStart = tokenizer.getFirstTokenStart(); + if (tokenStart > this.bufferIndent) { + this.buffer.add(line); + return this; + } + this.bufferIndent = -1; + if ((tokenStart == this.bufferIndent) && (tokenStart < tokenizer.len)) { + char c = tokenizer.line.charAt(tokenStart); + if (c == '}') { + this.buffer.add(line); // assuming proper formatting and indentation + return this; + } + } + } + if (this.member != null) { + this.member = appendWhileIndent(tokenizer, this.member); + return this; + } + String token = tokenizer.next(); + if (token.isEmpty()) { + // omit multiple empty lines in a row + if (this.buffer.isEmpty() || !this.buffer.get(this.buffer.size() - 1).isEmpty()) { + this.buffer.add(line); + } + return this; + } else if ("//".equals(token)) { + this.buffer.add(line); + return this; + } else if (token.startsWith("/*")) { + this.buffer.add(line); + this.bufferIndent = MULTILINE_BLOCK; + return this; + } + + int firstNonSpace = tokenizer.getFirstTokenStart(); + if (KEYWORD_PACKAGE.equals(token)) { + addLine2Block(CobiGenCodeBlock.NAME_PACKAGE, line, firstNonSpace, null); + return this; + } else if (KEYWORD_IMPORT.equals(token)) { + addLine2Block(CobiGenCodeBlock.NAME_IMPORTS, line, firstNonSpace, null); + addImportInternal(tokenizer); + return this; + } + + boolean hasModifiers = false; + while (isModifierKeyword(token)) { + hasModifiers = true; + token = tokenizer.next(); + } + if (token.isEmpty()) { + LOG.warn("Unexpected code with only modifiers: {}", line); + this.buffer.add(line); + return this; + } + String cat = getCategory(token); + if (cat != null) { + CobiGenOutputCode type = this; + String className = tokenizer.next(); + if (className == null) { + LOG.warn("Missing {} name in {}", token, this.filename); + className = "Unknown"; + } + if (this.typeName != null) { // create nested type + type = createChild(); + type.buffer.addAll(this.buffer); + this.buffer.clear(); + type.bufferIndent = this.bufferIndent; + this.bufferIndent = -1; + } + type.category = cat; + type.typeName = className; + type.addLine2Block(CobiGenCodeBlock.NAME_DECLARATION, line, firstNonSpace, className); + if (line.trim().endsWith("{")) { + this.block = (CobiGenCompositeCodeBlock) this.block.getNext(); + } + return type; + } else if (token.startsWith("@")) { + this.buffer.add(line); + this.bufferIndent = tokenizer.getFirstTokenStart(); + } else if (token.equals("}") && !hasModifiers) { + if (this.member != null) { + this.member.addLine(true, line); + this.member = null; + return this; + } else { + if (firstNonSpace > 0) { + int indentCount = 0; + String indent = this.block.getLast().getIndent(); + if (indent != null) { + indentCount = indent.length(); + } + if (firstNonSpace > indentCount) { + LOG.info("Unexpected code: {}", line); + this.buffer.add(line); + return this; + } + } + } + if (this.typeName != null) { + addLine2Block(CobiGenCodeBlock.NAME_FOOTER, line, firstNonSpace, null); + return this; + } else { + LOG.info("Unexpected code: {}", line); + this.buffer.add(line); + return this; + } + } else { + // private String name; + // T getName(); + // ClassName() { + String blockName = null; + String codeName = null; + // String type = token; + char signChar = 0; + if (tokenizer.signChar == '(') { // constructor + if (token.equals(this.typeName) || token.equals("constructor")) { + blockName = CobiGenCodeBlock.NAME_CONSTRUCTORS; + codeName = token; + } + } else { + token = tokenizer.next(); + if (tokenizer.signChar == '(') { // method + blockName = CobiGenCodeBlock.NAME_METHODS; + } else { + blockName = CobiGenCodeBlock.NAME_FIELDS; + signChar = tokenizer.signChar; + } + codeName = token; + } + + CobiGenAtomicCodeBlock newMember = addLine2Block(blockName, line, firstNonSpace, codeName); + token = tokenizer.next(); + if (signChar == 0) { + signChar = tokenizer.signChar; + } + if (signChar == '{') { + this.member = newMember; + } else if (signChar != ';') { + LOG.info("Unexpected code: {}", line); + } + } + return this; + } + + private CobiGenAtomicCodeBlock appendWhileIndent(LineTokenizer tokenizer, CobiGenAtomicCodeBlock codeBlock) { + + if (tokenizer.len == 0) { + codeBlock.addLine(true, tokenizer.line); // assuming proper formatting and indentation of annotations + return codeBlock; + } + int indentCount = 0; + String indent = codeBlock.getIndent(); + if (indent != null) { + indentCount = indent.length(); // assuming no mixture of space and tabs + } + int tokenStart = tokenizer.getFirstTokenStart(); + if (tokenStart > indentCount) { + codeBlock.addLine(true, tokenizer.line); // assuming proper formatting and indentation of annotations + return codeBlock; + } else if ((tokenStart == indentCount) && (tokenStart < tokenizer.len)) { + char c = tokenizer.line.charAt(tokenStart); + if (c == '}') { + codeBlock.addLine(true, tokenizer.line); // assuming proper formatting and indentation of annotations + } + } + return null; + } + + private CobiGenAtomicCodeBlock addLine2Block(String blockName, String line, int tokenStart, String memberName) { + + boolean unique = CobiGenCodeBlock.NAME_PACKAGE.equals(blockName); + boolean blockMatched; + if (blockName == null) { + blockMatched = true; + } else { + blockMatched = false; + AbstractCobiGenCodeBlock targetSection = this.block.getNext(blockName); + if (targetSection != null) { + if (!unique || targetSection.isEmpty()) { + this.block = (CobiGenCompositeCodeBlock) targetSection; + blockMatched = true; + } + } + } + if ((tokenStart > 0) && this.block.getIndent() == null) { + String indent = line.substring(0, tokenStart); + this.block.setIndent(indent); + } + AbstractCobiGenCodeBlock top; + if (memberName == null) { + top = this.block; + } else { + top = this.block.addAtomicChild(memberName); + } + if (!this.buffer.isEmpty()) { + top.addLines(true, this.buffer); + this.buffer.clear(); + } + CobiGenAtomicCodeBlock result = top.addLine(true, line); + if (unique) { + AbstractCobiGenCodeBlock next = this.block.getNext(); + if (next != null) { + this.block = (CobiGenCompositeCodeBlock) next; + } + } + if (!blockMatched) { + LOG.info("Unexpected code structure: expected block {} for '{}' but had to add to block {} instead.", blockName, + line, this.block.getName()); + } + return result; + } + + /** + * Tokenizer for a line of source-code. + */ + protected static final class LineTokenizer { + + private final String line; + + private final int len; + + /** current token start position */ + private int tokenStart; + + /** start position after indent (at the first character that is not a whitespace). */ + private int firstTokenStart; + + private char signChar; + + /** + * The constructor. + * + * @param line the source-code line to tokenize. + */ + public LineTokenizer(String line) { + + super(); + this.line = line; + this.len = line.length(); + while (this.firstTokenStart < this.len) { + char c = line.charAt(this.firstTokenStart); + if (Character.isWhitespace(c)) { + this.firstTokenStart++; + } else { + this.tokenStart = this.firstTokenStart; + break; + } + } + } + + /** + * @return the {@link String#charAt(int) index} of the first {@link Character} that is NOT a + * {@link Character#isWhitespace(char) whitespace}. + */ + public int getFirstTokenStart() { + + return this.firstTokenStart; + } + + /** + * @return the indent of the line. + */ + public String getIndent() { + + if (this.firstTokenStart == 0) { + return null; + } + return this.line.substring(0, this.firstTokenStart); + } + + /** + * @return the next token from the source-code line. + */ + public String next() { + + this.signChar = 0; + if (this.tokenStart >= this.len) { + return ""; + } + int tokenEnd = this.len; + int i = this.tokenStart; + while (i < this.len) { + char c = this.line.charAt(i); + if (Character.isWhitespace(c)) { + if (tokenEnd == this.len) { + tokenEnd = i; + } + } else { + if (tokenEnd != this.len) { + break; + } else if (c == ';') { + this.signChar = c; + tokenEnd = i; + } else if (c == '<') { + tokenEnd = i; + this.signChar = c; + i = findEnd(i, '>', true); + } else if (c == '(') { + tokenEnd = i; + this.signChar = c; + i = findEnd(i, ')', true); + } else if (c == '{') { + tokenEnd = i; + this.signChar = c; + i = findEnd(i, '}', false); + } else if (c == '"') { + tokenEnd = i; + this.signChar = c; + // TODO multi-line string? + i++; + boolean escape = false; + while (i < this.len) { + c = this.line.charAt(i); + if (c == '\\') { + escape = !escape; + } else { + if (c == '"') { + if (!escape) { + break; // found end of string literal + } + } + escape = false; + } + } + } + } + i++; + } + String token = this.line.substring(this.tokenStart, tokenEnd); + if (this.tokenStart > this.firstTokenStart) { // not the first token? + if ("//".equals(token)) { + this.tokenStart = this.len; + return null; // ignore comment at end of the line + } + + if (token.startsWith("/*")) { + int commentEnd = this.line.indexOf("*/", i); + if (commentEnd > 0) { + i = commentEnd; + while (i < this.len) { + char c = this.line.charAt(i); + if (Character.isWhitespace(c)) { + i++; + } else { + break; + } + } + this.tokenStart = i; + return next(); + } + // otherwise we return the token and have to start a block-comment. + } + } + this.tokenStart = i; + return token; + } + + private int findEnd(int i, char closingBrace, boolean expected) { + + int deepth = 1; + i++; + while (i < this.len) { + char c = this.line.charAt(i); + if (c == this.signChar) { + deepth++; + } else if (c == closingBrace) { + deepth--; + if (deepth == 0) { + return i; + } + } + i++; + } + if (expected) { + LOG.info("Found opening character '{}' but missing closing character '{}' in line: {}", this.signChar, + closingBrace, this.line); + } + return this.len; + } + + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutputFactory.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutputFactory.java new file mode 100644 index 0000000000..62975f30b4 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutputFactory.java @@ -0,0 +1,83 @@ +package com.devonfw.cobigen.api.template.out; + +import java.util.HashMap; +import java.util.Map; +import java.util.ServiceLoader; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.github.mmm.base.text.CaseHelper; + +/** + * Factory for {@link CobiGenOutput}. + */ +public final class CobiGenOutputFactory { + + private static final Logger LOG = LoggerFactory.getLogger(CobiGenOutputFactory.class); + + private static final CobiGenOutputFactory INSTANCE = new CobiGenOutputFactory(); + + private final Map typeFactories; + + private CobiGenOutputFactory() { + + super(); + this.typeFactories = new HashMap<>(); + ServiceLoader loader = ServiceLoader.load(CobiGenOutputTypeFactory.class); + for (CobiGenOutputTypeFactory factory : loader) { + String type = factory.getType(); + CobiGenOutputTypeFactory duplicate = this.typeFactories.put(type, factory); + if (duplicate != null) { + LOG.warn("Duplicate CobiGenOutputTypeFactory for {}: replacing {} with {}", type, + duplicate.getClass().getName(), factory.getClass().getName()); + } + } + if (this.typeFactories.isEmpty()) { + LOG.error("No CobiGenOutputTypeFactory was registered - check plugins."); + } else { + LOG.debug("Registered {} instance(s) of CobiGenOutputTypeFactory: {}", this.typeFactories.size(), + this.typeFactories); + } + } + + /** + * @param filename the filename of the output to generate. + * @return the {@link CobiGenOutput}. + */ + public CobiGenOutput create(String filename) { + + CobiGenOutputTypeFactory factory = null; + int lastDot = filename.lastIndexOf('.'); + String extension = ""; + if (lastDot > 0) { + extension = CaseHelper.toLowerCase(filename.substring(lastDot + 1)); + factory = this.typeFactories.get(extension); + if (factory == null) { + for (CobiGenOutputTypeFactory typeFactory : this.typeFactories.values()) { + if (typeFactory.isResponsible(extension)) { + factory = typeFactory; + break; + } + } + } + } + if (factory == null) { + LOG.info("No output factory found for file {} with extension {} - factories registered for extensions {}", + filename, extension, this.typeFactories.keySet()); + return null; + } + CobiGenOutput output = factory.create(filename); + LOG.debug("Created output of {} for file {} via factory {}", output.getClass(), filename, factory.getClass()); + return output; + } + + /** + * @return the singleton instance. + */ + public static CobiGenOutputFactory get() { + + return INSTANCE; + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutputFallback.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutputFallback.java new file mode 100644 index 0000000000..58895a61a7 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutputFallback.java @@ -0,0 +1,68 @@ +package com.devonfw.cobigen.api.template.out; + +/** + * Dummy implementation of {@link AbstractCobiGenOutput} to indicate that {@link #addLine(String) lines} shall not be + * buffered but directly written to the output. + */ +public class CobiGenOutputFallback extends AbstractCobiGenOutput { + + /** + * The constructor. + * + * @param filename the {@link #getFilename() filename}. + */ + public CobiGenOutputFallback(String filename) { + + super(filename); + } + + @Override + public ImportStatement getImport(String name) { + + return null; + } + + @Override + public boolean addImport(String qualifiedName) { + + throw new UnsupportedOperationException(); + } + + @Override + public boolean addImport(QualifiedName qualifiedName) { + + throw new UnsupportedOperationException(); + } + + @Override + public boolean addImport(ImportStatement importStatement) { + + throw new UnsupportedOperationException(); + } + + @Override + public void addProperty(String name, String qualifiedTypeName, String description) { + + throw new UnsupportedOperationException(); + } + + @Override + public void addProperty(String name, QualifiedName type, String description) { + + throw new UnsupportedOperationException(); + } + + @Override + public void addProperty(String name, QualifiedName type, String description, boolean addImport, boolean addField, + boolean addGetter, boolean addSetter) { + + throw new UnsupportedOperationException(); + } + + @Override + public AbstractCobiGenOutput addLine(String line) { + + return this; + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutputTypeFactory.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutputTypeFactory.java new file mode 100644 index 0000000000..71953f7c26 --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/CobiGenOutputTypeFactory.java @@ -0,0 +1,34 @@ +package com.devonfw.cobigen.api.template.out; + +/** + * Interface for a factory to {@link #create(String) create} the {@link CobiGenOutput} for a specific {@link #getType() + * type}. + */ +public interface CobiGenOutputTypeFactory { + + /** + * @return the default type (extension in lower-case excluding the dot like "java"). May only be {@code null} for the + * fallback implementation that is build-in CobiGen. + */ + String getType(); + + /** + * @param extension the file extension in lower-case excluding the dot (e.g. "java", "ts", "tsx", "cs"). + * @return {@code true} if this {@link CobiGenOutputTypeFactory} is responsible for the given {@code extension}, + * {@code false} otherwise. + */ + default boolean isResponsible(String extension) { + + if (extension.equals(getType())) { + return true; + } + return false; + } + + /** + * @param filename the {@link CobiGenOutput#getFilename() filename}. + * @return the newly created {@link CobiGenOutput}. + */ + CobiGenOutput create(String filename); + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/ImportStatement.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/ImportStatement.java new file mode 100644 index 0000000000..cb1821df6e --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/ImportStatement.java @@ -0,0 +1,62 @@ +package com.devonfw.cobigen.api.template.out; + +/** + * Interface for an import statement of whatever programming language. + */ +public interface ImportStatement { + + /** + * @return {@code true} in case of a static import that imports an element of a type rather than the type itself, + * {@code false} otherwise. + */ + default boolean isStatic() { + + return getStaticReference() != null; + } + + /** + * @return the number of {@link #getKey(int) keys}. Will always be {@code 1} for Java. E.g. in TypeScript you can + * import multiple items in a single import what will result in a higher count. + */ + int getKeyCount(); + + /** + * @return the first {@link #getKey(int) key} to import. + */ + default String getKey() { + + return getKey(0); + } + + /** + * @param i the index of the requested key to import. In Java this always has to be zero. + * @return the key to import for the given index. Will be the {@link Class#getSimpleName() simple name} in Java. + */ + String getKey(int i); + + /** + * @return the target that is imported. Will be the {@link Class#getName() qualified name} in case of Java. E.g. in + * TypeScript it will be the quoted path to the imported file. + */ + String getTarget(); + + /** + * @return the optional reference on the {@link #getTarget() target} in case of a {@link #isStatic() static import}. + * So in that case this will be the method or constant to import. Will be {@code null} if not a + * {@link #isStatic() static import}. + */ + default String getStaticReference() { + + return null; + } + + /** + * @return the optional alias. E.g. for the TypeScript statement "import * as shapes from './shapes';" this will + * return "shapes". + */ + default String getAlias() { + + return null; + } + +} diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/QualifiedName.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/QualifiedName.java new file mode 100644 index 0000000000..00c292190c --- /dev/null +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/template/out/QualifiedName.java @@ -0,0 +1,128 @@ +package com.devonfw.cobigen.api.template.out; + +import java.util.Objects; + +/** + * A qualified name with {@link #getNamespace() namespace}, {@link #getSimpleName() simple name} and its + * {@link #getQualifiedName() qualified name}. + */ +public class QualifiedName { + + private final String namespace; + + private final String simpleName; + + private final String qualifiedName; + + /** + * The constructor. + * + * @param namespace the {@link #getNamespace() namespace}. + * @param simpleName the {@link #getSimpleName() simple name}. + * @param qualifiedName the {@link #getQualifiedName() qualified name}. + */ + public QualifiedName(String namespace, String simpleName, String qualifiedName) { + + super(); + this.namespace = namespace; + this.simpleName = simpleName; + this.qualifiedName = qualifiedName; + } + + /** + * @return the namespace (e.g. package name or XML namespace URI). + */ + public String getNamespace() { + + return this.namespace; + } + + /** + * @return the simple name (also called local name or unqualified name). + */ + public String getSimpleName() { + + return this.simpleName; + } + + /** + * @return the qualified name. + */ + public String getQualifiedName() { + + return this.qualifiedName; + } + + @Override + public int hashCode() { + + return Objects.hash(this.namespace, this.qualifiedName, this.simpleName); + } + + @Override + public boolean equals(Object obj) { + + if (this == obj) { + return true; + } else if ((obj == null) || (getClass() != obj.getClass())) { + return false; + } + QualifiedName other = (QualifiedName) obj; + return Objects.equals(this.namespace, other.namespace) && Objects.equals(this.qualifiedName, other.qualifiedName) + && Objects.equals(this.simpleName, other.simpleName); + } + + @Override + public String toString() { + + return this.qualifiedName; + } + + /** + * Factory method to create {@link QualifiedName} for Java like naming. + * + * @param qname the {@link #getQualifiedName() qualified name}. + * @return the parsed {@link QualifiedName}. + */ + public static QualifiedName of(String qname) { + + return of(qname, "."); + } + + /** + * Factory method to create {@link QualifiedName}. + * + * @param qname the {@link #getQualifiedName() qualified name}. + * @param separator the seperator {@link String} (e.g. "." for Java or ":" for XML). + * @return the parsed {@link QualifiedName}. + */ + public static QualifiedName of(String qname, String separator) { + + String namespace; + String simpleName; + int lastSeparator = qname.lastIndexOf(separator); + if (lastSeparator > 0) { + namespace = qname.substring(0, lastSeparator); + simpleName = qname.substring(lastSeparator + separator.length()); + } else { + namespace = ""; + simpleName = qname; + } + return new QualifiedName(namespace, simpleName, qname); + } + + /** + * Factory method to create {@link QualifiedName}. + * + * @param namespace the {@link #getNamespace() namespace}. + * @param simpleName the {@link #getSimpleName() simple name}. + * @param separator the seperator character (e.g. '.' for Java). + * @return the composed {@link QualifiedName}. + */ + public static QualifiedName of(String namespace, String simpleName, char separator) { + + String qname = namespace + separator + simpleName; + return new QualifiedName(namespace, simpleName, qname); + } + +} diff --git a/cobigen/cobigen-core-api/src/test/java/com/devonfw/cobigen/api/model/CobiGenModelTest.java b/cobigen/cobigen-core-api/src/test/java/com/devonfw/cobigen/api/model/CobiGenModelTest.java new file mode 100644 index 0000000000..69ac979222 --- /dev/null +++ b/cobigen/cobigen-core-api/src/test/java/com/devonfw/cobigen/api/model/CobiGenModelTest.java @@ -0,0 +1,86 @@ +package com.devonfw.cobigen.api.model; + +import org.assertj.core.api.Assertions; +import org.junit.Test; + +/** + * Test of {@link CobiGenModel} with its implementation {@link CobiGenModelDefault}. + */ +public class CobiGenModelTest extends Assertions { + + /** + * Test of {@link CobiGenModel#resolve(String, char, VariableSyntax)} with {@link VariableSyntax#AGNOSTIC}. + */ + @Test + public void testResolveAgnostic() { + + CobiGenModel model = new CobiGenModelDefault(); + CobiGenVariableDefinitions.ENTITY_NAME.setValue(model, "MyExample"); + CobiGenVariableDefinitions.ROOT_PACKAGE.setValue(model, "com.customer.app"); + CobiGenVariableDefinitions.COMPONENT_NAME.setValue(model, "MyComponent"); + VariableSyntax syntax = VariableSyntax.AGNOSTIC; + assertThat(model.resolve("Hello X_EntityName_X or x-entity-name-x in resolve.", '.', syntax)) + .isEqualTo("Hello MyExample or my-example in resolve."); + assertThat(model.resolve("X_EntityName_Xx-entity-name-x", '.', syntax)).isEqualTo("MyExamplemy-example"); + assertThat(model.resolve("X_ENTITY_NAME_Xx.entity.name.x", '.', syntax)).isEqualTo("MY_EXAMPLEmy.example"); + assertThat(model.resolve("x_rootpackage_x.x_component_x.layer.x_scope_x.x_detail_x", '.', syntax)) + .isEqualTo("com.customer.app.mycomponent.layer"); + assertThat(model.resolve("${EntityName}", '.', syntax)).isEqualTo("${EntityName}"); + } + + /** + * Test of {@link CobiGenModel#resolve(String, char, VariableSyntax)} with {@link VariableSyntax#DOLLAR}. + */ + @Test + public void testResolveDollar() { + + CobiGenModel model = new CobiGenModelDefault(); + CobiGenVariableDefinitions.ENTITY_NAME.setValue(model, "MyExample"); + CobiGenVariableDefinitions.ROOT_PACKAGE.setValue(model, "com.customer.app"); + CobiGenVariableDefinitions.COMPONENT_NAME.setValue(model, "MyComponent"); + VariableSyntax syntax = VariableSyntax.DOLLAR; + assertThat(model.resolve("Hello ${variables.EntityName} or ${entity-name?uncap_first} in resolve.", '.', syntax)) + .isEqualTo("Hello MyExample or myExample in resolve."); + assertThat(model.resolve("${EntityName}${entity-name}", '.', syntax)).isEqualTo("MyExampleMyExample"); + assertThat(model.resolve("${EntityName?upper_case}${entity.name?lower_case}", '.', syntax)) + .isEqualTo("MYEXAMPLEmyexample"); + assertThat(model.resolve("${rootpackage}.${variables.component?lower_case}.layer.${scope}.${detail}", '.', syntax)) + .isEqualTo("com.customer.app.mycomponent.layer.."); + assertThat(model.resolve("${rootpackage?cap_first}", '/', syntax)).isEqualTo("Com/customer/app"); + assertThat(model.resolve("X_EntityName_X", '.', syntax)).isEqualTo("X_EntityName_X"); + } + + /** + * Test of {@link CobiGenModel#resolve(String, char, VariableSyntax)} with {@link VariableSyntax#DOLLAR}. + */ + @Test + public void testResolveMixed() { + + CobiGenModel model = new CobiGenModelDefault(); + CobiGenVariableDefinitions.ENTITY_NAME.setValue(model, "MyExample"); + CobiGenVariableDefinitions.ROOT_PACKAGE.setValue(model, "com.customer.app"); + CobiGenVariableDefinitions.COMPONENT_NAME.setValue(model, "MyComponent"); + assertThat(model.resolve("Hello ${variables.EntityName} or x-entity-name-x in resolve.", '.')) + .isEqualTo("Hello MyExample or my-example in resolve."); + } + + /** + * Test of hierarchical {@link CobiGenModel} with inheritance from parent model. + */ + @Test + public void testInheritance() { + + CobiGenModel root = new CobiGenModelDefault(); + CobiGenModel child = new CobiGenModelDefault(root); + CobiGenModel baby = new CobiGenModelDefault(child); + String key = "foo"; + assertThat(baby.getVariable(key)).isNull(); + root.put(key, "rootFoo"); + assertThat(baby.getVariable(key)).isEqualTo("rootFoo"); + child.put(key, "childFoo"); + assertThat(baby.getVariable(key)).isEqualTo("childFoo"); + baby.put(key, "babyFoo"); + assertThat(baby.getVariable(key)).isEqualTo("babyFoo"); + } + +} diff --git a/cobigen/cobigen-core/pom.xml b/cobigen/cobigen-core/pom.xml index e97f0815a1..464d65b9b4 100644 --- a/cobigen/cobigen-core/pom.xml +++ b/cobigen/cobigen-core/pom.xml @@ -51,6 +51,13 @@ commons-jxpath 1.3
+ + + javax.inject + javax.inject + 1 + + jakarta.xml.bind diff --git a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/entity/Variables.java b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/entity/Variables.java index 0b6d483584..e665c858ea 100644 --- a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/entity/Variables.java +++ b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/entity/Variables.java @@ -1,61 +1,32 @@ package com.devonfw.cobigen.impl.config.entity; import java.nio.file.Path; -import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import com.devonfw.cobigen.api.constants.ConfigurationConstants; -import com.devonfw.cobigen.api.exception.UnknownExpressionException; -import com.devonfw.cobigen.api.util.StringUtil; +import com.devonfw.cobigen.api.model.AbstractCobiGenModel; import com.devonfw.cobigen.impl.config.reader.CobiGenPropertiesReader; -import com.devonfw.cobigen.impl.exceptions.UnknownContextVariableException; -import com.devonfw.cobigen.impl.model.ModelBuilderImpl; import io.github.mmm.base.text.CaseSyntax; /** * This class is a container for variables that can inherit from parent {@link Variables} building a hierarchy. The - * {@link #containsKey(String) keys} for {@link #get(String) getting} and {@link #put(String, String) setting} variables + * {@link #containsKey(String) keys} for {@link #get(String) getting} and {@link #put(String, Object) setting} variables * are internally normalized (see {@link CaseSyntax#normalizeExample(String)}) and therefore treated case-insensitive as * well as stripped from special characters. Hence, you should name and use variable names in CobiGen templates and * their paths accordingly. For legacy support also the original variable name is used with priority so that special * characters are still supported for legacy syntax (e.g. ${Variable-Name}). */ -public class Variables { +public class Variables extends AbstractCobiGenModel { - /** The variables prefix. */ - private static final String PREFIX_VARIABLES = ModelBuilderImpl.NS_VARIABLES + "."; + /** The {@link Properties} containing the local variables. */ + private final Properties properties; - /** - * A {@link Character#isLetter(char) letter} character that is not to be expected to occur in regular input values. - */ - private static final char DUMMY_LETTER_FOR_DOT = 'สต'; - - /** - * Regex {@link Pattern} for variable in dollar syntax (${...}). - */ - private static final Pattern PATTERN_VARIABLE_DOLLAR_SYNTAX = Pattern - .compile("\\$\\{([^?#}]+)(((\\?|#)[^}?#]+)*)\\}"); - - /** - * Regex {@link Pattern} for variable in language-agnostic case-syntax (x_..._x). - */ - private static final Pattern PATTERN_VARIABLE_CASE_SYNTAX = Pattern.compile("[xX]__([a-zA-Z0-9_-]+?)__[xX]"); - - /** The parent {@link Variables} to inherit or {@code null}. */ - private final Variables parent; - - /** The {@link Properties} containing the local variables. */ - private final Properties properties; - - /** - * The constructor for the root variables. - */ - public Variables() { + /** + * The constructor for the root variables. + */ + public Variables() { this(null, null); } @@ -88,136 +59,20 @@ public Variables(Variables parent) { */ public Variables(Properties properties, Variables parent) { - super(); + super(parent); if (properties == null) { this.properties = new Properties(); } else { this.properties = properties; + putAll(getOriginalMap(), true); } - this.parent = parent; - } - - /** - * @param key the raw key. - * @return the normalized key. - */ - private String normalizeKey(String key) { - - return CaseSyntax.normalizeExample(key); - } - - /** - * @see #containsKey(String) - * - * @param key the raw key to check. - * @return {@code true} if this {@link Variables} contain the given {@code key}, {@code false} otherwise. - */ - private boolean containsKeyInternal(String key) { - - if (this.properties.containsKey(key)) { - return true; - } - if (this.parent != null) { - return this.parent.containsKeyInternal(key); - } - return false; - } - - /** - * @see Map#containsKey(Object) - * - * @param key the key to check. - * @return {@code true} if this {@link Variables} contain the given {@code key}, {@code false} otherwise. - */ - public boolean containsKey(String key) { - - if (containsKeyInternal(key)) { - return true; - } - String normalizeKey = normalizeKey(key); - if (normalizeKey.equals(key)) { - return false; - } - return containsKeyInternal(normalizeKey); } - /** - * @see #getInternal(String) - * - * @param key the raw key to get. - * @return the value of the variable with the given {@code key}. May be {@code null}. - */ - private String getInternal(String key) { - - String value = this.properties.getProperty(key); - if ((value == null) && !containsKeyInternal(key) && (this.parent != null)) { - value = this.parent.getInternal(key); - } - return value; - } - - /** - * @see Map#get(Object) - * - * @param key the key to get. - * @return the value of the variable with the given {@code key}. May be {@code null}. - */ - public String get(String key) { - - String value = getInternal(key); - if (value == null) { - String normalizeKey = normalizeKey(key); - if (!normalizeKey.equals(key)) { - value = getInternal(normalizeKey); - } - } - return value; - } - - /** - * @see Map#put(Object, Object) - * - * @param key the key of the variable to set. - * @param value the value of the variable to set. - * @return the previous value of the given variable. - */ - public String put(String key, String value) { - - String old = getInternal(key); - this.properties.setProperty(key, value); - String normalizeKey = normalizeKey(key); - if (!normalizeKey.equals(key)) { - if (old == null) { - old = getInternal(normalizeKey); - } - this.properties.put(normalizeKey, value); - } - return old; - } - - /** - * @return this {@link Variables} as {@link Map}. Further changes to this {@link Variables} or one of its ancestors - * are NOT reflected by the returned {@link Map}. This is an expensive operation that may only be called to - * pass {@link Variables} to a templating engine that cannot support {@link Variables} directly. - */ - public Map asMap() { + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public Map getOriginalMap() { - HashMap map = new HashMap<>(this.properties.size()); - asMap(map); - return map; - } - - /** - * @see #asMap() - * @param map the {@link Map} to populate. - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - private void asMap(Map map) { - - if (this.parent != null) { - this.parent.asMap(map); - } - map.putAll((Map) this.properties); + return (Map) this.properties; } /** @@ -226,7 +81,7 @@ private void asMap(Map map) { * @param map variable entries to be added. * @return the newly created instance. */ - public static Variables fromMap(Map map) { + public static Variables fromMap(Map map) { Variables variables = new Variables(); variables.putAll(map); @@ -242,173 +97,11 @@ public static Variables fromMap(Map map) { */ public Variables forChildFolder(Path folder) { - Properties childProperties = CobiGenPropertiesReader.load(folder, this.properties); - if (childProperties == this.properties) { + Properties childProperties = CobiGenPropertiesReader.load(folder); + if (childProperties == null) { return this; } return new Variables(childProperties, this); } - /** - * @param string the {@link String} where to resolve all variables. - * @return the given {@code string} with all variables (e.g. ${variableName#uncapfirst} or - * $_VariableName_$) replaced with those defined by this {@link Variables}. - */ - public String resolve(String string) { - - return resolve(string, '.'); - } - - /** - * - * @param string the {@link String} where to resolve all variables. - * @param replacementForDot the character used as replacement for the dot character ('.') or '\0' for no replacement - * (remove dots according to case syntax). - * @return the given {@code string} with all variables (e.g. ${variableName#uncapfirst} or - * $_VariableName_$) replaced with those defined by this {@link Variables}. - */ - public String resolve(String string, char replacementForDot) { - - String resolvedString = resolveVariables(string, PATTERN_VARIABLE_DOLLAR_SYNTAX, false, replacementForDot); - resolvedString = resolveVariables(resolvedString, PATTERN_VARIABLE_CASE_SYNTAX, true, replacementForDot); - return resolvedString; - } - - /** - * Resolves all variables from the given {@code string}. - * - * @param string the string to resolve. - * @param pattern the {@link Pattern} with the variable syntax. The {@link Matcher#group(int) group(1)} has to match - * the actual variable name. - * @param supportCase {@code true} for the new case transformation by example, {@code false} otherwise. - * @param replacementForDot the character used as replacement for the dot character ('.') or '\0' for no replacement. - * @return the given {@code string} with all variables resolved. - */ - private String resolveVariables(String string, Pattern pattern, boolean supportCase, char replacementForDot) { - - Matcher m = pattern.matcher(string.toString()); - StringBuffer out = new StringBuffer(); - while (m.find()) { - String variableKey = m.group(1); - if (!supportCase && (variableKey.startsWith(PREFIX_VARIABLES))) { - variableKey = variableKey.substring(PREFIX_VARIABLES.length()); - } - // a variable like ${detail} can be explicitly set to null - // this is considered as the empty string but null instead of "" is required for - // free-marker - if (!containsKey(variableKey)) { - throw new UnknownContextVariableException(variableKey); - } - - String variableValue = get(variableKey); - if (variableValue != null) { - boolean containsDot = variableValue.contains("."); - if (containsDot && (replacementForDot != '\0')) { - if (supportCase) { - variableValue = variableValue.replace('.', DUMMY_LETTER_FOR_DOT); - } else { - variableValue = variableValue.replace('.', replacementForDot); - } - } - if (supportCase) { - CaseSyntax syntax = CaseSyntax.ofExample(variableKey, true); - variableValue = syntax.convert(variableValue); - if (containsDot) { - variableValue = variableValue.replace(DUMMY_LETTER_FOR_DOT, replacementForDot); - } - } else { - variableValue = resolveFunction(variableValue, m.group(2)); - } - m.appendReplacement(out, variableValue); - } else { - m.appendReplacement(out, ""); - } - } - m.appendTail(out); - - return out.toString(); - - } - - /** - * Legacy support for freemarker function syntax. - * - * @param value the value of the variable to resolve. - * @param function the freemarker function(s) to simulate and apply. - * @return the resolved {@code value} with the given freemarker function(s) applied. - */ - private String resolveFunction(String value, String function) { - - if (function != null) { - boolean first = true; - for (String modifier : function.split("(\\?|#)")) { - if (first) { - first = false; - continue; // ignore first as always empty due to beginning '?' - } - value = applyStringModifier(modifier, value); - } - } - return value; - } - - /** - * Applies the given {@link String} modifier defined by ?modifier behind the variable reference - * - * @param modifierName name of the {@link String} modifier to be applied - * @param string {@link String} the modifier should be applied on - * @return the modified {@link String} - * @throws UnknownExpressionException if there is an unknown variable modifier - */ - private String applyStringModifier(String modifierName, String string) throws UnknownExpressionException { - - // simple operators - if (modifierName.equals("cap_first")) { - return StringUtil.capFirst(string); - } else if (modifierName.equals("uncap_first")) { - return StringUtil.uncapFirst(string); - } else if (modifierName.equals("lower_case")) { - return string.toLowerCase(); - } else if (modifierName.equals("upper_case")) { - return string.toUpperCase(); - } - - String parameterRegex = "\\s*'([^']*)'\\s*"; - - // ?replace(String regex, String replacement) - Pattern p = Pattern.compile("replace\\(" + parameterRegex + "," + parameterRegex + "\\)"); - Matcher m = p.matcher(modifierName); - - if (m.matches()) { - return string.replaceAll(m.group(1), m.group(2)); - } - - // ?removeSuffix(String suffix) - p = Pattern.compile("removeSuffix\\(" + parameterRegex + "\\)"); - m = p.matcher(modifierName); - - if (m.matches() && string.endsWith(m.group(1))) { - return string.substring(0, string.length() - m.group(1).length()); - } - - // ?removePrefix(String prefix) - p = Pattern.compile("removePrefix\\(" + parameterRegex + "\\)"); - m = p.matcher(modifierName); - - if (m.matches() && string.startsWith(m.group(1))) { - return string.substring(m.group(1).length(), string.length()); - } - - throw new UnknownExpressionException("?" + modifierName); - } - - /** - * @param map the {@link Map} with the variables to add. - */ - public void putAll(Map map) { - - for (Entry entry : map.entrySet()) { - put(entry.getKey(), entry.getValue()); - } - } } diff --git a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/reader/CobiGenPropertiesReader.java b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/reader/CobiGenPropertiesReader.java index 5e82141d0e..5eb1b80d5f 100644 --- a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/reader/CobiGenPropertiesReader.java +++ b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/reader/CobiGenPropertiesReader.java @@ -21,33 +21,16 @@ public class CobiGenPropertiesReader { /** * @param folder the {@link Path} pointing to the folder that may contain a {@code cobigen.properties} file. * @return the new {@link Properties} containing the properties from a potential {@code cobigen.properties}. Will be - * empty if no such properties file exists. + * {@code null} if no such properties file exists. */ public static final Properties load(Path folder) { - return load(folder, null); - } - - /** - * @param folder the {@link Path} pointing to the folder that may contain a {@code cobigen.properties} file. - * @param parent the parent {@link Properties} to inherit from and override with potentially read properties. - * @return the new {@link Properties} containing the properties from a potential {@code cobigen.properties} merged - * with the given {@code parent} properties. - */ - public static final Properties load(Path folder, Properties parent) { - Path propertiesPath = folder.resolve(ConfigurationConstants.COBIGEN_PROPERTIES); if (!Files.exists(propertiesPath)) { - if (parent == null) { - return new Properties(); - } - return parent; + return null; } Properties properties = new Properties(); - if (parent != null) { - properties.putAll(parent); - } try (Reader reader = Files.newBufferedReader(propertiesPath, UTF_8)) { properties.load(reader); } catch (IOException e) { diff --git a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/reader/TemplatesConfigurationReader.java b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/reader/TemplatesConfigurationReader.java index ffc8390e8b..069e80d12f 100644 --- a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/reader/TemplatesConfigurationReader.java +++ b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/reader/TemplatesConfigurationReader.java @@ -444,7 +444,7 @@ private Template createTemplate(TemplateFile templateFile, String templateName, String unresolvedDestinationPath = unresolvedTemplatePath; TemplateFolder templateFolder = templateFile.getParent(); - String relocate = templateFolder.getVariables().get(PROPERTY_RELOCATE); + String relocate = templateFolder.getVariables().getVariable(PROPERTY_RELOCATE); if (relocate != null) { if (scanSourcePath != null) { // The relative template path has to be specifically parsed to string and back to a path so diff --git a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/resolver/PathExpressionResolver.java b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/resolver/PathExpressionResolver.java index f744da046f..67e9c3dfa8 100644 --- a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/resolver/PathExpressionResolver.java +++ b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/resolver/PathExpressionResolver.java @@ -38,8 +38,7 @@ public String evaluateExpressions(String relativeUnresolvedPath) throws UnknownC return null; } String resolvedPath = this.variables.resolve(relativeUnresolvedPath, '/'); - // Cleanup empty path segments - return resolvedPath.replaceAll("/+", "/"); + return resolvedPath; } } diff --git a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/generator/GenerationProcessorImpl.java b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/generator/GenerationProcessorImpl.java index 12a1e1801e..f517cf5b2e 100644 --- a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/generator/GenerationProcessorImpl.java +++ b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/generator/GenerationProcessorImpl.java @@ -307,8 +307,6 @@ private ClassLoader prependTemplatesClassloader(ClassLoader inputProjectClassLoa return combinedClassLoader; } catch (MalformedURLException e) { throw new CobiGenRuntimeException("Invalid Path", e); - } catch (IOException e) { - throw new CobiGenRuntimeException("Unable to read " + cpCacheFile, e); } } else { combinedClassLoader = inputProjectClassLoader; @@ -442,7 +440,7 @@ private void generate(TemplateTo template, TriggerInterpreter triggerInterpreter // resolve temporary file paths @SuppressWarnings("unchecked") PathExpressionResolver pathExpressionResolver = new PathExpressionResolver( - Variables.fromMap((Map) model.get(ModelBuilderImpl.NS_VARIABLES))); + Variables.fromMap((Map) model.get(ModelBuilderImpl.NS_VARIABLES))); String resolvedTargetDestinationPath = pathExpressionResolver .evaluateExpressions(templateEty.getUnresolvedTargetPath()); String resolvedTmpDestinationPath = pathExpressionResolver diff --git a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/model/ModelBuilderImpl.java b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/model/ModelBuilderImpl.java index 4f85ded35e..ee607480bc 100644 --- a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/model/ModelBuilderImpl.java +++ b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/model/ModelBuilderImpl.java @@ -98,11 +98,14 @@ public Map createModel(TriggerInterpreter triggerInterpreter) th public Map enrichByContextVariables(Map model, TriggerInterpreter triggerInterpreter, Template template, Path targetRootPath, GenerationReportTo report) { - Map variables = Maps.newHashMap(); - Map contextVariables = new ContextVariableResolver(this.generatorInput, this.trigger) + Map variables = Maps.newHashMap(); + Map contextVariables = new ContextVariableResolver(this.generatorInput, this.trigger) .resolveVariables(triggerInterpreter, report).asMap(); - Map templateProperties = template.getVariables().asMap(); + Map templateProperties = template.getVariables().asMap(); Properties targetCobiGenProperties = CobiGenPropertiesReader.load(targetRootPath); + if (targetCobiGenProperties == null) { + targetCobiGenProperties = new Properties(); + } // if there are properties overriding each other, throw an exception for better usability. // This is most probably a not intended mechanism such that we simply will not support it. Set intersection = new HashSet<>(contextVariables.keySet()); diff --git a/cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/reader/TemplatesConfigurationReaderTest.java b/cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/reader/TemplatesConfigurationReaderTest.java index 98d5b810bf..48eec47ffd 100644 --- a/cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/reader/TemplatesConfigurationReaderTest.java +++ b/cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/reader/TemplatesConfigurationReaderTest.java @@ -522,11 +522,11 @@ public void testRelocate_overlappingTemplateExtensionAndScan() { // validation String staticRelocationPrefix = "../api/"; - String scanRelTemplatePath = "$_rootpackage_$/$_component_$/common/api/"; - Template template = verifyScannedTemplate(templates, "$_EntityName_$.java", scanRelTemplatePath, + String scanRelTemplatePath = "x_rootpackage_x/x_component_x/common/api/"; + Template template = verifyScannedTemplate(templates, "X_EntityName_X.java", scanRelTemplatePath, templatesConfigurationRoot, staticRelocationPrefix, templateScanDestinationPath); - String templateName = "$_EntityName_$2.java"; + String templateName = "X_EntityName_X2.java"; template = templates.get(templateName); assertThat(template).isNotNull(); String pathWithName = scanRelTemplatePath + templateName; @@ -561,8 +561,8 @@ public void testRelocate_overlappingExplicitTemplateDestinationPathAndRelocatedS // validation String staticRelocationPrefix = "../api/"; - String scanRelTemplatePath = "$_rootpackage_$/$_component_$/common/api/"; - Template template = verifyScannedTemplate(templates, "$_EntityName_$.java", scanRelTemplatePath, + String scanRelTemplatePath = "x_rootpackage_x/x_component_x/common/api/"; + Template template = verifyScannedTemplate(templates, "X_EntityName_X.java", scanRelTemplatePath, templatesConfigurationRoot, staticRelocationPrefix, templateScanDestinationPath); template = templates.get("ExplicitlyDefined"); @@ -571,7 +571,7 @@ public void testRelocate_overlappingExplicitTemplateDestinationPathAndRelocatedS assertThat(template.getAbsoluteTemplatePath().toString().replace('\\', '/')) .isEqualTo(templatesConfigurationRoot + "OuterTemplate.java"); // the destination path has designed to match a relocated path during the scan by intention - String destinationPath = "src/main/java/$_rootpackage_$/$_component_$/common/api/ExplicitlyDefined.java"; + String destinationPath = "src/main/java/x_rootpackage_x/x_component_x/common/api/ExplicitlyDefined.java"; assertThat(template.getUnresolvedTemplatePath()).isEqualTo(destinationPath); assertThat(template.getUnresolvedTargetPath()).isEqualTo(destinationPath); assertThat(template.getVariables().asMap()).hasSize(0); @@ -596,12 +596,12 @@ public void testRelocate_propertiesResolution() { assertThat(templates).hasSize(2); // assert - Template template = templates.get("$_Component_$.java"); + Template template = templates.get("X_Component_X.java"); assertThat(template).isNotNull(); assertThat(template.getVariables().asMap()).isNotNull().containsEntry("foo", "root").containsEntry("bar", "barValue"); - template = templates.get("$_EntityName_$Eto.java"); + template = templates.get("X_EntityName_XEto.java"); assertThat(template).isNotNull(); assertThat(template.getVariables().asMap()).isNotNull().containsEntry("relocate", "../api2/${cwd}") .containsEntry("foo", "logic.api.to").containsEntry("bar", "barValue").containsEntry("local", "localValue"); @@ -629,10 +629,10 @@ public void testRelocate_withTemplateFilenameEnding() { assertThat(templates).hasSize(1); String staticRelocationPrefix = "../server/"; - String templateName = "$_Component_$Impl.java"; + String templateName = "X_Component_XImpl.java"; Template template = templates.get(templateName); assertThat(template).isNotNull(); - String pathWithName = "$_rootpackage_$/$_component_$/logic/impl/" + templateName; + String pathWithName = "x_rootpackage_x/x_component_x/logic/impl/" + templateName; assertThat(template.getRelativeTemplatePath()).isEqualTo("templates/" + pathWithName + ".ftl"); assertThat(template.getAbsoluteTemplatePath().toString().replace('\\', '/')) .isEqualTo(templatesConfigurationRoot + "templates/" + pathWithName + ".ftl"); @@ -665,14 +665,14 @@ public void testRelocate() { assertThat(templates).hasSize(3); String staticRelocationPrefix = "../api/"; - verifyScannedTemplate(templates, "$_EntityName_$Entity.java", "$_rootpackage_$/$_component_$/dataaccess/api/", + verifyScannedTemplate(templates, "X_EntityName_XEntity.java", "x_rootpackage_x/x_component_x/dataaccess/api/", templatesConfigurationRoot, staticRelocationPrefix, templateScanDestinationPath); staticRelocationPrefix = "../api2/"; - verifyScannedTemplate(templates, "$_EntityName_$Eto.java", "$_rootpackage_$/$_component_$/logic/api/to/", + verifyScannedTemplate(templates, "X_EntityName_XEto.java", "x_rootpackage_x/x_component_x/logic/api/to/", templatesConfigurationRoot, staticRelocationPrefix, templateScanDestinationPath); - verifyScannedTemplate(templates, "$_Component_$.java", "$_rootpackage_$/$_component_$/logic/api/", + verifyScannedTemplate(templates, "X_Component_X.java", "x_rootpackage_x/x_component_x/logic/api/", templatesConfigurationRoot, noRelocation, templateScanDestinationPath); } diff --git a/cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/resolver/PathExpressionResolverTest.java b/cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/resolver/PathExpressionResolverTest.java index 1a1624d54f..3dc8a7c6fc 100644 --- a/cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/resolver/PathExpressionResolverTest.java +++ b/cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/resolver/PathExpressionResolverTest.java @@ -14,129 +14,129 @@ */ public class PathExpressionResolverTest { - /** - * Test target - */ - private static PathExpressionResolver target; - - static { - Variables variables = new Variables(); - variables.put("v1", "praefix Value Suffix"); - variables.put("v2", "Praefix Value Suffix"); - variables.put("variablename", "PrefixValueSuffix"); - variables.put("variablekey", "prefix_value_suffix"); - variables.put("PackageName", "my.pkg.name"); - target = new PathExpressionResolver(variables); - } - - /** - * Tests expression resolving without any expression - */ - @Test - public void testEvaluateExpressionNoExpression() { - - assertThat(target.evaluateExpressions("asdf asdf")).isEqualTo("asdf asdf"); - } - - /** - * Tests expression resolving with ?cap_first expression - */ - @Test - public void testEvaluateExpressionCapFirst() { - - assertThat(target.evaluateExpressions("asdf${variables.v1?cap_first} asdf")) - .isEqualTo("asdfPraefix Value Suffix asdf"); - } - - /** - * Tests expression resolving with ?uncap_first expression - */ - @Test - public void testEvaluateExpressionUncapFirst() { - - assertThat(target.evaluateExpressions("asdf${variables.v2?uncap_first} asdf")) - .isEqualTo("asdfpraefix Value Suffix asdf"); - } - - /** - * Tests expression resolving with ?lower_case expression - */ - @Test - public void testEvaluateExpressionLowerCase() { - - assertThat(target.evaluateExpressions("asdf${variables.v1?lower_case} asdf")) - .isEqualTo("asdfpraefix value suffix asdf"); - } - - /** - * Tests expression resolving with ?upper_case expression - */ - @Test - public void testEvaluateExpressionUpperCase() { - - assertThat(target.evaluateExpressions("asdf${variables.v1?upper_case} asdf")) - .isEqualTo("asdfPRAEFIX VALUE SUFFIX asdf"); - } - - /** - * Tests expression resolving with ?upper_case expression - */ - @Test - public void testEvaluateExpressionReplace() { - - assertThat(target.evaluateExpressions("asdf${variables.v1?replace('Value', 'Replacement')} asdf")) - .isEqualTo("asdfpraefix Replacement Suffix asdf"); - } - - /** - * Tests expression resolving with ?upper_case expression - */ - @Test - public void testEvaluateExpressionReplaceAll() { - - assertThat(target.evaluateExpressions("asdf${variables.v1?replace('x', 'XXX')} asdf")) - .isEqualTo("asdfpraefiXXX Value SuffiXXX asdf"); - } - - /** - * Tests expression resolving with ?upper_case expression - */ - @Test - public void testEvaluateExpressionRemoveSuffix() { - - assertThat(target.evaluateExpressions("asdf${variables.v1?removeSuffix('Suffix')} asdf")) - .isEqualTo("asdfpraefix Value asdf"); - } - - /** - * Tests expression resolving with ?upper_case expression - */ - @Test - public void testEvaluateExpressionRemovePraefix() { - - assertThat(target.evaluateExpressions("asdf${variables.v1?removePrefix('praefix')} asdf")) - .isEqualTo("asdf Value Suffix asdf"); - } - - /** - * Tests expression resolving with ?upper_case expression - */ - @Test - public void testEvaluateExpressionConcatenation() { - - assertThat(target.evaluateExpressions("asdf${variables.v1?lower_case?removePrefix('praefix')} asdf")) - .isEqualTo("asdf value suffix asdf"); - } + /** + * Test target + */ + private static PathExpressionResolver target; + + static { + Variables variables = new Variables(); + variables.put("v1", "praefix Value Suffix"); + variables.put("v2", "Praefix Value Suffix"); + variables.put("variablename", "PrefixValueSuffix"); + variables.put("variablekey", "prefix_value_suffix"); + variables.put("PackageName", "my.pkg.name"); + target = new PathExpressionResolver(variables); + } + + /** + * Tests expression resolving without any expression + */ + @Test + public void testEvaluateExpressionNoExpression() { + + assertThat(target.evaluateExpressions("asdf asdf")).isEqualTo("asdf asdf"); + } + + /** + * Tests expression resolving with ?cap_first expression + */ + @Test + public void testEvaluateExpressionCapFirst() { + + assertThat(target.evaluateExpressions("asdf${variables.v1?cap_first} asdf")) + .isEqualTo("asdfPraefix Value Suffix asdf"); + } + + /** + * Tests expression resolving with ?uncap_first expression + */ + @Test + public void testEvaluateExpressionUncapFirst() { + + assertThat(target.evaluateExpressions("asdf${variables.v2?uncap_first} asdf")) + .isEqualTo("asdfpraefix Value Suffix asdf"); + } + + /** + * Tests expression resolving with ?lower_case expression + */ + @Test + public void testEvaluateExpressionLowerCase() { + + assertThat(target.evaluateExpressions("asdf${variables.v1?lower_case} asdf")) + .isEqualTo("asdfpraefix value suffix asdf"); + } + + /** + * Tests expression resolving with ?upper_case expression + */ + @Test + public void testEvaluateExpressionUpperCase() { + + assertThat(target.evaluateExpressions("asdf${variables.v1?upper_case} asdf")) + .isEqualTo("asdfPRAEFIX VALUE SUFFIX asdf"); + } + + /** + * Tests expression resolving with ?upper_case expression + */ + @Test + public void testEvaluateExpressionReplace() { + + assertThat(target.evaluateExpressions("asdf${variables.v1?replace('Value', 'Replacement')} asdf")) + .isEqualTo("asdfpraefix Replacement Suffix asdf"); + } + + /** + * Tests expression resolving with ?upper_case expression + */ + @Test + public void testEvaluateExpressionReplaceAll() { + + assertThat(target.evaluateExpressions("asdf${variables.v1?replace('x', 'XXX')} asdf")) + .isEqualTo("asdfpraefiXXX Value SuffiXXX asdf"); + } + + /** + * Tests expression resolving with ?upper_case expression + */ + @Test + public void testEvaluateExpressionRemoveSuffix() { + + assertThat(target.evaluateExpressions("asdf${variables.v1?removeSuffix('Suffix')} asdf")) + .isEqualTo("asdfpraefix Value asdf"); + } + + /** + * Tests expression resolving with ?upper_case expression + */ + @Test + public void testEvaluateExpressionRemovePraefix() { + + assertThat(target.evaluateExpressions("asdf${variables.v1?removePrefix('praefix')} asdf")) + .isEqualTo("asdf Value Suffix asdf"); + } + + /** + * Tests expression resolving with ?upper_case expression + */ + @Test + public void testEvaluateExpressionConcatenation() { + + assertThat(target.evaluateExpressions("asdf${variables.v1?lower_case?removePrefix('praefix')} asdf")) + .isEqualTo("asdf value suffix asdf"); + } /** - * Test of {@link PathExpressionResolver#evaluateExpressions(String)} using the {@link CaseSyntax} with arbitrary - * cases. + * Test of {@link PathExpressionResolver#evaluateExpressions(String)} using the + * {@link io.github.mmm.base.text.CaseSyntax} with arbitrary cases. */ @Test public void testEvaluateExpressionCaseSyntax() { - assertThat(target.evaluateExpressions("foo-X__VariableName__X-bar-x__variableName__x-some")) + assertThat(target.evaluateExpressions("foo-X_VariableName_X-bar-x_variableName_x-some")) .isEqualTo("foo-PrefixValueSuffix-bar-prefixValueSuffix-some"); - assertThat(target.evaluateExpressions("fooX__VariableName__Xbar")).isEqualTo("fooPrefixValueSuffixbar"); + assertThat(target.evaluateExpressions("fooX_VariableName_Xbar")).isEqualTo("fooPrefixValueSuffixbar"); } } diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/$_rootpackage_$/$_component_$/dataaccess/api/$_EntityName_$Entity.java b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/x_rootpackage_x/x_component_x/dataaccess/api/X_EntityName_XEntity.java similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/$_rootpackage_$/$_component_$/dataaccess/api/$_EntityName_$Entity.java rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/x_rootpackage_x/x_component_x/dataaccess/api/X_EntityName_XEntity.java diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/$_rootpackage_$/$_component_$/dataaccess/api/cobigen.properties b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/x_rootpackage_x/x_component_x/dataaccess/api/cobigen.properties similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/$_rootpackage_$/$_component_$/dataaccess/api/cobigen.properties rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/x_rootpackage_x/x_component_x/dataaccess/api/cobigen.properties diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/$_rootpackage_$/$_component_$/logic/api/$_Component_$.java b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/x_rootpackage_x/x_component_x/logic/api/X_Component_X.java similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/$_rootpackage_$/$_component_$/logic/api/$_Component_$.java rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/x_rootpackage_x/x_component_x/logic/api/X_Component_X.java diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/$_rootpackage_$/$_component_$/logic/api/to/$_EntityName_$Eto.java b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/x_rootpackage_x/x_component_x/logic/api/to/X_EntityName_XEto.java similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/$_rootpackage_$/$_component_$/logic/api/to/$_EntityName_$Eto.java rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/x_rootpackage_x/x_component_x/logic/api/to/X_EntityName_XEto.java diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/$_rootpackage_$/$_component_$/logic/api/to/cobigen.properties b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/x_rootpackage_x/x_component_x/logic/api/to/cobigen.properties similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/$_rootpackage_$/$_component_$/logic/api/to/cobigen.properties rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate/templates/x_rootpackage_x/x_component_x/logic/api/to/cobigen.properties diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/$_rootpackage_$/cobigen.properties b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/x_rootpackage_x/cobigen.properties similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/$_rootpackage_$/cobigen.properties rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/x_rootpackage_x/cobigen.properties diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/$_rootpackage_$/$_component_$/logic/api/$_Component_$.java b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/x_rootpackage_x/x_component_x/logic/api/X_Component_X.java similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/$_rootpackage_$/$_component_$/logic/api/$_Component_$.java rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/x_rootpackage_x/x_component_x/logic/api/X_Component_X.java diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/$_rootpackage_$/$_component_$/logic/api/to/$_EntityName_$Eto.java b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/x_rootpackage_x/x_component_x/logic/api/to/X_EntityName_XEto.java similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/$_rootpackage_$/$_component_$/logic/api/to/$_EntityName_$Eto.java rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/x_rootpackage_x/x_component_x/logic/api/to/X_EntityName_XEto.java diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/$_rootpackage_$/$_component_$/logic/api/to/cobigen.properties b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/x_rootpackage_x/x_component_x/logic/api/to/cobigen.properties similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/$_rootpackage_$/$_component_$/logic/api/to/cobigen.properties rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_propertiesresolution/templates/x_rootpackage_x/x_component_x/logic/api/to/cobigen.properties diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates.xml b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates.xml index 780ff46714..9d3f3ab682 100644 --- a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates.xml +++ b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1"> - + diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates/$_rootpackage_$/$_component_$/common/api/$_EntityName_$.java b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates/x_rootpackage_x/x_component_x/common/api/X_EntityName_X.java similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates/$_rootpackage_$/$_component_$/common/api/$_EntityName_$.java rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates/x_rootpackage_x/x_component_x/common/api/X_EntityName_X.java diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates/$_rootpackage_$/$_component_$/common/api/$_EntityName_$2.java b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates/x_rootpackage_x/x_component_x/common/api/X_EntityName_X2.java similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates/$_rootpackage_$/$_component_$/common/api/$_EntityName_$2.java rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates/x_rootpackage_x/x_component_x/common/api/X_EntityName_X2.java diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates/$_rootpackage_$/$_component_$/common/api/cobigen.properties b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates/x_rootpackage_x/x_component_x/common/api/cobigen.properties similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates/$_rootpackage_$/$_component_$/common/api/cobigen.properties rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_templateExt_vs_scan/templates/x_rootpackage_x/x_component_x/common/api/cobigen.properties diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_template_fileending/templates/$_rootpackage_$/$_component_$/logic/impl/$_Component_$Impl.java.ftl b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_template_fileending/templates/x_rootpackage_x/x_component_x/logic/impl/X_Component_XImpl.java.ftl similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_template_fileending/templates/$_rootpackage_$/$_component_$/logic/impl/$_Component_$Impl.java.ftl rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_template_fileending/templates/x_rootpackage_x/x_component_x/logic/impl/X_Component_XImpl.java.ftl diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_template_fileending/templates/$_rootpackage_$/$_component_$/logic/impl/cobigen.properties b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_template_fileending/templates/x_rootpackage_x/x_component_x/logic/impl/cobigen.properties similarity index 100% rename from cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_template_fileending/templates/$_rootpackage_$/$_component_$/logic/impl/cobigen.properties rename to cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_template_fileending/templates/x_rootpackage_x/x_component_x/logic/impl/cobigen.properties diff --git a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_template_vs_scan/templates.xml b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_template_vs_scan/templates.xml index fcd8c654a5..fae74966e4 100644 --- a/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_template_vs_scan/templates.xml +++ b/cobigen/cobigen-core/src/test/resources/testdata/unittest/config/reader/TemplatesConfigurationReaderTest/valid_relocate_template_vs_scan/templates.xml @@ -4,7 +4,7 @@