This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository eugene. See https://gitlab.nuiton.org/nuiton/eugene.git commit 201ee1441faa207f644547cf50f3dd3147aaf54d Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Oct 8 14:56:43 2016 +0200 Remove old tag value and stereotypes api (See #4042) --- .../eugene/java/JavaTemplatesStereoTypes.java | 412 ------------ .../nuiton/eugene/java/JavaTemplatesTagValues.java | 735 --------------------- ....models.stereotype.StereotypeDefinitionProvider | 1 - ...gene.models.tagvalue.TagValueDefinitionProvider | 1 - .../eugene/java/JavaTemplatesStereoTypesTest.java | 81 --- .../eugene/java/JavaTemplatesTagValuesTest.java | 72 -- .../org/nuiton/eugene/EugeneCoreTagValues.java | 6 +- .../java/org/nuiton/eugene/EugeneStereoTypes.java | 128 ---- .../java/org/nuiton/eugene/EugeneTagValues.java | 227 ------- .../main/java/org/nuiton/eugene/GeneratorUtil.java | 4 +- .../main/java/org/nuiton/eugene/models/Model.java | 6 +- .../models/extension/tagvalue/TagValueUtil.java | 16 +- ...Values.java => WithTagValuesOrStereotypes.java} | 11 +- .../eugene/models/object/ObjectModelElement.java | 6 +- .../eugene/models/object/ObjectModelPackage.java | 6 +- .../models/object/xml/ObjectModelElementImpl.java | 1 + .../eugene/models/object/xml/ObjectModelImpl.java | 1 + .../models/object/xml/ObjectModelPackageImpl.java | 1 + .../eugene/models/state/xml/StateModelImpl.java | 1 + .../AggregateStereotypeDefinitionProvider.java | 78 --- .../InvalidStereotypeSyntaxException.java | 35 - .../MismatchStereotypeTargetException.java | 35 - .../stereotype/MissingStereoTypeException.java | 66 -- .../stereotype/MyStereotypeDefinitionProvider.java | 39 -- .../eugene/models/stereotype/StereotypeAble.java | 57 -- .../models/stereotype/StereotypeDefinition.java | 66 -- .../stereotype/StereotypeDefinitionProvider.java | 177 ----- ...ereotypeDefinitionProviderManagerExtension.java | 64 -- .../stereotype/StereotypeDefinitionProviders.java | 83 --- .../stereotype/StereotypeNotFoundException.java | 35 - .../eugene/models/stereotype/Stereotypes.java | 185 ------ .../eugene/models/stereotype/package-info.java | 32 - .../AggregateTagValueDefinitionProvider.java | 78 --- .../tagvalue/InvalidTagValueSyntaxException.java | 35 - .../tagvalue/MismatchTagValueTargetException.java | 35 - .../models/tagvalue/MissingTagValueException.java | 69 -- .../eugene/models/tagvalue/TagValueAble.java | 70 -- .../eugene/models/tagvalue/TagValueDefinition.java | 79 --- .../tagvalue/TagValueDefinitionProvider.java | 260 -------- ...TagValueDefinitionProviderManagerExtension.java | 64 -- .../tagvalue/TagValueDefinitionProviders.java | 83 --- .../models/tagvalue/TagValueNotFoundException.java | 35 - .../nuiton/eugene/models/tagvalue/TagValues.java | 351 ---------- .../matcher/EqualsTagValueNameMatcher.java | 46 -- .../tagvalue/matcher/StartsWithTagNameMatcher.java | 47 -- .../matcher/TagValueDefinitionMatcher.java | 61 -- .../eugene/models/tagvalue/package-info.java | 32 - ....models.stereotype.StereotypeDefinitionProvider | 1 - ...gene.models.tagvalue.TagValueDefinitionProvider | 1 - .../main/resources/i18n/eugene_en_GB.properties | 7 +- .../main/resources/i18n/eugene_fr_FR.properties | 7 +- .../org/nuiton/eugene/EugeneStereotypesTest.java | 71 -- .../org/nuiton/eugene/EugeneTagValuesTest.java | 86 --- .../eugene/models/tagvalue/TagValuesTest.java | 61 -- 54 files changed, 39 insertions(+), 4208 deletions(-) diff --git a/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesStereoTypes.java b/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesStereoTypes.java deleted file mode 100644 index 1e38930..0000000 --- a/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesStereoTypes.java +++ /dev/null @@ -1,412 +0,0 @@ -package org.nuiton.eugene.java; - -/* - * #%L - * EUGene :: Java templates - * %% - * Copyright (C) 2012 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.nuiton.eugene.models.object.ObjectModel; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelPackage; -import org.nuiton.eugene.models.stereotype.StereotypeDefinition; -import org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider; -import org.nuiton.eugene.models.stereotype.Stereotypes; - -/** - * Defines all stereotypes managed by Java templates. - * - * @author Tony Chemit - chemit@codelutin.com - * @plexus.component role="org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider" role-hint="eugene-java-templates" - * @since 2.5.6 - */ -public class JavaTemplatesStereoTypes extends StereotypeDefinitionProvider { - - /** - * Stereotype for JavaBean objects to place on a classifier. - * - * @see #hasBeanStereotype(ObjectModelClassifier, ObjectModelPackage) - * @see #hasBeanStereotype(ObjectModelPackage) - * @since 2.5.6 - */ - @StereotypeDefinition( - target = {ObjectModelClassifier.class, ObjectModelPackage.class}, - documentation = "To specify that a class is a JavaBean") - public static final String STEREOTYPE_BEAN = "bean"; - - /** - * Tag value to authorize user to generate some bean with methods, some generators won't generate them : Lots code). - * - * By default, user should never add methods in bean classes, simply write them in your java code!. - * - * You can globaly use it on the complete model, on packages, or to a specific classifier. - * - * @see #isAcceptBeanWithMethods(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @StereotypeDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To authorize to generate bean with method (in some generator such method won't be generated).") - public static final String STEREOTYPE_ACCEPT_BEAN_WITH_METHODS = "acceptBeanWithMethods"; - - /** - * Tag value to authorize user to override abstract classes. - * - * By default, user should never override abstract classes but works on implementation ones. - * - * You can globaly use it on the complete model, on packages, or to a specific classifier. - * - * @see #isOverrideAbstractClasses(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @StereotypeDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To authorize to override abstract classes.") - public static final String STEREOTYPE_OVERRIDE_ABSTRACT_CLASSES = "overrideAbstractClasses"; - - /** - * Tag value to generate property change support on generated beans. - * - * You can globaly use it on the complete model, on packages, or to a specific classifier. - * - * @see #isSkipGeneratePropertyChangeSupport(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.12 - */ - @StereotypeDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To generate property change support code.") - public static final String STEREOTYPE_SKIP_GENERATE_PROPERTY_CHANGE_SUPPORT = "generatePropertyChangeSupport"; - - /** - * Tag value to generate lazy instanciation of any collection to avoid NPEs. - * - * You can globaly use it on the complete model or a package, or to a specific classifier. - * - * @see #isSkipGenerateNotEmptyCollections(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.12 - */ - @StereotypeDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To lazy instanciate collections to avoid NPE codes.") - public static final String STEREOTYPE_SKIP_GENERATE_NOT_EMPTY_COLLECTIONS = "generateNotEmptyCollections"; - - /** - * To generate an interface of each simple bean. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #isSimpleBeanSkipGenerateInterface(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.6.2 - */ - @StereotypeDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To generate an interface for each bean " + - "for a class or any class of a model.\n" + - "(only effective with simple bean generator)") - public static final String STEREOTYPE_SIMPLE_BEAN_SKIP_GENERATE_INTERFACE = "simpleBeanGenerateInterface"; - - /** - * To generate a factory of generated simple beans. - * - * You must use it on the complete model. - * - * @see #isSimpleBeanSkipGenerateFactory(ObjectModel) - * @since 2.6.2 - */ - @StereotypeDefinition( - target = {ObjectModel.class}, - documentation = "To generate a factory of simple bean.\n" + - "(only effective with simple bean generator)") - public static final String STEREOTYPE_SIMPLE_BEAN_SKIP_GENERATE_FACTORY = "simpleBeanGenerateFactory"; - - /** - * To generate a factory of generated simple beans. - * - * You must use it on the complete model. - * - * @see #isSimpleBeanSkipGenerateDefaults(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.7.2 - */ - @StereotypeDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To generate defaults class with simple operations on the type.\n" + - "(only effective with simple bean generator)") - public static final String STEREOTYPE_SIMPLE_BEAN_SKIP_GENERATE_DEFAULTS = "simpleBeanGenerateDefaults"; - - /** - * To generate a factory of generated simple beans. - * - * You must use it on the complete model. - * - * @see #isSimpleBeanWithNoInterfaceSkipGenerateDefaults(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @StereotypeDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To skip generation of defaults class with simple operations on the type.\n" + - "(only effective with simple bean generator)") - public static final String STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_DEFAULTS = "simpleBeanWithNoInterfaceGenerateDefaults"; - - - /** - * To generate or not guava predicates on each property of the bean. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #isSimpleBeanWithNoInterfaceSkipGeneratePredicates(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @StereotypeDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To generate or not guava predicates on propertyes on beans.\n" + - "(only effective with simple bean with no interface generator)") - public static final String STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_PREDICATES = "simpleBeanWithNoInterfaceGeneratePredicates"; - - /** - * To generate or not guava functions on each property of the bean. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #isSimpleBeanWithNoInterfaceSkipGenerateFunctions(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @StereotypeDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To generate or not guava predicates on propertyes on beans.\n" + - "(only effective with simple bean with no interface generator)") - public static final String STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_FUNCTIONS = "simpleBeanWithNoInterfaceGenerateFunctions"; - - /** - * To generate or not constructors methods on Default classes. - * - * You can globaly use it on the complete model, package or on a specific classifier. - * - * @see #isSimpleBeanWithNoInterfaceSkipGenerateDefaultConstructors(ObjectModelClassifier, ObjectModelPackage, ObjectModel)} - * @since 3.0 - */ - @StereotypeDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To generate or not constructors predicates on propertyes on beans.\n" + - "(only effective with simple bean with no interface generator)") - public static final String STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_DEFAULT_CONSTRUCTORS= "simpleBeanWithNoInterfaceSkipGenerateConstructors"; - - /** - * Check if the given classifier has the {@link #STEREOTYPE_BEAN} stereotype. - * - * @param classifier classifier to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see #STEREOTYPE_BEAN - */ - public static boolean hasBeanStereotype(ObjectModelClassifier classifier, ObjectModelPackage aPackage) { - return Stereotypes.findDirectStereotype(STEREOTYPE_BEAN, classifier, aPackage); - } - - /** - * Check if the given aPackage has the {@link #STEREOTYPE_BEAN} stereotype. - * - * @param aPackage classifier to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see #STEREOTYPE_BEAN - */ - public static boolean hasBeanStereotype(ObjectModelPackage aPackage) { - return Stereotypes.findDirectStereotype(STEREOTYPE_BEAN, aPackage); - } - - /** - * Obtain the value of the {@link #STEREOTYPE_ACCEPT_BEAN_WITH_METHODS} tag value on the given model, package or classifier. - * - * It will first look on the model, then and package and then in the given classifier. - * - * If no value found, then will use the default value of the tag value. - * - * @param classifier classifier to seek - * @param aPackage package to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #STEREOTYPE_ACCEPT_BEAN_WITH_METHODS - * @since 3.0 - */ - public boolean isAcceptBeanWithMethods(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return Stereotypes.findDirectStereotype(STEREOTYPE_ACCEPT_BEAN_WITH_METHODS, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #STEREOTYPE_OVERRIDE_ABSTRACT_CLASSES} tag value on the given model, package or classifier. - * - * It will first look on the model, then and package and then in the given classifier. - * - * If no value found, then will use the default value of the tag value. - * - * @param classifier classifier to seek - * @param aPackage package to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #STEREOTYPE_OVERRIDE_ABSTRACT_CLASSES - * @since 3.0 - */ - public boolean isOverrideAbstractClasses(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return Stereotypes.findDirectStereotype(STEREOTYPE_OVERRIDE_ABSTRACT_CLASSES, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #STEREOTYPE_SKIP_GENERATE_PROPERTY_CHANGE_SUPPORT} tag value on the given model, package or classifier. - * - * It will first look on the model, then and package and then in the given classifier. - * - * If no value found, then will use the default value of the tag value. - * - * @param classifier classifier to seek - * @param aPackage package to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #STEREOTYPE_SKIP_GENERATE_PROPERTY_CHANGE_SUPPORT - * @since 2.12 - */ - public boolean isSkipGeneratePropertyChangeSupport(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return Stereotypes.findDirectStereotype(STEREOTYPE_SKIP_GENERATE_PROPERTY_CHANGE_SUPPORT, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #STEREOTYPE_SKIP_GENERATE_NOT_EMPTY_COLLECTIONS} tag value on the given model, package or classifier. - * - * It will first look on the model, then and package and then in the given classifier. - * - * If no value found, then will use the default value of the tag value. - * - * @param classifier classifier to seek - * @param aPackage package to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #STEREOTYPE_SKIP_GENERATE_NOT_EMPTY_COLLECTIONS - * @since 2.12 - */ - public boolean isSkipGenerateNotEmptyCollections(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return Stereotypes.findDirectStereotype(STEREOTYPE_SKIP_GENERATE_NOT_EMPTY_COLLECTIONS, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #STEREOTYPE_SIMPLE_BEAN_SKIP_GENERATE_INTERFACE} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #STEREOTYPE_SIMPLE_BEAN_SKIP_GENERATE_INTERFACE - * @since 2.3 - */ - public boolean isSimpleBeanSkipGenerateInterface(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return Stereotypes.findDirectStereotype(STEREOTYPE_SIMPLE_BEAN_SKIP_GENERATE_INTERFACE, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #STEREOTYPE_SIMPLE_BEAN_SKIP_GENERATE_FACTORY} tag value on the given model or classifier. - * - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #STEREOTYPE_SIMPLE_BEAN_SKIP_GENERATE_FACTORY - * @since 2.7.2 - */ - public boolean isSimpleBeanSkipGenerateFactory(ObjectModel model) { - return Stereotypes.findDirectStereotype(STEREOTYPE_SIMPLE_BEAN_SKIP_GENERATE_FACTORY, model); - } - - /** - * Obtain the value of the {@link #STEREOTYPE_SIMPLE_BEAN_SKIP_GENERATE_DEFAULTS} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #STEREOTYPE_SIMPLE_BEAN_SKIP_GENERATE_DEFAULTS - * @since 2.7.2 - */ - public boolean isSimpleBeanSkipGenerateDefaults(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return Stereotypes.findDirectStereotype(STEREOTYPE_SIMPLE_BEAN_SKIP_GENERATE_DEFAULTS, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_DEFAULTS} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_DEFAULTS - * @since 3.0 - */ - public boolean isSimpleBeanWithNoInterfaceSkipGenerateDefaults(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return Stereotypes.findDirectStereotype(STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_DEFAULTS, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_PREDICATES} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * <strong>If not filled, then use default {@code s} value.</strong> - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_PREDICATES - * @since 3.0 - */ - public boolean isSimpleBeanWithNoInterfaceSkipGeneratePredicates(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return Stereotypes.findDirectStereotype(STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_PREDICATES, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_FUNCTIONS} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * <strong>If not filled, then use default {@code s} value.</strong> - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_FUNCTIONS - * @since 3.0 - */ - public boolean isSimpleBeanWithNoInterfaceSkipGenerateFunctions(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return Stereotypes.findDirectStereotype(STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_FUNCTIONS, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_DEFAULT_CONSTRUCTORS} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * <strong>If not filled, then use default {@code s} value.</strong> - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_DEFAULT_CONSTRUCTORS - * @since 3.0 - */ - public boolean isSimpleBeanWithNoInterfaceSkipGenerateDefaultConstructors(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return Stereotypes.findDirectStereotype(STEREOTYPE_SIMPLE_BEAN_WITH_NO_INTERFACE_SKIP_GENERATE_DEFAULT_CONSTRUCTORS, classifier, aPackage, model); - } - - -} diff --git a/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesTagValues.java b/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesTagValues.java deleted file mode 100644 index c18a197..0000000 --- a/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesTagValues.java +++ /dev/null @@ -1,735 +0,0 @@ -package org.nuiton.eugene.java; - -/* - * #%L - * EUGene :: Java templates - * %% - * Copyright (C) 2012 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.apache.commons.lang3.StringUtils; -import org.nuiton.eugene.models.object.ObjectModel; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelPackage; -import org.nuiton.eugene.models.tagvalue.TagValueDefinition; -import org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider; - -/** - * Defines all tag values managed by Java templates. - * - * @author Tony Chemit - chemit@codelutin.com - * @plexus.component role="org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider" role-hint="eugene-java-templates" - * @since 2.5.6 - */ -public class JavaTemplatesTagValues extends TagValueDefinitionProvider { - -// /** -// * Tag value to generate property change support on generated beans. -// * -// * You can globaly use it on the complete model, on packages, or to a specific classifier. -// * -// * @see #isSkipGeneratePropertyChangeSupport(ObjectModelClassifier, ObjectModelPackage, ObjectModel) -// * @since 2.12 -// */ -// @TagValueDefinition( -// target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, -// defaultValue = "true", -// documentation = "To generate property change support code.") -// public static final String TAG_GENERATE_PROPERTY_CHANGE_SUPPORT = "generatePropertyChangeSupport"; -// -// /** -// * Tag value to generate lazy instanciation of any collection to avoid NPEs. -// * -// * You can globaly use it on the complete model or a package, or to a specific classifier. -// * -// * @see #isSkipGenerateNotEmptyCollections(ObjectModelClassifier, ObjectModelPackage, ObjectModel) -// * @since 2.12 -// */ -// @TagValueDefinition( -// target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, -// defaultValue = "true", -// documentation = "To lazy instanciate collections to avoid NPE codes.") -// public static final String TAG_GENERATE_NOT_EMPTY_COLLECTIONS = "generateNotEmptyCollections"; - - /** - * Tag value to use a super class for generated bean. - * - * If the bean needs Property change support (says you use the {@link JavaTemplatesStereoTypes#STEREOTYPE_SKIP_GENERATE_PROPERTY_CHANGE_SUPPORT}), - * then your class must provide everything for it. - * - * More over, if you use some collections in your bean you must also define - * two method named {@code getChild(Collection list, int index)} and - * {@code getChild(List list, int index)} - * - * See new code to know minimum stuff to add in your class for this purpose. - * <pre> - * public abstract class AbstractBean implements Serializable { - * - * private static final long serialVersionUID = 1L; - * - * protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); - * - * public void addPropertyChangeListener(PropertyChangeListener listener) { - * pcs.addPropertyChangeListener(listener); - * } - * - * public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - * pcs.addPropertyChangeListener(propertyName, listener); - * } - * - * public void removePropertyChangeListener(PropertyChangeListener listener) { - * pcs.removePropertyChangeListener(listener); - * } - * - * public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - * pcs.removePropertyChangeListener(propertyName, listener); - * } - * - * protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - * pcs.firePropertyChange(propertyName, oldValue, newValue); - * } - * - * protected void firePropertyChange(String propertyName, Object newValue) { - * firePropertyChange(propertyName, null, newValue); - * } - * - * protected <T> T getChild(Collection<T> list, int index) { - * return CollectionUtil.getOrNull(list, index); - * } - * - * protected <T> T getChild(List<T> list, int index) { - * return CollectionUtil.getOrNull(list, index); - * } - * } - * </pre> - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getBeanSuperClassTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.5.6 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To specify a super-class to used on generated bean " + - "for a class or any class of a model.\n" + - "(only effective with bean generator)") - public static final String TAG_BEAN_SUPER_CLASS = "beanSuperClass"; - - /** - * Tag value to use a super class for generated bean. - * - * If the bean needs Property change support (says you use the tag-value {@link JavaTemplatesStereoTypes#STEREOTYPE_SKIP_GENERATE_PROPERTY_CHANGE_SUPPORT}, - * then your class must provide evrything for it. - * - * More over, if you use some collections in your bean you must also define - * two method named {@code getChild(Collection list, int index)} and - * {@code getChild(List list, int index)} - * - * See new code to know minimum stuff to add in your class for this purpose. - * <pre> - * public abstract class AbstractBean implements Serializable { - * - * private static final long serialVersionUID = 1L; - * - * protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); - * - * public void addPropertyChangeListener(PropertyChangeListener listener) { - * pcs.addPropertyChangeListener(listener); - * } - * - * public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - * pcs.addPropertyChangeListener(propertyName, listener); - * } - * - * public void removePropertyChangeListener(PropertyChangeListener listener) { - * pcs.removePropertyChangeListener(listener); - * } - * - * public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - * pcs.removePropertyChangeListener(propertyName, listener); - * } - * - * protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - * pcs.firePropertyChange(propertyName, oldValue, newValue); - * } - * - * protected void firePropertyChange(String propertyName, Object newValue) { - * firePropertyChange(propertyName, null, newValue); - * } - * - * protected <T> T getChild(Collection<T> list, int index) { - * return CollectionUtil.getOrNull(list, index); - * } - * - * protected <T> T getChild(List<T> list, int index) { - * return CollectionUtil.getOrNull(list, index); - * } - * } - * </pre> - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanSuperClassTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.5.6 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To specify a super-class to used on generated simple bean " + - "for a class or any class of a model.\n" + - "(only effective with simple bean generator)") - public static final String TAG_SIMPLE_BEAN_SUPER_CLASS = "simpleBeanSuperClass"; - - /** - * To add a prefix on the name of each generated bean class. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanClassNamePrefixTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.6.2 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To add a prefix on class name of generated bean " + - "for a class or any class of a model.\n" + - "(only effective with simple bean generator)") - public static final String TAG_SIMPLE_BEAN_CLASS_NAME_PREFIX = "simpleBeanClassNamePrefix"; - - /** - * To add a prefix on the name of each generated bean class. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanClassNameSuffixTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.6.2 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - defaultValue = "Bean", - documentation = "To add a suffix on class name of generated bean " + - "for a class or any class of a model.\n" + - "(only effective with simple bean generator)") - public static final String TAG_SIMPLE_BEAN_CLASS_NAME_SUFFIX = "simpleBeanClassNameSuffix"; - - /** - * Tag value to use a super interface for generated interfaces on simple bean. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanInterfaceSuperClassTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.6.2 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To specify a super-class to used on generated interfaces " + - "for a class or any class of a model.\n" + - "(only effective with simple bean generator)") - public static final String TAG_SIMPLE_BEAN_INTERFACE_SUPER_CLASS = "simpleBeanInterfaceSuperClass"; - - /** - * To add a prefix on the name of each generated interface of a simple bean. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanInterfaceNamePrefixTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.6.2 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To add a prefix on interface name of generated bean " + - "for a class or any class of a model.\n" + - "(only effective with simple bean generator)") - public static final String TAG_SIMPLE_BEAN_INTERFACE_NAME_PREFIX = "simpleBeanInterfaceNamePrefix"; - - /** - * To add a prefix on the name of each generated interface of a simple bean. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanInterfaceNameSuffixTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.6.2 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To add a suffix on interface name of generated bean " + - "for a class or any class of a model.\n" + - "(only effective with simple bean generator)") - public static final String TAG_SIMPLE_BEAN_INTERFACE_NAME_SUFFIX = "simpleBeanInterfaceNameSuffix"; - - /** - * Tag value to use a super super-class for generated defaults class of a - * simple bean. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanDefaultsSuperClassTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.7.2 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To specify a super-class to used on generated defaults classes" + - "for a bean or any bean of a model.\n" + - "(only effective with simple bean generator)") - public static final String TAG_SIMPLE_BEAN_DEFAULTS_SUPER_CLASS = "simpleBeanDefaultsSuperClass"; - - /** - * To add a prefix on the name of each generated bean class. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanDefaultsClassNamePrefixTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.7.2 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To add a prefix on class name of generated defaults bean " + - "for a class or any class of a model.\n" + - "(only effective with simple bean generator)") - public static final String TAG_SIMPLE_BEAN_DEFAULTS_CLASS_NAME_PREFIX = "simpleBeanDefaultsClassNamePrefix"; - - /** - * To add a suffix on the name of each generated bean class. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanDefaultsClassNameSuffixTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.6.2 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To add a suffix on class name of generated defaults bean " + - "for a class or any class of a model.\n" + - "(only effective with simple bean generator)") - public static final String TAG_SIMPLE_BEAN_DEFAULTS_CLASS_NAME_SUFFIX = "simpleBeanDefaultsClassNameSuffix"; - - /** - * Tag value to use a super class for generated bean. - * - * If the bean needs Property change support (says you use the tag-value {@link JavaTemplatesStereoTypes#STEREOTYPE_SKIP_GENERATE_PROPERTY_CHANGE_SUPPORT}, - * then your class must provide evrything for it. - * - * More over, if you use some collections in your bean you must also define - * two method named {@code getChild(Collection list, int index)} and - * {@code getChild(List list, int index)} - * - * See new code to know minimum stuff to add in your class for this purpose. - * <pre> - * public abstract class AbstractBean implements Serializable { - * - * private static final long serialVersionUID = 1L; - * - * protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); - * - * public void addPropertyChangeListener(PropertyChangeListener listener) { - * pcs.addPropertyChangeListener(listener); - * } - * - * public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - * pcs.addPropertyChangeListener(propertyName, listener); - * } - * - * public void removePropertyChangeListener(PropertyChangeListener listener) { - * pcs.removePropertyChangeListener(listener); - * } - * - * public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - * pcs.removePropertyChangeListener(propertyName, listener); - * } - * - * protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - * pcs.firePropertyChange(propertyName, oldValue, newValue); - * } - * - * protected void firePropertyChange(String propertyName, Object newValue) { - * firePropertyChange(propertyName, null, newValue); - * } - * - * protected <T> T getChild(Collection<T> list, int index) { - * return CollectionUtil.getOrNull(list, index); - * } - * - * protected <T> T getChild(List<T> list, int index) { - * return CollectionUtil.getOrNull(list, index); - * } - * } - * </pre> - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanWithNoInterfaceSuperClassTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To specify a super-class to used on generated simple bean " + - "for a class or any class of a model.\n" + - "(only effective with simple bean generator)") - public static final String TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_SUPER_CLASS = "simpleBeanWithNoInterfaceSuperClass"; - - /** - * Tag value to use a super super-class for generated defaults class of a simple bean. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanWithNoInterfaceDefaultsSuperClassTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To specify a super-class to used on generated defaults classes" + - "for a bean or any bean of a model.\n" + - "(only effective with simple bean generator)") - public static final String TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_DEFAULTS_SUPER_CLASS = "simpleBeanWithNoInterfaceDefaultsSuperClass"; - - /** - * To add a prefix on the name of each generated bean class. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanClassNamePrefixTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To add a prefix on class name of generated bean " + - "for a class or any class of a model.\n" + - "(only effective with simple bean with no interface generator)") - public static final String TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_CLASS_NAME_PREFIX = "simpleBeanWithNoInterfaceClassNamePrefix"; - - /** - * To add a prefix on the name of each generated bean class. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanClassNameSuffixTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To add a suffix on class name of generated bean " + - "for a class or any class of a model.\n" + - "(only effective with simple bean with no interface generator)") - public static final String TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_CLASS_NAME_SUFFIX = "simpleBeanWithNoInterfaceClassNameSuffix"; - - /** - * To add a prefix on the name of each generated bean class. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanWithNoInterfaceDefaultsClassNamePrefixTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To add a prefix on class name of generated defaults bean " + - "for a class or any class of a model.\n" + - "(only effective with simple bean generator)") - public static final String TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_DEFAULTS_CLASS_NAME_PREFIX = "simpleBeanWithNoInterfaceDefaultsClassNamePrefix"; - - /** - * To add a suffix on the name of each generated bean class. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getSimpleBeanWithNoInterfaceDefaultsClassNameSuffixTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 3.0 - */ - @TagValueDefinition( - target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "To add a suffix on class name of generated defaults bean " + - "for a class or any class of a model.\n" + - "(only effective with simple bean generator)") - public static final String TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_DEFAULTS_CLASS_NAME_SUFFIX = "simpleBeanWithNoInterfaceDefaultsClassNameSuffix"; - - /** - * Obtain the value of the {@link #TAG_BEAN_SUPER_CLASS} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_BEAN_SUPER_CLASS - * @since 2.3 - */ - public String getBeanSuperClassTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_BEAN_SUPER_CLASS, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_SUPER_CLASS} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_SUPER_CLASS - * @since 2.6.2 - */ - public String getSimpleBeanSuperClassTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_SIMPLE_BEAN_SUPER_CLASS, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_INTERFACE_SUPER_CLASS} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_INTERFACE_SUPER_CLASS - * @since 2.6.2 - */ - public String getSimpleBeanInterfaceSuperClassTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_SIMPLE_BEAN_INTERFACE_SUPER_CLASS, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_CLASS_NAME_PREFIX} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_CLASS_NAME_PREFIX - * @since 2.6.2 - */ - public String getSimpleBeanClassNamePrefixTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_SIMPLE_BEAN_CLASS_NAME_PREFIX, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_CLASS_NAME_SUFFIX} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_CLASS_NAME_SUFFIX - * @since 2.6.2 - */ - public String getSimpleBeanClassNameSuffixTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_SIMPLE_BEAN_CLASS_NAME_SUFFIX, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_INTERFACE_NAME_PREFIX} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_INTERFACE_NAME_PREFIX - * @since 2.6.2 - */ - public String getSimpleBeanInterfaceNamePrefixTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_SIMPLE_BEAN_INTERFACE_NAME_PREFIX, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_INTERFACE_NAME_SUFFIX} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_INTERFACE_NAME_SUFFIX - * @since 2.6.2 - */ - public String getSimpleBeanInterfaceNameSuffixTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_SIMPLE_BEAN_INTERFACE_NAME_SUFFIX, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_DEFAULTS_SUPER_CLASS} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_DEFAULTS_SUPER_CLASS - * @since 2.7.2 - */ - public String getSimpleBeanDefaultsSuperClassTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_SIMPLE_BEAN_DEFAULTS_SUPER_CLASS, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_DEFAULTS_CLASS_NAME_PREFIX} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_DEFAULTS_CLASS_NAME_PREFIX - * @since 2.7.2 - */ - public String getSimpleBeanDefaultsClassNamePrefixTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_SIMPLE_BEAN_DEFAULTS_CLASS_NAME_PREFIX, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_DEFAULTS_CLASS_NAME_SUFFIX} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * <strong>If not filled, then use default {@code s} value.</strong> - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_DEFAULTS_CLASS_NAME_SUFFIX - * @since 2.6.2 - */ - public String getSimpleBeanDefaultsClassNameSuffixTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - String value = findTagValue(TAG_SIMPLE_BEAN_DEFAULTS_CLASS_NAME_SUFFIX, classifier, aPackage, model); - if (StringUtils.isBlank(value)) { - value = "s"; - } - return value; - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_SUPER_CLASS} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_SUPER_CLASS - * @since 3.0 - */ - public String getSimpleBeanWithNoInterfaceSuperClassTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_SUPER_CLASS, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_DEFAULTS_SUPER_CLASS} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_DEFAULTS_SUPER_CLASS - * @since 3.0 - */ - public String getSimpleBeanWithNoInterfaceDefaultsSuperClassTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_DEFAULTS_SUPER_CLASS, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_CLASS_NAME_PREFIX} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_CLASS_NAME_PREFIX - * @since 3.0 - */ - public String getSimpleBeanWithNoInterfaceClassNamePrefixTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_CLASS_NAME_PREFIX, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_CLASS_NAME_SUFFIX} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_CLASS_NAME_SUFFIX - * @since 3.0 - */ - public String getSimpleBeanWithNoInterfaceClassNameSuffixTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_CLASS_NAME_SUFFIX, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_DEFAULTS_CLASS_NAME_PREFIX} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_DEFAULTS_CLASS_NAME_PREFIX - * @since 3.0 - */ - public String getSimpleBeanWithNoInterfaceDefaultsClassNamePrefixTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - return findTagValue(TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_DEFAULTS_CLASS_NAME_PREFIX, classifier, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_DEFAULTS_CLASS_NAME_SUFFIX} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * <strong>If not filled, then use default {@code s} value.</strong> - * - * @param classifier classifier to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_DEFAULTS_CLASS_NAME_SUFFIX - * @since 3.0 - */ - public String getSimpleBeanWithNoInterfaceDefaultsClassNameSuffixTagValue(ObjectModelClassifier classifier, ObjectModelPackage aPackage, ObjectModel model) { - String value = findTagValue(TAG_SIMPLE_BEAN_WITH_NO_INTERFACE_DEFAULTS_CLASS_NAME_SUFFIX, classifier, aPackage, model); - if (StringUtils.isBlank(value)) { - value = "s"; - } - return value; - } - - /** - * To use java 8 new syntax and api in generation. - * - * You can globaly use it on the complete model. - * - * @see #isUseJava8(ObjectModel) - * @since 2.15 - */ - @TagValueDefinition( - target = {ObjectModel.class}, - documentation = "To use java 8 new syntax and API.\n") - public static final String TAG_JAVA8 = "java8"; - - /** - * Obtain the value of the {@link #TAG_JAVA8} tag value on the given model. - * - * @param model model to seek - * @return {@code true} the none empty value of the found tag value or {@code false} if not found nor empty. - * @see #TAG_JAVA8 - * @since 2.15 - */ - public boolean isUseJava8(ObjectModel model) { - return findBooleanTagValue(TAG_JAVA8, model); - } - -} diff --git a/eugene-java-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider b/eugene-java-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider deleted file mode 100644 index 37ac157..0000000 --- a/eugene-java-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider +++ /dev/null @@ -1 +0,0 @@ -org.nuiton.eugene.java.JavaTemplatesStereoTypes \ No newline at end of file diff --git a/eugene-java-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider b/eugene-java-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider deleted file mode 100644 index b6b2acf..0000000 --- a/eugene-java-templates/src/main/resources/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider +++ /dev/null @@ -1 +0,0 @@ -org.nuiton.eugene.java.JavaTemplatesTagValues \ No newline at end of file diff --git a/eugene-java-templates/src/test/java/org/nuiton/eugene/java/JavaTemplatesStereoTypesTest.java b/eugene-java-templates/src/test/java/org/nuiton/eugene/java/JavaTemplatesStereoTypesTest.java deleted file mode 100644 index 8e3b2ed..0000000 --- a/eugene-java-templates/src/test/java/org/nuiton/eugene/java/JavaTemplatesStereoTypesTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.nuiton.eugene.java; - -/* - * #%L - * EUGene :: Java templates - * %% - * Copyright (C) 2012 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.nuiton.eugene.models.object.ObjectModel; -import org.nuiton.eugene.models.object.ObjectModelAttribute; -import org.nuiton.eugene.models.object.ObjectModelClass; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelEnumeration; -import org.nuiton.eugene.models.object.ObjectModelInterface; -import org.nuiton.eugene.models.object.ObjectModelOperation; -import org.nuiton.eugene.models.object.ObjectModelPackage; -import org.nuiton.eugene.models.stereotype.MismatchStereotypeTargetException; -import org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider; -import org.nuiton.eugene.models.stereotype.StereotypeNotFoundException; - -public class JavaTemplatesStereoTypesTest { - - protected StereotypeDefinitionProvider provider; - - @Before - public void setUp() throws Exception { - provider = new JavaTemplatesStereoTypes(); - provider.init(); - } - - @Test - public void validate() throws Exception { - - validate(JavaTemplatesStereoTypes.STEREOTYPE_BEAN, true, ObjectModelPackage.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class, ObjectModelInterface.class); - validate(JavaTemplatesStereoTypes.STEREOTYPE_SKIP_GENERATE_NOT_EMPTY_COLLECTIONS, true, ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class); - validate(JavaTemplatesStereoTypes.STEREOTYPE_SKIP_GENERATE_PROPERTY_CHANGE_SUPPORT, true, ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class); - validate(JavaTemplatesStereoTypes.STEREOTYPE_SKIP_GENERATE_NOT_EMPTY_COLLECTIONS, false, ObjectModelOperation.class, ObjectModelAttribute.class); - validate(JavaTemplatesStereoTypes.STEREOTYPE_SKIP_GENERATE_PROPERTY_CHANGE_SUPPORT, false, ObjectModelOperation.class, ObjectModelAttribute.class); - - validate(JavaTemplatesStereoTypes.STEREOTYPE_BEAN, false, ObjectModel.class, ObjectModelOperation.class); - - long l = System.nanoTime(); - validate(JavaTemplatesStereoTypes.STEREOTYPE_BEAN + l, false, ObjectModelPackage.class, ObjectModel.class, ObjectModelOperation.class); - validate(JavaTemplatesStereoTypes.STEREOTYPE_SKIP_GENERATE_NOT_EMPTY_COLLECTIONS + l, false, ObjectModelPackage.class, ObjectModelOperation.class, ObjectModelAttribute.class); - validate(JavaTemplatesStereoTypes.STEREOTYPE_SKIP_GENERATE_PROPERTY_CHANGE_SUPPORT + l, false, ObjectModelPackage.class, ObjectModelOperation.class, ObjectModelAttribute.class); - - } - - protected void validate(String name, boolean expected, Class<?>... types) { - for (Class<?> type : types) { - try { - provider.validate(name, type); - Assert.assertTrue(expected); - } catch (StereotypeNotFoundException e) { - Assert.assertFalse(expected); - } catch (MismatchStereotypeTargetException e) { - Assert.assertFalse(expected); - } - } - } - -} diff --git a/eugene-java-templates/src/test/java/org/nuiton/eugene/java/JavaTemplatesTagValuesTest.java b/eugene-java-templates/src/test/java/org/nuiton/eugene/java/JavaTemplatesTagValuesTest.java deleted file mode 100644 index d8595f6..0000000 --- a/eugene-java-templates/src/test/java/org/nuiton/eugene/java/JavaTemplatesTagValuesTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.nuiton.eugene.java; - -/* - * #%L - * EUGene :: Java templates - * %% - * Copyright (C) 2012 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.nuiton.eugene.models.object.ObjectModel; -import org.nuiton.eugene.models.object.ObjectModelAttribute; -import org.nuiton.eugene.models.object.ObjectModelClass; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelEnumeration; -import org.nuiton.eugene.models.object.ObjectModelOperation; -import org.nuiton.eugene.models.object.ObjectModelPackage; -import org.nuiton.eugene.models.tagvalue.MismatchTagValueTargetException; -import org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider; -import org.nuiton.eugene.models.tagvalue.TagValueNotFoundException; - -public class JavaTemplatesTagValuesTest { - - protected TagValueDefinitionProvider provider; - - @Before - public void setUp() throws Exception { - provider = new JavaTemplatesTagValues(); - provider.init(); - } - - @Test - public void validate() throws Exception { - validate(JavaTemplatesTagValues.TAG_BEAN_SUPER_CLASS, true, ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class); - validate(JavaTemplatesTagValues.TAG_BEAN_SUPER_CLASS, false, ObjectModelOperation.class, ObjectModelAttribute.class); - - long l = System.nanoTime(); - validate(JavaTemplatesTagValues.TAG_BEAN_SUPER_CLASS + l, false, ObjectModelPackage.class, ObjectModelOperation.class, ObjectModelAttribute.class); - } - - - protected void validate(String name, boolean expected, Class<?>... types) { - for (Class<?> type : types) { - try { - provider.validate(name, type); - Assert.assertTrue(expected); - } catch (TagValueNotFoundException e) { - Assert.assertFalse(expected); - } catch (MismatchTagValueTargetException e) { - Assert.assertFalse(expected); - } - } - } - -} diff --git a/eugene/src/main/java/org/nuiton/eugene/EugeneCoreTagValues.java b/eugene/src/main/java/org/nuiton/eugene/EugeneCoreTagValues.java index c146772..f91e40e 100644 --- a/eugene/src/main/java/org/nuiton/eugene/EugeneCoreTagValues.java +++ b/eugene/src/main/java/org/nuiton/eugene/EugeneCoreTagValues.java @@ -123,18 +123,18 @@ public class EugeneCoreTagValues extends DefaultTagValueMetadatasProvider { * * @since 2.8 */ - ordered(n("eugene.core.stereotypes.ordered"), boolean.class, null,ObjectModelAttribute.class), + ordered(n("eugene.core.tagValues.ordered"), boolean.class, null, ObjectModelAttribute.class), /** * Stereotype to mark an attribute with multiplicity as unique. * * It means that uniqueness of elements is maintained in the collection: in Java, it * will lead to a collection typed with {@link java.util.Set}. */ - unique(n("eugene.core.stereotypes.unique"), boolean.class, null,ObjectModelAttribute.class), + unique(n("eugene.core.tagValues.unique"), boolean.class, null, ObjectModelAttribute.class), /** * Stereotype to skip generation for some templates. */ - skip(n("eugene.core.stereotypes.skip"), boolean.class, null,ObjectModelClassifier.class, ObjectModelPackage.class); + skip(n("eugene.core.tagValues.skip"), boolean.class, null, ObjectModelClassifier.class, ObjectModelPackage.class); private final Set<Class<?>> targets; diff --git a/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java b/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java deleted file mode 100644 index 401d25e..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2010 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.eugene; - -import org.nuiton.eugene.models.object.ObjectModelAttribute; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelPackage; -import org.nuiton.eugene.models.stereotype.StereotypeDefinition; -import org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider; -import org.nuiton.eugene.models.stereotype.Stereotypes; - -/** - * Defines all stereotypes managed by Eugene. - * - * In another library using eugene, please extends this contract to put your - * own stereotypes, to get a unique place where to find stereotypes. - * - * @author Tony Chemit - chemit@codelutin.com - * @plexus.component role="org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider" role-hint="eugene" - * @since 2.9 - */ -@Deprecated -public class EugeneStereoTypes extends StereotypeDefinitionProvider { - - /** - * Stereotype to mark an attribute with multiplicity as ordered. - * - * It means that order of insertion is maintained: in Java, it will lead - * to a collection typed with {@link java.util.List} or {@link java.util.LinkedHashSet} - * or {@link java.util.LinkedHashMap}. - * - * @see #hasOrderedStereotype(ObjectModelAttribute) - * @since 2.8 - */ - @StereotypeDefinition(target = ObjectModelAttribute.class, - documentation = "To specify that a attribute is ordered") - public static final String STEREOTYPE_ORDERED = "ordered"; - - /** - * Stereotype to mark an attribute with multiplicity as unique. - * - * It means that uniqueness of elements is maintained in the collection: in Java, it - * will lead to a collection typed with {@link java.util.Set}. - * - * @see #hasUniqueStereotype(ObjectModelAttribute) - */ - @StereotypeDefinition(target = ObjectModelAttribute.class, - documentation = "To specify that an attribute is unique") - public static final String STEREOTYPE_UNIQUE = "unique"; - - /** - * Stereotype to skip generation for some transformer. - * - * @see #hasSkipStereotype(ObjectModelClassifier, ObjectModelPackage) - * @see #hasSkipStereotype(ObjectModelPackage) - */ - @StereotypeDefinition(target = {ObjectModelClassifier.class, ObjectModelPackage.class}, - documentation = "To specify that a classifier should not been generated.") - public static final String STEREOTYPE_SKIP = "skip"; - - /** - * Check if the given attribute has the {@link #STEREOTYPE_ORDERED} stereotype. - * - * @param attribute attribute to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see #STEREOTYPE_ORDERED - * @since 2.9 - */ - public static boolean hasOrderedStereotype(ObjectModelAttribute attribute) { - return attribute.hasStereotype(EugeneStereoTypes.STEREOTYPE_ORDERED); - } - - /** - * Check if the given attribute has the {@link #STEREOTYPE_UNIQUE} stereotype. - * - * @param attribute attribute to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see #STEREOTYPE_UNIQUE - * @since 2.9 - */ - public static boolean hasUniqueStereotype(ObjectModelAttribute attribute) { - return attribute.hasStereotype(EugeneStereoTypes.STEREOTYPE_UNIQUE); - } - - /** - * Check if the given classifier has the {@link #STEREOTYPE_SKIP} stereotype. - * - * @param classifier classifier to test - * @param aPackage package to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see #STEREOTYPE_SKIP - * @since 2.9 - */ - public static boolean hasSkipStereotype(ObjectModelClassifier classifier, ObjectModelPackage aPackage) { - return Stereotypes.findDirectStereotype(STEREOTYPE_SKIP, classifier, aPackage); - } - - /** - * Check if the given aPackage has the {@link #STEREOTYPE_SKIP} stereotype. - * - * @param aPackage package to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see #STEREOTYPE_SKIP - */ - public static boolean hasSkipStereotype(ObjectModelPackage aPackage) { - return Stereotypes.findDirectStereotype(STEREOTYPE_SKIP, aPackage); - } - -} diff --git a/eugene/src/main/java/org/nuiton/eugene/EugeneTagValues.java b/eugene/src/main/java/org/nuiton/eugene/EugeneTagValues.java deleted file mode 100644 index beec633..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/EugeneTagValues.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2010 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.eugene; - -import org.nuiton.eugene.models.object.ObjectModel; -import org.nuiton.eugene.models.object.ObjectModelAttribute; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelElement; -import org.nuiton.eugene.models.object.ObjectModelPackage; -import org.nuiton.eugene.models.tagvalue.TagValueDefinition; -import org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider; - -/** - * Defines all tag values managed by Eugene. - * - * In another library using eugene, please extends this contract to put your - * own tag values, to get a unique place where to find tag values. - * - * @author Tony Chemit - chemit@codelutin.com - * @plexus.component role="org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider" role-hint="eugene" - * @since 2.3 - */ -@Deprecated -public class EugeneTagValues extends TagValueDefinitionProvider { - - /** - * Tag value to add the version of the model from outside (says in the - * properties file associated to the model).. - * - * Actually, the eugene api does not use to modify the model. ItaTa is only - * used while reading the properties associated with a model and if found is - * directly set to the {@code version} field of the model. - * - * @since 2.3 - */ - @TagValueDefinition(target = {ObjectModel.class}, - documentation = "To set the version of the model.") - public static final String TAG_VERSION = "version"; - - /** - * Tag value to add on constants enumeration (or other incoming dev) - * a prefix to constant to generate. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getDocumentationTagValue(ObjectModel) - * @see #getDocumentationTagValue(ObjectModelPackage) - * @see #getDocumentationTagValue(ObjectModelElement) - * @since 2.5 - */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelElement.class}, - documentation = "Sets the documentation of a model or any of his elements") - public static final String TAG_DOCUMENTATION = "documentation"; - - /** - * Tag value to add on constants enumeration (or other incoming dev) - * a prefix to constant to generate. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getConstantPrefixTagValue(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.3 - */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - defaultValue = "PROPERTY_", - documentation = "Sets the prefix of any constant to be generated for the given class") - public static final String TAG_CONSTANT_PREFIX = "constantPrefix"; - - /** - * Tag value to specify the i18n prefix to use whene generating i18n keys. - * - * You can globaly use it on the complete model or to a specific classifier. - * - * @see #getI18nPrefixTagValue(ObjectModelElement, ObjectModelPackage, ObjectModel) - * @since 2.3 - */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - documentation = "Sets the i18n prefix to use on I18n keys generated") - public static final String TAG_I18N_PREFIX = "i18n"; - - /** - * Tag value to generate also {@code getXXX} methods for a boolean property. - * - * @see #isGenerateBooleanGetMethods(ObjectModelClassifier, ObjectModelPackage, ObjectModel) - * @since 2.12 - */ - @TagValueDefinition(target = {ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class}, - defaultValue = "false", - documentation = "To specify to generate getXXX methods for boolean properties") - public static final String TAG_GENERATE_BOOLEAN_GET_METHODS = "generateBooleanGetMethods"; - - /** - * To add a generic to an attribute. - * - * @see #getAttributeGenericTagValue(ObjectModelAttribute) - * @since 3.0 - */ - @TagValueDefinition(target = {ObjectModelAttribute.class}, - documentation = "To add a generic to an attribute.") - public static final String TAG_ATTRIBUTE_GENERIC = "attributeGeneric"; - - /** - * Obtain the value of the {@link #TAG_DOCUMENTATION} tag value on the given model. - * - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_DOCUMENTATION - * @since 2.3 - */ - public String getDocumentationTagValue(ObjectModel model) { - String value = findTagValue(TAG_DOCUMENTATION, model); - return value; - } - - /** - * Obtain the value of the {@link #TAG_DOCUMENTATION} tag value on the given element. - * - * @param element element to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_DOCUMENTATION - * @since 2.3 - */ - public String getDocumentationTagValue(ObjectModelElement element) { - String value = findTagValue(TAG_DOCUMENTATION, element); - return value; - } - - /** - * Obtain the value of the {@link #TAG_DOCUMENTATION} tag value on the given package. - * - * @param aPackage package to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_DOCUMENTATION - * @since 2.12 - */ - public String getDocumentationTagValue(ObjectModelPackage aPackage) { - String value = findTagValue(TAG_DOCUMENTATION, aPackage); - return value; - } - - /** - * Cherche et renvoie le prefixe i18n à utiliser sur cet element, sinon sur - * le model. - * - * @param element l'élément à tester - * @param aPackage package to seek - * @param model le modele utilisé - * @return le prefix i18n ou <code>null</code> si non spécifié - * @since 2.3 - */ - public String getI18nPrefixTagValue(ObjectModelElement element, - ObjectModelPackage aPackage, - ObjectModel model) { - return findTagValue(TAG_I18N_PREFIX, element, aPackage, model); - } - - /** - * Obtain the value of the {@link #TAG_GENERATE_BOOLEAN_GET_METHODS} - * tag value on the given model, package or classifier. - * - * It will first look on the model, then on package and then in the given classifier. - * - * @param classifier classifier to seek - * @param aPackage package to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_GENERATE_BOOLEAN_GET_METHODS - * @since 2.12 - */ - public boolean isGenerateBooleanGetMethods(ObjectModelClassifier classifier, - ObjectModelPackage aPackage, - ObjectModel model) { - boolean value = findBooleanTagValue(TAG_GENERATE_BOOLEAN_GET_METHODS, classifier, aPackage, model); - return value; - } - - /** - * Obtain the value of the {@link #TAG_CONSTANT_PREFIX} tag value on the given model or classifier. - * - * It will first look on the model, and then in the given classifier. - * - * @param classifier classifier to seek - * @param aPackage package to seek - * @param model model to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_CONSTANT_PREFIX - * @since 2.3 - */ - public String getConstantPrefixTagValue(ObjectModelClassifier classifier, - ObjectModelPackage aPackage, - ObjectModel model) { - String value = findTagValue(TAG_CONSTANT_PREFIX, classifier, aPackage, model); - return value; - } - - /** - * Obtain the value of the {@link #TAG_ATTRIBUTE_GENERIC} tag value on the given attribute. - * - * @param attribute attribute to seek - * @return the none empty value of the found tag value or {@code null} if not found nor empty. - * @see #TAG_ATTRIBUTE_GENERIC - * @since 3.0 - */ - public String getAttributeGenericTagValue(ObjectModelAttribute attribute) { - String value = findTagValue(TAG_ATTRIBUTE_GENERIC, attribute); - return value; - } -} diff --git a/eugene/src/main/java/org/nuiton/eugene/GeneratorUtil.java b/eugene/src/main/java/org/nuiton/eugene/GeneratorUtil.java index 0ed4416..3a253d1 100644 --- a/eugene/src/main/java/org/nuiton/eugene/GeneratorUtil.java +++ b/eugene/src/main/java/org/nuiton/eugene/GeneratorUtil.java @@ -27,7 +27,7 @@ import org.apache.commons.lang3.StringUtils; import org.nuiton.eugene.models.Model; import org.nuiton.eugene.models.extension.tagvalue.TagValueMetadata; import org.nuiton.eugene.models.extension.tagvalue.TagValueUtil; -import org.nuiton.eugene.models.extension.tagvalue.WithTagValues; +import org.nuiton.eugene.models.extension.tagvalue.WithTagValuesOrStereotypes; import org.nuiton.eugene.models.object.ObjectModel; import org.nuiton.eugene.models.object.ObjectModelAttribute; import org.nuiton.eugene.models.object.ObjectModelClass; @@ -505,7 +505,7 @@ public class GeneratorUtil { * @param element l'élément à tester * @param model le modele utilisé * @return la valeur du tagValue ou null - * @deprecated since 2.9 (will be remove in version 3.0), prefer use now {@link TagValueUtil#findTagValue(TagValueMetadata, WithTagValues...)} + * @deprecated since 2.9 (will be remove in version 3.0), prefer use now {@link TagValueUtil#findTagValue(TagValueMetadata, WithTagValuesOrStereotypes...)} */ @Deprecated public static String findTagValue(String tagName, diff --git a/eugene/src/main/java/org/nuiton/eugene/models/Model.java b/eugene/src/main/java/org/nuiton/eugene/models/Model.java index 74180c7..0eea04f 100644 --- a/eugene/src/main/java/org/nuiton/eugene/models/Model.java +++ b/eugene/src/main/java/org/nuiton/eugene/models/Model.java @@ -23,14 +23,12 @@ package org.nuiton.eugene.models; -import org.nuiton.eugene.models.extension.tagvalue.WithTagValues; -import org.nuiton.eugene.models.stereotype.StereotypeAble; -import org.nuiton.eugene.models.tagvalue.TagValueAble; +import org.nuiton.eugene.models.extension.tagvalue.WithTagValuesOrStereotypes; /** * Model. */ -public interface Model extends TagValueAble, StereotypeAble, WithTagValues { +public interface Model extends WithTagValuesOrStereotypes { /** * Plexus role name diff --git a/eugene/src/main/java/org/nuiton/eugene/models/extension/tagvalue/TagValueUtil.java b/eugene/src/main/java/org/nuiton/eugene/models/extension/tagvalue/TagValueUtil.java index c27a0b6..ae45c99 100644 --- a/eugene/src/main/java/org/nuiton/eugene/models/extension/tagvalue/TagValueUtil.java +++ b/eugene/src/main/java/org/nuiton/eugene/models/extension/tagvalue/TagValueUtil.java @@ -114,14 +114,14 @@ public class TagValueUtil { * @return found tag value or {@code null} if not found * @since 3.0 */ - public static String findTagValue(TagValueMetadata tagName, WithTagValues... elements) { + public static String findTagValue(TagValueMetadata tagName, WithTagValuesOrStereotypes... elements) { String result = findDirectTagValue(tagName, elements); if (result != null) { return result; } - for (WithTagValues element : elements) { + for (WithTagValuesOrStereotypes element : elements) { if (element instanceof ObjectModelElement) { // try in declaring element ObjectModelElement declaringElement = ((ObjectModelElement) element).getDeclaringElement(); @@ -136,7 +136,7 @@ public class TagValueUtil { return tagName.getDefaultValue(); } - public static boolean findBooleanTagValue(TagValueMetadata tagName, WithTagValues... elements) { + public static boolean findBooleanTagValue(TagValueMetadata tagName, WithTagValuesOrStereotypes... elements) { String value = findTagValue(tagName, elements); return value != null && "true".equalsIgnoreCase(value); } @@ -144,7 +144,7 @@ public class TagValueUtil { /** * Seek for a Boolean tag value. * - * Will first the tag value using the method {@link #findTagValue(TagValueMetadata, WithTagValues...)}. + * Will first the tag value using the method {@link #findTagValue(TagValueMetadata, WithTagValuesOrStereotypes...)}. * * If not found, return {@code null}, otherwise return boolean value (case is ignored). * @@ -157,7 +157,7 @@ public class TagValueUtil { * @return found boolean tag value or {@code null} if tag value not found. * @since 3.0 */ - public static Boolean findNullableBooleanTagValue(TagValueMetadata tagName, WithTagValues... elements) { + public static Boolean findNullableBooleanTagValue(TagValueMetadata tagName, WithTagValuesOrStereotypes... elements) { String value = findTagValue(tagName, elements); return value == null ? null : "true".equalsIgnoreCase(value); } @@ -177,9 +177,9 @@ public class TagValueUtil { * @return found tag value or {@code null} if not found * @since 3.0 */ - public static String findDirectTagValue(TagValueMetadata tagName, WithTagValues... elements) { + public static String findDirectTagValue(TagValueMetadata tagName, WithTagValuesOrStereotypes... elements) { - for (WithTagValues element : elements) { + for (WithTagValuesOrStereotypes element : elements) { String value = findNotEmptyTagValue(tagName, element); if (value != null) { return value; @@ -189,7 +189,7 @@ public class TagValueUtil { return tagName.getDefaultValue(); } - public static String findNotEmptyTagValue(TagValueMetadata tagName, WithTagValues element) { + public static String findNotEmptyTagValue(TagValueMetadata tagName, WithTagValuesOrStereotypes element) { String value = null; if (element != null) { diff --git a/eugene/src/main/java/org/nuiton/eugene/models/extension/tagvalue/WithTagValues.java b/eugene/src/main/java/org/nuiton/eugene/models/extension/tagvalue/WithTagValuesOrStereotypes.java similarity index 90% rename from eugene/src/main/java/org/nuiton/eugene/models/extension/tagvalue/WithTagValues.java rename to eugene/src/main/java/org/nuiton/eugene/models/extension/tagvalue/WithTagValuesOrStereotypes.java index 9e37507..d599825 100644 --- a/eugene/src/main/java/org/nuiton/eugene/models/extension/tagvalue/WithTagValues.java +++ b/eugene/src/main/java/org/nuiton/eugene/models/extension/tagvalue/WithTagValuesOrStereotypes.java @@ -23,6 +23,7 @@ package org.nuiton.eugene.models.extension.tagvalue; */ import java.util.Map; +import java.util.Set; /** * Created on 4/26/14. @@ -30,7 +31,15 @@ import java.util.Map; * @author Tony Chemit - chemit@codelutin.com * @since 2.9 */ -public interface WithTagValues { +public interface WithTagValuesOrStereotypes { + + boolean hasStereotype(String stereotypeName); + + Set<String> getStereotypes(); + + void addStereotype(String stereotypeName); + + void removeStereotype(String stereotypeName); /** * Returns the tagValues associated with this element. diff --git a/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelElement.java b/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelElement.java index 56d900d..0a36b8c 100644 --- a/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelElement.java +++ b/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelElement.java @@ -22,9 +22,7 @@ package org.nuiton.eugene.models.object; -import org.nuiton.eugene.models.extension.tagvalue.WithTagValues; -import org.nuiton.eugene.models.stereotype.StereotypeAble; -import org.nuiton.eugene.models.tagvalue.TagValueAble; +import org.nuiton.eugene.models.extension.tagvalue.WithTagValuesOrStereotypes; import java.util.List; @@ -33,7 +31,7 @@ import java.util.List; * * @author Cédric Pineau - pineau@codelutin.com */ -public interface ObjectModelElement extends TagValueAble, StereotypeAble, WithTagValues { +public interface ObjectModelElement extends WithTagValuesOrStereotypes { /** * Returns the name of this element. diff --git a/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelPackage.java b/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelPackage.java index 2a15149..6f98782 100644 --- a/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelPackage.java +++ b/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelPackage.java @@ -22,9 +22,7 @@ package org.nuiton.eugene.models.object; * #L% */ -import org.nuiton.eugene.models.extension.tagvalue.WithTagValues; -import org.nuiton.eugene.models.stereotype.StereotypeAble; -import org.nuiton.eugene.models.tagvalue.TagValueAble; +import org.nuiton.eugene.models.extension.tagvalue.WithTagValuesOrStereotypes; import java.util.List; @@ -34,7 +32,7 @@ import java.util.List; * @author Tony Chemit - chemit@codelutin.com * @since 2.12 */ -public interface ObjectModelPackage extends TagValueAble, StereotypeAble, WithTagValues { +public interface ObjectModelPackage extends WithTagValuesOrStereotypes { /** * @return the name of this package. diff --git a/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelElementImpl.java b/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelElementImpl.java index 33b9df1..68faee8 100644 --- a/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelElementImpl.java +++ b/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelElementImpl.java @@ -214,6 +214,7 @@ public abstract class ObjectModelElementImpl implements ObjectModelElement { tagValues.put(stereotype, "true"); } + @Override public void removeStereotype(String stereotype) { tagValues.remove(stereotype); } diff --git a/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java b/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java index a55c312..80e0590 100644 --- a/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java +++ b/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java @@ -400,6 +400,7 @@ public class ObjectModelImpl implements ObjectModel { tagValues.put(stereotype, "true"); } + @Override public void removeStereotype(String stereotype) { tagValues.remove(stereotype); } diff --git a/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelPackageImpl.java b/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelPackageImpl.java index 556f553..16dfe5f 100644 --- a/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelPackageImpl.java +++ b/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelPackageImpl.java @@ -110,6 +110,7 @@ public class ObjectModelPackageImpl implements ObjectModelPackage { stereotypes.add(stereotype); } + @Override public void removeStereotype(String stereotype) { stereotypes.remove(stereotype); } diff --git a/eugene/src/main/java/org/nuiton/eugene/models/state/xml/StateModelImpl.java b/eugene/src/main/java/org/nuiton/eugene/models/state/xml/StateModelImpl.java index e8c3533..800484e 100644 --- a/eugene/src/main/java/org/nuiton/eugene/models/state/xml/StateModelImpl.java +++ b/eugene/src/main/java/org/nuiton/eugene/models/state/xml/StateModelImpl.java @@ -107,6 +107,7 @@ public class StateModelImpl implements StateModel { modelTagValues.put(stereotype, "true"); } + @Override public void removeStereotype(String stereotype) { modelTagValues.remove(stereotype); } diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/AggregateStereotypeDefinitionProvider.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/AggregateStereotypeDefinitionProvider.java deleted file mode 100644 index 44463c0..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/AggregateStereotypeDefinitionProvider.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.nuiton.eugene.models.stereotype; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.Iterator; -import java.util.ServiceLoader; - -/** - * Created on 4/27/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class AggregateStereotypeDefinitionProvider extends StereotypeDefinitionProvider implements Iterable<StereotypeDefinitionProvider> { - - /** Logger. */ - private static final Log log = LogFactory.getLog(AggregateStereotypeDefinitionProvider.class); - - protected ClassLoader loader; - - private Iterable<StereotypeDefinitionProvider> stereotypeDefinitionFactories; - - public AggregateStereotypeDefinitionProvider(ClassLoader loader) { - this.loader = loader; - } - - public AggregateStereotypeDefinitionProvider(Iterable<StereotypeDefinitionProvider> stereotypeDefinitionFactories) { - this.stereotypeDefinitionFactories = stereotypeDefinitionFactories; - } - - @Override - public Iterator<StereotypeDefinitionProvider> iterator() { - return stereotypeDefinitionFactories.iterator(); - } - - @Override - public void initDefinition() { - - if (stereotypeDefinitionFactories == null) { - - stereotypeDefinitionFactories = ServiceLoader.load(StereotypeDefinitionProvider.class, loader); - } - - for (StereotypeDefinitionProvider tagValueDefinitionFactory : stereotypeDefinitionFactories) { - if (isVerbose()) { - log.info("Will init tag value definition factory " + tagValueDefinitionFactory); - } - tagValueDefinitionFactory.setVerbose(isVerbose()); - tagValueDefinitionFactory.init(); - addAllDefinition(tagValueDefinitionFactory); - addAllDeprecated(tagValueDefinitionFactory); - } - } -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/InvalidStereotypeSyntaxException.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/InvalidStereotypeSyntaxException.java deleted file mode 100644 index a4dfde5..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/InvalidStereotypeSyntaxException.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.nuiton.eugene.models.stereotype; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -/** - * Created on 5/1/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class InvalidStereotypeSyntaxException extends Exception { - - private static final long serialVersionUID = 1L; -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/MismatchStereotypeTargetException.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/MismatchStereotypeTargetException.java deleted file mode 100644 index 25226a4..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/MismatchStereotypeTargetException.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.nuiton.eugene.models.stereotype; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -/** - * Created on 4/27/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class MismatchStereotypeTargetException extends Exception { - - private static final long serialVersionUID = 1L; -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/MissingStereoTypeException.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/MissingStereoTypeException.java deleted file mode 100644 index 8c54a44..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/MissingStereoTypeException.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.nuiton.eugene.models.stereotype; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2015 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import com.google.common.base.Joiner; -import org.nuiton.eugene.models.object.ObjectModelClass; -import org.nuiton.eugene.models.object.ObjectModelPackage; - -import java.util.Set; - -/** - * When a missing tag value is detected. - * - * Created on 15/08/15. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 3.0 - */ -@Deprecated -public class MissingStereoTypeException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - protected final String stereoTypeName; - - protected final String prefixMessage; - - protected final Set<String> stack; - - public MissingStereoTypeException(String stereoTypeName, String prefixMessage, ObjectModelPackage aPackage, ObjectModelClass aClass) { - this.stereoTypeName = stereoTypeName; - this.prefixMessage = prefixMessage; - this.stack = Stereotypes.getUsageStack(stereoTypeName, aPackage, aClass); - } - - @Override - public String toString() { - - return "\n\n" + prefixMessage - + "\n==========================================================================================" - + "\n" + Joiner.on("\n").join(stack) - + "\n=========================================================================================="; - - } - -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/MyStereotypeDefinitionProvider.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/MyStereotypeDefinitionProvider.java deleted file mode 100644 index b713d5f..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/MyStereotypeDefinitionProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.nuiton.eugene.models.stereotype; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.nuiton.eugene.models.object.ObjectModelAttribute; - -/** - * Created on 4/27/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since XXX - */ -@Deprecated -public class MyStereotypeDefinitionProvider extends StereotypeDefinitionProvider { - - @StereotypeDefinition(target = ObjectModelAttribute.class, - documentation = "doc of your stereotype") - public static final String MY_STEREOTYPE = "mystereotype"; -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeAble.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeAble.java deleted file mode 100644 index 741879c..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeAble.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.nuiton.eugene.models.stereotype; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import java.util.Set; - -/** - * Created on 4/26/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public interface StereotypeAble { - - /** - * Returns the stereotypes names associated with this element. - * - * @return a Collection containing all stereotypes names associated with this element as String. - */ - Set<String> getStereotypes(); - - /** - * Returns whether this element has a stereotype corresponding to the given name, or not. - * - * @param stereotypeName stereotype name - * @return a boolean indicating whether this element has a stereotype corresponding to the given name, or not. - */ - boolean hasStereotype(String stereotypeName); - - /** - * Add a stereotype. - * - * @param stereotype stereotype to add - */ - void addStereotype(String stereotype); -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeDefinition.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeDefinition.java deleted file mode 100644 index b5ddafb..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeDefinition.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.nuiton.eugene.models.stereotype; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.nuiton.eugene.EugeneTagValues; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * To define a stereotype. - * - * Place this annotation on the constant defining your stereotype. - * - * Example for stereotype named mystereotype which can be only put on a attribute : - * <pre> - * String STEREOTYPE_MYSTEREOTYPE = "mystereotype"; - * \@StereotypeDefinition(target = ObjectModelAttribute.class) - * </pre> - * - * @author Tony Chemit - chemit@codelutin.com - * @see EugeneTagValues - * @since 2.3 - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -@Deprecated -public @interface StereotypeDefinition { - - /** - * Define the types of object model api which can use this tag value. - * - * @return the array of target object model element which can accept the tag value. - */ - Class<?>[] target(); - - /** - * Obtain the english documentation of the stereotype. - * - * @return the documentation of the stereotype. - * @since 2.3.1 - */ - String documentation(); -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeDefinitionProvider.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeDefinitionProvider.java deleted file mode 100644 index 97a3681..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeDefinitionProvider.java +++ /dev/null @@ -1,177 +0,0 @@ -package org.nuiton.eugene.models.stereotype; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import com.google.common.collect.ImmutableMap; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.eugene.EugeneStereoTypes; - -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map; -import java.util.ServiceLoader; -import java.util.Set; -import java.util.TreeMap; - -/** - * To describe stereotype definitions you can use on your model. Using a such class permits to validate - * the stereotypes before generation. - * - * Created on 4/27/14. - * <h3>Howto</h3> - * Overrides this class adding constants with {@link StereotypeDefinition} annotations: - * <pre> - * package org.nuiton.mymodel; - * - * public class MyStereotypeDefinitionProvider extends StereotypeDefinitionProvider { - * - * \@StereotypeDefinition(target = ObjectModelAttribute.class, - * documentation = "doc of your stereotype") - * public static final String MY_STEREOTYPE = "mystereotype"; - * } - * </pre> - * Register you provider via the {@link ServiceLoader} mecanism, create the file in your class-path - * {@code META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider}, and - * add a line - * <pre>org.nuiton.mymodel.MyStereotypeDefinitionProvider</pre> - * - * @author Tony Chemit - chemit@codelutin.com - * @see EugeneStereoTypes - * @since 2.9 - */ -@Deprecated -public class StereotypeDefinitionProvider { - - /** Logger. */ - private static final Log log = LogFactory.getLog(StereotypeDefinitionProvider.class); - - protected Map<String, StereotypeDefinition> definition; - - protected Set<String> deprecated; - - protected boolean verbose; - - protected StereotypeDefinitionProvider() { - definition = new TreeMap<>(); - deprecated = new HashSet<>(); - } - - public boolean isVerbose() { - return verbose; - } - - public void setVerbose(boolean verbose) { - this.verbose = verbose; - } - - public void init() { - initDefinition(); - } - - public void validate(String stereotypeName, Class<?> type) throws StereotypeNotFoundException, MismatchStereotypeTargetException { - - StereotypeDefinition def = getDefinition(stereotypeName); - - if (def == null) { - throw new StereotypeNotFoundException(); - } - - boolean valid = false; - - for (Class<?> target : def.target()) { - if (target.equals(type) || target.isAssignableFrom(type)) { - - // found one accepting target - valid = true; - break; - } - } - if (!valid) { - throw new MismatchStereotypeTargetException(); - } - } - - public boolean isDeprecated(String stereotypeName) { - boolean result = deprecated.contains(stereotypeName); - return result; - } - - public Map<String, StereotypeDefinition> getDefinition() { - return ImmutableMap.copyOf(definition); - } - - protected void initDefinition() { - try { - scanClass(getClass()); - } catch (IllegalAccessException e) { - throw new RuntimeException("Could not init stereotype provider", e); - } - } - - protected StereotypeDefinition getDefinition(String stereotypeName) { - StereotypeDefinition result = definition.get(stereotypeName); - return result; - } - - protected void scanClass(Class<?> holder) throws IllegalAccessException { - if (isVerbose()) { - log.info("Will scan " + holder.getName() + " to search some stereotype definitions..."); - } - Field[] fields = holder.getDeclaredFields(); - for (Field field : fields) { - - StereotypeDefinition stereotypeDefinition = - field.getAnnotation(StereotypeDefinition.class); - - if (stereotypeDefinition != null) { - String fieldName = field.getName(); - String stereotypeName = (String) field.get(null); - if (isVerbose()) { - log.info("Detected stereotype definition [" + fieldName + ":" + stereotypeName + "] : " + Arrays.toString(stereotypeDefinition.target())); - } - addDefinition(stereotypeName, stereotypeDefinition); - if (field.isAnnotationPresent(Deprecated.class)) { - addDeprecated(stereotypeName); - } - } - } - } - - protected void addDefinition(String name, StereotypeDefinition def) { - definition.put(name, def); - } - - protected void addAllDefinition(StereotypeDefinitionProvider tagValueDefinitionFactory) { - definition.putAll(tagValueDefinitionFactory.definition); - } - - protected void addDeprecated(String name) { - deprecated.add(name); - } - - protected void addAllDeprecated(StereotypeDefinitionProvider tagValueDefinitionFactory) { - deprecated.addAll(tagValueDefinitionFactory.deprecated); - } -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeDefinitionProviderManagerExtension.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeDefinitionProviderManagerExtension.java deleted file mode 100644 index f700af1..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeDefinitionProviderManagerExtension.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.nuiton.eugene.models.stereotype; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import com.google.common.base.Preconditions; - -/** - * Created on 6/18/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.11 - */ -@Deprecated -public class StereotypeDefinitionProviderManagerExtension { - - /** - * Extension static used to identify this extension in ObjectModel. - */ - public static final String OBJECTMODEL_EXTENSION = "stereotypeDefinitionProviders"; - - protected AggregateStereotypeDefinitionProvider aggregateStereotypeDefinitionProvider; - - public void setAggregateStereotypeDefinitionProvider(AggregateStereotypeDefinitionProvider aggregateStereotypeDefinitionProvider) { - this.aggregateStereotypeDefinitionProvider = aggregateStereotypeDefinitionProvider; - } - - public <T extends StereotypeDefinitionProvider> T getStereotypeDefinitionProvider(Class<T> providerType) { - - Preconditions.checkState(aggregateStereotypeDefinitionProvider != null, "No aggregateStereotypeDefinitionProvider assigned"); - - StereotypeDefinitionProvider result = null; - for (StereotypeDefinitionProvider stereotypeDefinitionProvider : aggregateStereotypeDefinitionProvider) { - if (providerType.equals(stereotypeDefinitionProvider.getClass())) { - result = stereotypeDefinitionProvider; - break; - } - } - - Preconditions.checkState(result != null, "No stereotypeDefinitionProvider of this type: " + providerType.getName()); - return (T) result; - - } - -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeDefinitionProviders.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeDefinitionProviders.java deleted file mode 100644 index 4ae281b..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeDefinitionProviders.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.nuiton.eugene.models.stereotype; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Created on 4/27/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class StereotypeDefinitionProviders { - - /** Logger. */ - private static final Log log = LogFactory.getLog(StereotypeDefinitionProviders.class); - - /** - * Obtain a new provider of stereotype definitions. - * - * @param loader the classloader to use (if none given will use the one of the current thread) - * @param verbose verbose flag - * @return the aggregate provider of stereotype definitions detected in the class-path - */ - public static AggregateStereotypeDefinitionProvider newProvider(ClassLoader loader, boolean verbose) { - - if (loader == null) { - - // use the current thread loader - loader = Thread.currentThread().getContextClassLoader(); - } - - AggregateStereotypeDefinitionProvider store = new AggregateStereotypeDefinitionProvider(loader); - store.setVerbose(verbose || log.isDebugEnabled()); - try { - store.init(); - } catch (Exception e) { - throw new RuntimeException("Could not init stereotype definition provider", e); - } - return store; - } - - /** - * Obtain a new provider of stereotype definitions. - * - * @param providers the list of providers to use in the factory - * @param verbose verbose flag - * @return the aggregate provider of stereotype definitions detected in the class-path - */ - public static AggregateStereotypeDefinitionProvider newProvider(Iterable<StereotypeDefinitionProvider> providers, boolean verbose) { - - AggregateStereotypeDefinitionProvider store = new AggregateStereotypeDefinitionProvider(providers); - store.setVerbose(verbose || log.isDebugEnabled()); - try { - store.init(); - } catch (Exception e) { - throw new RuntimeException("Could not init stereotype definition provider", e); - } - return store; - } -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeNotFoundException.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeNotFoundException.java deleted file mode 100644 index d06b588..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/StereotypeNotFoundException.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.nuiton.eugene.models.stereotype; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -/** - * Created on 4/27/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class StereotypeNotFoundException extends Exception { - - private static final long serialVersionUID = 1L; -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/Stereotypes.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/Stereotypes.java deleted file mode 100644 index 60c0f6b..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/Stereotypes.java +++ /dev/null @@ -1,185 +0,0 @@ -package org.nuiton.eugene.models.stereotype; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import com.google.common.collect.ImmutableSet; -import org.nuiton.eugene.models.object.ObjectModelClass; -import org.nuiton.eugene.models.object.ObjectModelElement; -import org.nuiton.eugene.models.object.ObjectModelPackage; - -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Created on 5/1/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class Stereotypes { - - protected static final Pattern PACKAGE_STEREOTYPE_PATTERN = Pattern - .compile("^package\\.((?:[_a-zA-Z0-9]+\\.)+)?(?:(stereotype)?)$"); - - protected static final Pattern STEREOTYPE_PATTERN = Pattern - .compile("^((?:[_a-zA-Z0-9]+\\.)+(?:_?[a-zA-Z][_a-zA-Z0-9]*\\.)+)(?:(class|attribute|operation))\\.(?:([_a-zA-Z0-9]+)\\.)?(?:(stereotype)?)$"); - - - public static Matcher getMatcher(String key) throws InvalidStereotypeSyntaxException { - Matcher matcher = STEREOTYPE_PATTERN.matcher(key); - if (!matcher.find()) { - throw new InvalidStereotypeSyntaxException(); - } - return matcher; - } - - public static Matcher getPackageMatcher(String key) throws InvalidStereotypeSyntaxException { - Matcher matcher = PACKAGE_STEREOTYPE_PATTERN.matcher(key); - if (!matcher.find()) { - throw new InvalidStereotypeSyntaxException(); - } - return matcher; - } - - public static Set<String> getStereotypes(String value) { - String[] split = value.split("\\s*,\\s*"); - return ImmutableSet.<String>builder().add(split).build(); - } - - /** - * Seek for a stereotype amoung elements given using these rules: - * <ul> - * <li>Look into {@code elements} and return the first element with this stereotype found.</li> - * <li>If not found, Look into {@code elements} declaringElement (for each - * element that is a {@link ObjectModelElement} and return the first not empty tag - * element with this stereotype found.</li> - * </ul> - * <strong>Note:</strong> Order of {@code elements} is important, better then to - * always starts from specialized to more general level (for example from attribute, - * to classifier or model). - * - * @param stereotypeName tag name to find - * @param elements not null elements to test - * @return {@code true} if found stereotype, {@code false} otherwise - * @since 2.12 - */ - public static boolean findStereotype(String stereotypeName, StereotypeAble... elements) { - - boolean result = findDirectStereotype(stereotypeName, elements); - - if (result) { - return result; - } - - for (StereotypeAble element : elements) { - if (element instanceof ObjectModelElement) { - // try in declaring element - ObjectModelElement declaringElement = ((ObjectModelElement) element).getDeclaringElement(); - if (declaringElement != null) { - boolean value = findStereotype(stereotypeName, declaringElement); - if (value) { - return value; - } - } - } - } - return false; - - } - - /** - * Seek for a stereotype amoung elements given using these rules: - * <ul> - * <li>Look into {@code elements} and return the first element with this stereotype found.</li> - * </ul> - * <strong>Note:</strong> Order of {@code elements} is important, better then to - * always starts from specialized to more general level (for example from attribute, - * to classifier or model). - * - * @param stereotypeName stereotype to find - * @param elements not null elements to test - * @return {@code true} if found stereotype, {@code false} otherwise - * @since 2.12 - */ - public static boolean findDirectStereotype(String stereotypeName, StereotypeAble... elements) { - boolean value = false; - for (StereotypeAble element : elements) { - if (element != null) { - if (element instanceof ObjectModelPackage) { - value = findDirectStereotype(stereotypeName, (ObjectModelPackage) element); - } else { - value = element.hasStereotype(stereotypeName); - } - if (value) { - break; - } - } - } - - return value; - - } - - /** - * Build the stack of usage of the given stereoType. - * - * Order of usage is : model, packages (from root to final package), then class. - * - * @param stereoTypeName - * @param aPackage - * @param aClass - * @return the orderer set of stack usage. - */ - public static LinkedHashSet<String> getUsageStack(String stereoTypeName, ObjectModelPackage aPackage, ObjectModelClass aClass) { - String suffix = ".stereotype=" + stereoTypeName ; - LinkedHashSet<String> stack = new LinkedHashSet<>(); - - stack.add("model" + suffix); - - addPackageStereoTypes(aPackage, suffix, stack); - stack.add(aClass.getQualifiedName() + ".class" + suffix); - - return stack; - } - - protected static void addPackageStereoTypes(ObjectModelPackage aPackage, String suffix, Set<String> stack) { - - if (aPackage.getParentPackage() != null) { - addPackageStereoTypes(aPackage.getParentPackage(), suffix, stack); - } - stack.add("package." + aPackage.getName() + suffix); - - } - - protected static boolean findDirectStereotype(String stereotypeName, ObjectModelPackage element) { - boolean withStereotype = element.hasStereotype(stereotypeName); - if (!withStereotype && element.getParentPackage() != null) { - withStereotype = findDirectStereotype(stereotypeName, element.getParentPackage()); - } - return withStereotype; - - } -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/package-info.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/package-info.java deleted file mode 100644 index 2a845b2..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/package-info.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2010 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -/** - * This package contains stereotype API. - * - * <strong>Note:</strong> Replace the deprecated class {@code org.nuiton.eugene.ModelPropertiesUtil}. - * - * @since 2.9 - * @deprecated since 3.0, use now {@code org.nuiton.eugene.models.extension.stereotype} package. - */ -package org.nuiton.eugene.models.stereotype; - diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/AggregateTagValueDefinitionProvider.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/AggregateTagValueDefinitionProvider.java deleted file mode 100644 index d7ed33c..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/AggregateTagValueDefinitionProvider.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.nuiton.eugene.models.tagvalue; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.Iterator; -import java.util.ServiceLoader; - -/** - * Created on 4/27/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class AggregateTagValueDefinitionProvider extends TagValueDefinitionProvider implements Iterable<TagValueDefinitionProvider> { - - /** Logger. */ - private static final Log log = LogFactory.getLog(AggregateTagValueDefinitionProvider.class); - - protected ClassLoader loader; - - private Iterable<TagValueDefinitionProvider> tagValueDefinitionFactories; - - public AggregateTagValueDefinitionProvider(ClassLoader loader) { - this.loader = loader; - } - - public AggregateTagValueDefinitionProvider(Iterable<TagValueDefinitionProvider> tagValueDefinitionFactories) { - this.tagValueDefinitionFactories = tagValueDefinitionFactories; - } - - @Override - public void initDefinition() { - - if (tagValueDefinitionFactories == null) { - - tagValueDefinitionFactories = ServiceLoader.load(TagValueDefinitionProvider.class, loader); - } - - for (TagValueDefinitionProvider tagValueDefinitionProvider : tagValueDefinitionFactories) { - if (isVerbose()) { - log.info("Will init tag value definition factory " + tagValueDefinitionProvider); - } - tagValueDefinitionProvider.setVerbose(isVerbose()); - tagValueDefinitionProvider.init(); - addAllDefinition(tagValueDefinitionProvider); - addAllDeprecated(tagValueDefinitionProvider); - } - } - - @Override - public Iterator<TagValueDefinitionProvider> iterator() { - return tagValueDefinitionFactories.iterator(); - } -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/InvalidTagValueSyntaxException.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/InvalidTagValueSyntaxException.java deleted file mode 100644 index 2335218..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/InvalidTagValueSyntaxException.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.nuiton.eugene.models.tagvalue; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -/** - * Created on 5/1/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class InvalidTagValueSyntaxException extends Exception { - - private static final long serialVersionUID = 1L; -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/MismatchTagValueTargetException.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/MismatchTagValueTargetException.java deleted file mode 100644 index 526b671..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/MismatchTagValueTargetException.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.nuiton.eugene.models.tagvalue; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -/** - * Created on 4/26/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class MismatchTagValueTargetException extends Exception { - - private static final long serialVersionUID = 1L; -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/MissingTagValueException.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/MissingTagValueException.java deleted file mode 100644 index 00a17fd..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/MissingTagValueException.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.nuiton.eugene.models.tagvalue; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2015 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import com.google.common.base.Joiner; -import org.nuiton.eugene.models.object.ObjectModelClass; -import org.nuiton.eugene.models.object.ObjectModelPackage; - -import java.util.Set; - -/** - * When a missing tag value is detected. - * - * Created on 15/08/15. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 3.0 - */ -@Deprecated -public class MissingTagValueException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - protected final String tagValueName; - - protected final String tagValueValue; - - protected final String prefixMessage; - - protected final Set<String> stack; - - public MissingTagValueException(String tagValueName, String tagValueValue, String prefixMessage, ObjectModelPackage aPackage, ObjectModelClass aClass) { - this.tagValueName = tagValueName; - this.tagValueValue = tagValueValue; - this.prefixMessage = prefixMessage; - this.stack = TagValues.getUsageStack(tagValueName, tagValueValue, aPackage, aClass); - } - - @Override - public String toString() { - - return "\n\n" + prefixMessage - + "\n==========================================================================================" - + "\n" + Joiner.on("\n").join(stack) - + "\n=========================================================================================="; - - } - -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueAble.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueAble.java deleted file mode 100644 index 0a71892..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueAble.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.nuiton.eugene.models.tagvalue; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import java.util.Map; - -/** - * Created on 4/26/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public interface TagValueAble { - - /** - * Returns the tagValues associated with this element. - * For each entry, the key is the name of the tagValue, the value is the value of the tagValue :-) - * - * @return a Map containing all tagValues associated with this element - */ - Map<String, String> getTagValues(); - - /** - * Returns the tagValue corresponding to the given name, or null if the element has no associated tagValue for this name. - * - * @param tagValue tag value key - * @return the value of the found tagValue, or null if the element has no associated tagValue for this name. - */ - String getTagValue(String tagValue); - - /** - * Adds the given {@code value} associated to the {@code tagValue}. - * - * Note: If a previous tag value was definied, then it will be replaced. - * - * @param tagValue the name of the tag value - * @param value the value to associate - * @since 2.1.2 - */ - void addTagValue(String tagValue, String value); - - /** - * Returns whether this element has a tagValue corresponding to the given name, or not. - * - * @param tagValue tag value name - * @return a boolean indicating whether this element has a tagValue corresponding to the given name, or not. - */ - boolean hasTagValue(String tagValue); -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueDefinition.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueDefinition.java deleted file mode 100644 index 7255ee1..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueDefinition.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.nuiton.eugene.models.tagvalue; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.nuiton.eugene.models.tagvalue.matcher.EqualsTagValueNameMatcher; -import org.nuiton.eugene.models.tagvalue.matcher.TagValueDefinitionMatcher; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * To define a tag value. - * - * Place this annotation on the constant defining your tag-value. - * - * Example for tag value named mytagvalut which can be only put on a attribute : - * <pre> - * String TAG_VALUE_MYTAGVALUE = "mytagvalue"; - * \@TagValueDefinition(target = ObjectModelAttribute.class) - * </pre> - * - * @author Tony Chemit - chemit@codelutin.com - * @see org.nuiton.eugene.EugeneTagValues - * @since 2.3 - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -@Deprecated -public @interface TagValueDefinition { - - /** - * Define the types of object model api which can use this tag value. - * - * @return the array of target object model element which can accept the tag value. - */ - Class<?>[] target(); - - /** - * Obtain the english documentation of the tag value. - * - * @return the documentation of the tag value. - * @since 2.3.1 - */ - String documentation(); - - /** - * @return the matcher used to find out back a tagValue definition from his name. - * @since 2.9 - */ - Class<? extends TagValueDefinitionMatcher> matcherClass() default EqualsTagValueNameMatcher.class; - - /** - * @return the default value to use, if not setted then do NOT use the default value. - * @since 2.9 - */ - String defaultValue() default ""; -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueDefinitionProvider.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueDefinitionProvider.java deleted file mode 100644 index 2d9284f..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueDefinitionProvider.java +++ /dev/null @@ -1,260 +0,0 @@ -package org.nuiton.eugene.models.tagvalue; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import com.google.common.base.Strings; -import com.google.common.collect.ImmutableMap; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.eugene.EugeneTagValues; -import org.nuiton.eugene.models.tagvalue.matcher.EqualsTagValueNameMatcher; -import org.nuiton.eugene.models.tagvalue.matcher.StartsWithTagNameMatcher; -import org.nuiton.eugene.models.tagvalue.matcher.TagValueDefinitionMatcher; - -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map; -import java.util.ServiceLoader; -import java.util.Set; -import java.util.TreeMap; - -/** - * To describe tag value definitions you can use on your model. Using a such class permits to validate - * the tag values before generation. - * - * Created on 4/27/14. - * <h3>Howto</h3> - * Overrides this class adding constants with {@link TagValueDefinition} annotations: - * <pre> - * package org.nuiton.mymodel; - * - * public class MyTagValueDefinitionProvider extends TagValueDefinitionProvider { - * - * \@TagvalueDefinition(target = ObjectModelAttribute.class, - * documentation = "doc of your tagValue") - * public static final String MY_TAG_VALUE = "mytagvalue"; - * } - * </pre> - * Register you provider via the {@link ServiceLoader} mecanism, create the file in your class-path - * {@code META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider}, and - * add a line - * <pre>org.nuiton.mymodel.MyTagValueDefinitionProvider</pre> - * - * @author Tony Chemit - chemit@codelutin.com - * @see EugeneTagValues - * @since 2.9 - */ -@Deprecated -public class TagValueDefinitionProvider { - - /** Logger. */ - private static final Log log = LogFactory.getLog(TagValueDefinitionProvider.class); - - protected Map<String, TagValueDefinition> definition; - - protected Set<String> deprecated; - - protected Set<TagValueDefinitionMatcher> matcher; - - protected boolean verbose; - - public TagValueDefinitionProvider() { - definition = new TreeMap<>(); - deprecated = new HashSet<>(); - matcher = new HashSet<>(); - } - - public boolean isVerbose() { - return verbose; - } - - public void setVerbose(boolean verbose) { - this.verbose = verbose; - } - - public void init() { - initDefinition(); - initMatcher(); - } - - public boolean isDeprecated(String tagValueName) { - boolean result = this.deprecated.contains(tagValueName); - return result; - } - - public void validate(String tagValueName, Class<?> type) throws TagValueNotFoundException, MismatchTagValueTargetException { - - TagValueDefinition def = getDefinition(tagValueName); - - if (def == null) { - throw new TagValueNotFoundException(); - } - - boolean valid = false; - - for (Class<?> target : def.target()) { - if (target.equals(type) || target.isAssignableFrom(type)) { - - // found one accepting target - valid = true; - break; - } - } - - if (!valid) { - throw new MismatchTagValueTargetException(); - } - } - - public String getDefaultValue(String tagValueName) { - TagValueDefinition tagValueDefinition = getDefinition(tagValueName); - String defaultValue = null; - if (tagValueDefinition != null) { - defaultValue = Strings.emptyToNull(tagValueDefinition.defaultValue()); - } - return defaultValue; - } - - public String findTagValue(String tagName, TagValueAble... elements) { - - String defaultValue = getDefaultValue(tagName); - String result = TagValues.findTagValue(tagName, defaultValue, elements); - return result; - - } - - public boolean findBooleanTagValue(String tagName, TagValueAble... elements) { - - String defaultValue = getDefaultValue(tagName); - String value = TagValues.findTagValue(tagName, defaultValue, elements); - return value != null && "true".equalsIgnoreCase(value); - - } - - public Boolean findNullableBooleanTagValue(String tagName, TagValueAble... elements) { - - String defaultValue = getDefaultValue(tagName); - Boolean result = TagValues.findNullableBooleanTagValue(tagName, defaultValue, elements); - return result; - - } - - public String findDirectTagValue(String tagName, TagValueAble... elements) { - - String defaultValue = getDefaultValue(tagName); - String value = TagValues.findDirectTagValue(tagName, defaultValue, elements); - return value; - - } - - public Map<String, TagValueDefinition> getDefinition() { - return ImmutableMap.copyOf(definition); - } - - protected void initDefinition() { - try { - scanClass(getClass()); - } catch (IllegalAccessException e) { - throw new RuntimeException("Could not init definition provider", e); - } - } - - protected TagValueDefinition getDefinition(String tagValueName) { - TagValueDefinition def = null; - - for (TagValueDefinitionMatcher tagValueDefinitionMatcher : matcher) { - def = tagValueDefinitionMatcher.match(tagValueName); - if (def != null) { - break; - } - } - return def; - } - - protected void addDefinition(String name, TagValueDefinition def) { - definition.put(name, def); - } - - protected void addAllDefinition(TagValueDefinitionProvider provider) { - definition.putAll(provider.definition); - } - - protected void addDeprecated(String name) { - deprecated.add(name); - } - - protected void addAllDeprecated(TagValueDefinitionProvider provider) { - deprecated.addAll(provider.deprecated); - } - - protected void addMatcher(TagValueDefinitionMatcher matcher) { - this.matcher.add(matcher); - } - - protected void scanClass(Class<?> holder) throws IllegalAccessException { - if (isVerbose()) { - log.info("Will scan " + holder.getName() + " to search some tag value definitions..."); - } - Field[] fields = holder.getDeclaredFields(); - for (Field field : fields) { - - TagValueDefinition tagValueDefinition = - field.getAnnotation(TagValueDefinition.class); - if (tagValueDefinition != null) { - String fieldName = field.getName(); - String tagValueName = (String) field.get(null); - if (isVerbose()) { - log.info("Detected tag value definition [" + fieldName + ":" + tagValueName + "] : " + Arrays.toString(tagValueDefinition.target())); - } - addDefinition(tagValueName, tagValueDefinition); - if (field.isAnnotationPresent(Deprecated.class)) { - addDeprecated(tagValueName); - } - } - } - } - - protected void initMatcher() { - - { - Map<String, TagValueDefinition> tagValueDefinitionForMatcher = getDefinitionForMatcher(EqualsTagValueNameMatcher.class); - addMatcher(new EqualsTagValueNameMatcher(tagValueDefinitionForMatcher)); - } - - { - Map<String, TagValueDefinition> tagValueDefinitionForMatcher = getDefinitionForMatcher(StartsWithTagNameMatcher.class); - addMatcher(new StartsWithTagNameMatcher(tagValueDefinitionForMatcher)); - } - } - - protected <M extends TagValueDefinitionMatcher> Map<String, TagValueDefinition> getDefinitionForMatcher(Class<M> matcherType) { - Map<String, TagValueDefinition> result = new TreeMap<>(); - for (Map.Entry<String, TagValueDefinition> entry : definition.entrySet()) { - if (matcherType.equals(entry.getValue().matcherClass())) { - result.put(entry.getKey(), entry.getValue()); - } - } - return result; - } -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueDefinitionProviderManagerExtension.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueDefinitionProviderManagerExtension.java deleted file mode 100644 index 8817e8d..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueDefinitionProviderManagerExtension.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.nuiton.eugene.models.tagvalue; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import com.google.common.base.Preconditions; - -/** - * Created on 6/18/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.11 - */ -@Deprecated -public class TagValueDefinitionProviderManagerExtension { - - /** - * Extension static used to identify this extension in ObjectModel. - */ - public static final String OBJECTMODEL_EXTENSION = "tagValueDefinitionProviders"; - - protected AggregateTagValueDefinitionProvider aggregateTagValueDefinitionProvider; - - public void setAggregateTagValueDefinitionProvider(AggregateTagValueDefinitionProvider aggregateTagValueDefinitionProvider) { - this.aggregateTagValueDefinitionProvider = aggregateTagValueDefinitionProvider; - } - - public <T extends TagValueDefinitionProvider> T getTagValueDefinitionProvider(Class<T> providerType) { - - Preconditions.checkState(aggregateTagValueDefinitionProvider != null, "No aggregateTagValueDefinitionProvider assigned"); - - TagValueDefinitionProvider result = null; - for (TagValueDefinitionProvider stereotypeDefinitionProvider : aggregateTagValueDefinitionProvider) { - if (providerType.equals(stereotypeDefinitionProvider.getClass())) { - result = stereotypeDefinitionProvider; - break; - } - } - - Preconditions.checkState(result != null, "No tagValueDefinitionProvider of this type: " + providerType.getName()); - return (T) result; - - } - -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueDefinitionProviders.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueDefinitionProviders.java deleted file mode 100644 index efcb304..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueDefinitionProviders.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.nuiton.eugene.models.tagvalue; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Created on 4/27/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class TagValueDefinitionProviders { - - /** Logger. */ - private static final Log log = LogFactory.getLog(TagValueDefinitionProviders.class); - - /** - * Obtain a new provider of tag value definitions. - * - * @param loader the classloader to use (if none given will use the one of the current thread) - * @param verbose verbose flag - * @return the aggregate provider of tag value definitions detected in the class-path - */ - public static AggregateTagValueDefinitionProvider newProvider(ClassLoader loader, boolean verbose) { - - if (loader == null) { - - // use the current thread loader - loader = Thread.currentThread().getContextClassLoader(); - } - - AggregateTagValueDefinitionProvider store = new AggregateTagValueDefinitionProvider(loader); - store.setVerbose(verbose || log.isDebugEnabled()); - try { - store.init(); - } catch (Exception e) { - throw new RuntimeException("Could not init tag value definition provider", e); - } - return store; - } - - /** - * Obtain a new provider of tag value definitions. - * - * @param providers the list of providers to use in the factory - * @param verbose verbose flag - * @return the aggregate provider of tag value definitions detected in the class-path - */ - public static AggregateTagValueDefinitionProvider newProvider(Iterable<TagValueDefinitionProvider> providers, boolean verbose) { - - AggregateTagValueDefinitionProvider store = new AggregateTagValueDefinitionProvider(providers); - store.setVerbose(verbose || log.isDebugEnabled()); - try { - store.init(); - } catch (Exception e) { - throw new RuntimeException("Could not init tag value definition provider", e); - } - return store; - } -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueNotFoundException.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueNotFoundException.java deleted file mode 100644 index 7480ae6..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValueNotFoundException.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.nuiton.eugene.models.tagvalue; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -/** - * Created on 4/26/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class TagValueNotFoundException extends Exception { - - private static final long serialVersionUID = 1L; -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValues.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValues.java deleted file mode 100644 index 31e39b7..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValues.java +++ /dev/null @@ -1,351 +0,0 @@ -package org.nuiton.eugene.models.tagvalue; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.apache.commons.lang3.StringUtils; -import org.nuiton.eugene.models.object.ObjectModelClass; -import org.nuiton.eugene.models.object.ObjectModelElement; -import org.nuiton.eugene.models.object.ObjectModelPackage; - -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Created on 4/26/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class TagValues { - - /** - * Pattern to define tag values authorized at classifier level in the model - * properties file. - * - * L'expression réguliere match les chaines de type - * <package.ClassName>.<class|attribute|operation>.[name].<stereotype|tagvalue>.[tag] - * fr.isisfish.entities.Population.class.stereotype=entity - * fr.isisfish.entities.Population.class.tagvalue.persistenceType=flatfile - * fr.isisfish.entities.Population.attribute.name.stereotype=... - * fr.isisfish.entities.Population.attribute.name.tagvalue.pk=topiaId - * fr.isisfish.entities.Population.operation.getRegion.stereotype=... - * fr.isisfish.entities.Population.operation.getRegion.tagvalue.pk=... - */ - protected static final Pattern TAG_VALUE_PATTERN = - Pattern.compile("^((?:[_a-zA-Z0-9]+\\.)+(?:_?[A-Z][_a-zA-Z0-9]*\\.)+)(?:(class|attribute|operation))\\.(?:([_a-zA-Z0-9]+)\\.)?(?:(tagvalue|tagValue)?)\\.((?:[_a-zA-Z0-9]+)+(?:\\.?[_a-zA-Z0-9]+)*)?$"); - - /** - * Pattern to define tag values authorized at model level in the model - * properties file. - */ - protected static final Pattern MODEL_TAG_VALUE_PATTERN = Pattern.compile( - "^model\\.(?:(tagvalue|tagValue)?)\\.((?:[_a-zA-Z0-9]+)+(?:\\.?[_a-zA-Z0-9]+)*)$"); - - /** - * Pattern to define tag values authorized at model level in the model - * properties file. - */ - protected static final Pattern PACKAGE_TAG_VALUE_PATTERN = Pattern.compile( - "^package\\.((?:[_a-zA-Z0-9]+\\.)+)(?:(tagvalue|tagValue)?)\\.((?:[_a-zA-Z0-9]+)+(?:\\.?[_a-zA-Z0-9]+)*)$"); - - public static Matcher getModelMatcher(String key) throws InvalidTagValueSyntaxException { - Matcher matcher = MODEL_TAG_VALUE_PATTERN.matcher(key); - if (!matcher.find()) { - throw new InvalidTagValueSyntaxException(); - } - return matcher; - } - - public static Matcher getPackageMatcher(String key) throws InvalidTagValueSyntaxException { - Matcher matcher = PACKAGE_TAG_VALUE_PATTERN.matcher(key); - if (!matcher.find()) { - throw new InvalidTagValueSyntaxException(); - } - return matcher; - } - - public static Matcher getMatcher(String key) throws InvalidTagValueSyntaxException { - Matcher matcher = TAG_VALUE_PATTERN.matcher(key); - if (!matcher.find()) { - throw new InvalidTagValueSyntaxException(); - } - return matcher; - } - - /** - * Seek for a Boolean tag value. - * - * Will first the tag value using the method {@link #findTagValue(String, TagValueAble...)}. - * - * If not found, return {@code null}, otherwise return boolean value (case is ignored). - * - * <strong>Note:</strong> Order of {@code elements} is important, better then to - * always starts from specialized to more general level (for example from attribute, - * to classifier or model). - * - * @param tagName tag name to find - * @param elements not null elements to test - * @return found boolean tag value or {@code null} if tag value not found. - * @since 2.9 - */ - public static Boolean findNullableBooleanTagValue(String tagName, TagValueAble... elements) { - - String value = findTagValue(tagName, elements); - return value == null ? null : "true".equalsIgnoreCase(value); - - } - - /** - * Seek for a Boolean tag value. - * - * Will first the tag value using the method {@link #findTagValue(String, TagValueAble...)}. - * - * If not found, return {@code null}, otherwise return boolean value (case is ignored). - * - * <strong>Note:</strong> Order of {@code elements} is important, better then to - * always starts from specialized to more general level (for example from attribute, - * to classifier or model). - * - * @param tagName tag name to find - * @param defaultValue the String representation of the value to return if not found. May be "true", "false" or null - * @param elements not null elements to test - * @return found boolean tag value or {@code null} if tag value not found. - * @since 2.11 - */ - public static Boolean findNullableBooleanTagValue(String tagName, String defaultValue, TagValueAble... elements) { - - String value = findTagValue(tagName, defaultValue, elements); - return value == null ? null : "true".equalsIgnoreCase(value); - - } - - /** - * Seek for a boolean tag value. - * - * Will first the tag value using the method {@link #findTagValue(String, TagValueAble...)}. - * - * If found, return {@code true}, if the value is not null and is {@code "true"} String value (case is ignored). - * - * <strong>Note:</strong> Order of {@code elements} is important, better then to - * always starts from specialized to more general level (for example from attribute, - * to classifier or model). - * - * @param tagName tag name to find - * @param elements not null elements to test - * @return found boolean tag value or {@code false} if tag value is not found, nor having - * {@code "true"} value (case is ignored). - * @since 2.9 - */ - public static boolean findBooleanTagValue(String tagName, TagValueAble... elements) { - - String value = findTagValue(tagName, elements); - return value != null && "true".equalsIgnoreCase(value); - - } - - /** - * Seek for a boolean tag value. - * - * Will first the tag value using the method {@link #findTagValue(String, TagValueAble...)}. - * - * If found, return {@code true}, if the value is not null and is {@code "true"} String value (case is ignored). - * - * <strong>Note:</strong> Order of {@code elements} is important, better then to - * always starts from specialized to more general level (for example from attribute, - * to classifier or model). - * - * @param tagName tag name to find - * @param defaultValue the String representation of the value to return if not found. May be "true", "false" or null - * @param elements not null elements to test - * @return found boolean tag value or {@code false} if tag value is not found, nor having - * {@code "true"} value (case is ignored). - * @since 2.11 - */ - public static boolean findBooleanTagValue(String tagName, String defaultValue, TagValueAble... elements) { - - String value = findTagValue(tagName, defaultValue, elements); - return value != null && "true".equalsIgnoreCase(value); - - } - - /** - * Seek for a tag value amoung elements given using these rules: - * <ul> - * <li>Look into {@code elements} and return the first not empty tag value found.</li> - * <li>If not found, Look into {@code elements} declaringElement (for each - * element that is a {@link ObjectModelElement} and return the first not empty tag - * value found.</li> - * <li>If not found return {@code null}</li> - * </ul> - * <strong>Note:</strong> Order of {@code elements} is important, better then to - * always starts from specialized to more general level (for example from attribute, - * to classifier or model). - * - * @param tagName tag name to find - * @param elements not null elements to test - * @return found tag value or {@code null} if not found - * @since 2.9 - */ - public static String findTagValue(String tagName, TagValueAble... elements) { - - return findTagValue(tagName, null, elements); - } - - /** - * Seek for a tag value amoung elements given using these rules: - * <ul> - * <li>Look into {@code elements} and return the first not empty tag value found.</li> - * <li>If not found, Look into {@code elements} declaringElement (for each - * element that is a {@link ObjectModelElement} and return the first not empty tag - * value found.</li> - * <li>If not found return {@code defaultValue}</li> - * </ul> - * <strong>Note:</strong> Order of {@code elements} is important, better then to - * always starts from specialized to more general level (for example from attribute, - * to classifier or model). - * - * @param tagName tag name to find - * @param defaultValue the value to return if not found - * @param elements not null elements to test - * @return found tag value or {@code null} if not found - * @since 2.11 - */ - public static String findTagValue(String tagName, String defaultValue, TagValueAble... elements) { - - String result = findDirectTagValue(tagName, defaultValue, elements); - - if (result != null) { - return result; - } - - for (TagValueAble element : elements) { - if (element instanceof ObjectModelElement) { - // try in declaring element - ObjectModelElement declaringElement = ((ObjectModelElement) element).getDeclaringElement(); - if (declaringElement != null) { - String value = findNotEmptyTagValue(tagName, declaringElement); - if (value != null) { - return value; - } - } - } - } - return defaultValue; - - } - - /** - * Seek for a tag value amoung elements given using these rules: - * <ul> - * <li>Look into {@code elements} and return the first not empty tag value found.</li> - * <li>If not found return {@code defaultValue}</li> - * </ul> - * <strong>Note:</strong> Order of {@code elements} is important, better then to - * always starts from specialized to more general level (for example from attribute, - * to classifier or model). - * - * @param tagName tag name to find - * @param defaultValue the value to return if not found - * @param elements not null elements to test - * @return found tag value or {@code null} if not found - * @since 2.12 - */ - public static String findDirectTagValue(String tagName, String defaultValue, TagValueAble... elements) { - - for (TagValueAble element : elements) { - String value = findNotEmptyTagValue(tagName, element); - if (value != null) { - return value; - } - } - - return defaultValue; - - } - - public static String findNotEmptyTagValue(String tagName, TagValueAble element) { - - String value = null; - if (element != null) { - if (element instanceof ObjectModelPackage) { - value = findNotEmptyTagValue(tagName, (ObjectModelPackage) element); - } else { - value = element.getTagValue(tagName); - if (StringUtils.isEmpty(value)) { - value = null; - } - } - } - return value; - - } - - /** - * Build the stack of usage of the given tag value. - * - * Order of usage is : model, packages (from root to final package), then class. - * - * @param tagValueName - * @param tagValueValue - * @param aPackage - * @param aClass - * @return the orderer set of stack usage. - */ - public static LinkedHashSet<String> getUsageStack(String tagValueName, String tagValueValue, ObjectModelPackage aPackage, ObjectModelClass aClass) { - String suffix = ".tagvalue." + tagValueName + "=" + tagValueValue; - LinkedHashSet<String> stack = new LinkedHashSet<>(); - - stack.add("model" + suffix); - - addPackageTagValue(aPackage, suffix, stack); - stack.add(aClass.getQualifiedName() + ".class" + suffix); - - return stack; - } - - protected static void addPackageTagValue(ObjectModelPackage aPackage, String suffix, Set<String> stack) { - - if (aPackage.getParentPackage() != null) { - addPackageTagValue(aPackage.getParentPackage(), suffix, stack); - } - stack.add("package." + aPackage.getName() + suffix); - - } - - protected static String findNotEmptyTagValue(String tagName, ObjectModelPackage element) { - - String value = element.getTagValue(tagName); - if (StringUtils.isEmpty(value)) { - value = null; - } - if (value == null && element.getParentPackage() != null) { - value = findNotEmptyTagValue(tagName, element.getParentPackage()); - } - return value; - - } - -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/matcher/EqualsTagValueNameMatcher.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/matcher/EqualsTagValueNameMatcher.java deleted file mode 100644 index 82c7083..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/matcher/EqualsTagValueNameMatcher.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.nuiton.eugene.models.tagvalue.matcher; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.nuiton.eugene.models.tagvalue.TagValueDefinition; - -import java.util.Map; - -/** - * Created on 4/26/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class EqualsTagValueNameMatcher extends TagValueDefinitionMatcher { - - public EqualsTagValueNameMatcher(Map<String, TagValueDefinition> tagValueDefinitionMap) { - super(tagValueDefinitionMap); - } - - @Override - protected boolean accept(String tagValueName, Map.Entry<String, TagValueDefinition> entry) { - return entry.getKey().equals(tagValueName); - } -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/matcher/StartsWithTagNameMatcher.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/matcher/StartsWithTagNameMatcher.java deleted file mode 100644 index 2c30604..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/matcher/StartsWithTagNameMatcher.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.nuiton.eugene.models.tagvalue.matcher; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.nuiton.eugene.models.tagvalue.TagValueDefinition; - -import java.util.Map; - -/** - * Created on 4/26/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public class StartsWithTagNameMatcher extends TagValueDefinitionMatcher { - - public StartsWithTagNameMatcher(Map<String, TagValueDefinition> tagValueDefinitionMap) { - super(tagValueDefinitionMap); - } - - @Override - protected boolean accept(String tagValueName, Map.Entry<String, TagValueDefinition> entry) { - return tagValueName.startsWith(entry.getKey()); - } - -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/matcher/TagValueDefinitionMatcher.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/matcher/TagValueDefinitionMatcher.java deleted file mode 100644 index b765962..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/matcher/TagValueDefinitionMatcher.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.nuiton.eugene.models.tagvalue.matcher; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import com.google.common.collect.ImmutableMap; -import org.nuiton.eugene.models.tagvalue.TagValueDefinition; - -import java.util.Map; - -/** - * To match a Tag value name. - * - * Created on 4/26/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.9 - */ -@Deprecated -public abstract class TagValueDefinitionMatcher { - - protected Map<String, TagValueDefinition> tagValueDefinitionMap; - - public TagValueDefinitionMatcher(Map<String, TagValueDefinition> tagValueDefinitionMap) { - this.tagValueDefinitionMap = ImmutableMap.<String, TagValueDefinition>builder().putAll(tagValueDefinitionMap).build(); - } - - public TagValueDefinition match(String tagValueName) { - TagValueDefinition tagValueDefinition = null; - for (Map.Entry<String, TagValueDefinition> entry : tagValueDefinitionMap.entrySet()) { - if (accept(tagValueName, entry)) { - // found tag value definition - tagValueDefinition = entry.getValue(); - break; - } - } - return tagValueDefinition; - } - - protected abstract boolean accept(String tagValueName, Map.Entry<String, TagValueDefinition> entry); - -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/package-info.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/package-info.java deleted file mode 100644 index 8c890ee..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/package-info.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2010 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -/** - * This package contains tag value API. - * - * <strong>Note:</strong> Replace the deprecated class {@code org.nuiton.eugene.ModelPropertiesUtil}. - * - * @since 2.9 - * @deprecated since 3.0, use now {@code org.nuiton.eugene.models.extension.tagvalue} package. - */ -package org.nuiton.eugene.models.tagvalue; - diff --git a/eugene/src/main/resolver-cache/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider b/eugene/src/main/resolver-cache/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider deleted file mode 100644 index dd11657..0000000 --- a/eugene/src/main/resolver-cache/META-INF/services/org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider +++ /dev/null @@ -1 +0,0 @@ -org.nuiton.eugene.EugeneStereoTypes \ No newline at end of file diff --git a/eugene/src/main/resolver-cache/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider b/eugene/src/main/resolver-cache/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider deleted file mode 100644 index f8cf779..0000000 --- a/eugene/src/main/resolver-cache/META-INF/services/org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider +++ /dev/null @@ -1 +0,0 @@ -org.nuiton.eugene.EugeneTagValues \ No newline at end of file diff --git a/eugene/src/main/resources/i18n/eugene_en_GB.properties b/eugene/src/main/resources/i18n/eugene_en_GB.properties index 30f0113..9360a93 100644 --- a/eugene/src/main/resources/i18n/eugene_en_GB.properties +++ b/eugene/src/main/resources/i18n/eugene_en_GB.properties @@ -1,11 +1,10 @@ -eugene.core.stereotypes=EUGeNe Core stereotypes -eugene.core.stereotypes.ordered=Is attribute ordererd ? -eugene.core.stereotypes.skip=Skip generation -eugene.core.stereotypes.unique=Is attribute unique ? eugene.core.tagValues.attributeGeneric=Generic type of attribute eugene.core.tagValues.constantPrefix=Constant field prefix eugene.core.tagValues.documentation=Documentation eugene.core.tagValues.generateBooleanGetMethods=Generate getter on Boolean eugene.core.tagValues.i18n=I18n prefix +eugene.core.tagValues.ordered=Is attribute ordererd ? +eugene.core.tagValues.skip=Skip generation +eugene.core.tagValues.unique=Is attribute unique ? eugene.core.tagValues.version=Version of model eugene.core.tagvalues=EUGeNe Core tag values diff --git a/eugene/src/main/resources/i18n/eugene_fr_FR.properties b/eugene/src/main/resources/i18n/eugene_fr_FR.properties index db0b548..d1594f2 100644 --- a/eugene/src/main/resources/i18n/eugene_fr_FR.properties +++ b/eugene/src/main/resources/i18n/eugene_fr_FR.properties @@ -1,11 +1,10 @@ -eugene.core.stereotypes=EUGeNe stéréotypes -eugene.core.stereotypes.ordered=L'attribut est-il ordonné ? -eugene.core.stereotypes.skip=Ne pas générer -eugene.core.stereotypes.unique=L'attribut est-il unique ? eugene.core.tagValues.attributeGeneric=Type générique de l'attribut eugene.core.tagValues.constantPrefix=Préfixe des constantes eugene.core.tagValues.documentation=Documentation eugene.core.tagValues.generateBooleanGetMethods=Génerer les getters sur le type Boolean eugene.core.tagValues.i18n=Préfix i18n +eugene.core.tagValues.ordered=L'attribut est-il ordonné ? +eugene.core.tagValues.skip=Ne pas générer +eugene.core.tagValues.unique=L'attribut est-il unique ? eugene.core.tagValues.version=Version du modèle eugene.core.tagvalues=EUGeNe Core tag values diff --git a/eugene/src/test/java/org/nuiton/eugene/EugeneStereotypesTest.java b/eugene/src/test/java/org/nuiton/eugene/EugeneStereotypesTest.java deleted file mode 100644 index d479aae..0000000 --- a/eugene/src/test/java/org/nuiton/eugene/EugeneStereotypesTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.nuiton.eugene; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.nuiton.eugene.models.object.ObjectModel; -import org.nuiton.eugene.models.object.ObjectModelAttribute; -import org.nuiton.eugene.models.object.ObjectModelClass; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelEnumeration; -import org.nuiton.eugene.models.object.ObjectModelInterface; -import org.nuiton.eugene.models.object.ObjectModelOperation; -import org.nuiton.eugene.models.stereotype.MismatchStereotypeTargetException; -import org.nuiton.eugene.models.stereotype.StereotypeNotFoundException; - -public class EugeneStereotypesTest { - - protected EugeneStereoTypes provider; - - @Before - public void setUp() throws Exception { - provider = new EugeneStereoTypes(); - provider.init(); - } - - @Test - public void validate() throws Exception { - - validate(EugeneStereoTypes.STEREOTYPE_ORDERED, true, ObjectModelAttribute.class); - - validate(EugeneStereoTypes.STEREOTYPE_ORDERED, false, ObjectModel.class, ObjectModelOperation.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class, ObjectModelInterface.class); - - long l = System.nanoTime(); - validate(EugeneStereoTypes.STEREOTYPE_ORDERED + l, false, ObjectModel.class, ObjectModelOperation.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class, ObjectModelInterface.class); - - } - - protected void validate(String name, boolean expected, Class<?>... types) { - for (Class<?> type : types) { - try { - provider.validate(name, type); - Assert.assertTrue(expected); - } catch (StereotypeNotFoundException | MismatchStereotypeTargetException e) { - Assert.assertFalse(expected); - } - } - } - -} diff --git a/eugene/src/test/java/org/nuiton/eugene/EugeneTagValuesTest.java b/eugene/src/test/java/org/nuiton/eugene/EugeneTagValuesTest.java deleted file mode 100644 index a37433c..0000000 --- a/eugene/src/test/java/org/nuiton/eugene/EugeneTagValuesTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.nuiton.eugene; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.nuiton.eugene.models.object.ObjectModel; -import org.nuiton.eugene.models.object.ObjectModelAttribute; -import org.nuiton.eugene.models.object.ObjectModelClass; -import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelEnumeration; -import org.nuiton.eugene.models.object.ObjectModelOperation; -import org.nuiton.eugene.models.object.ObjectModelPackage; -import org.nuiton.eugene.models.object.xml.ObjectModelClassImpl; -import org.nuiton.eugene.models.object.xml.ObjectModelImpl; -import org.nuiton.eugene.models.object.xml.ObjectModelPackageImpl; -import org.nuiton.eugene.models.tagvalue.MismatchTagValueTargetException; -import org.nuiton.eugene.models.tagvalue.TagValueNotFoundException; - -public class EugeneTagValuesTest { - - protected EugeneTagValues provider; - - @Before - public void setUp() throws Exception { - provider = new EugeneTagValues(); - provider.init(); - } - - @Test - public void validate() throws Exception { - validate(EugeneTagValues.TAG_CONSTANT_PREFIX, true, ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class); - validate(EugeneTagValues.TAG_I18N_PREFIX, true, ObjectModel.class, ObjectModelPackage.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class); - validate(EugeneTagValues.TAG_VERSION, true, ObjectModel.class); - - validate(EugeneTagValues.TAG_CONSTANT_PREFIX, false, ObjectModelOperation.class, ObjectModelAttribute.class); - validate(EugeneTagValues.TAG_I18N_PREFIX, false, ObjectModelOperation.class, ObjectModelAttribute.class); - validate(EugeneTagValues.TAG_VERSION, false, ObjectModelPackage.class, ObjectModelClassifier.class, ObjectModelOperation.class, ObjectModelAttribute.class); - - long l = System.nanoTime(); - validate(EugeneTagValues.TAG_CONSTANT_PREFIX + l, false, ObjectModelOperation.class, ObjectModelPackage.class, ObjectModelAttribute.class); - validate(EugeneTagValues.TAG_I18N_PREFIX + l, false, ObjectModelOperation.class, ObjectModelPackage.class, ObjectModelAttribute.class); - validate(EugeneTagValues.TAG_VERSION + l, false, ObjectModelClassifier.class, ObjectModelPackage.class, ObjectModelOperation.class, ObjectModelAttribute.class); - } - - @Test - public void testDefaultValue() throws Exception { - Assert.assertEquals("PROPERTY_", provider.getConstantPrefixTagValue(new ObjectModelClassImpl(), new ObjectModelPackageImpl(), new ObjectModelImpl())); - Assert.assertEquals(false, provider.isGenerateBooleanGetMethods(new ObjectModelClassImpl(), new ObjectModelPackageImpl(), new ObjectModelImpl())); - // No default value - Assert.assertNull(provider.getI18nPrefixTagValue(new ObjectModelClassImpl(), new ObjectModelPackageImpl(), new ObjectModelImpl())); - } - - protected void validate(String name, boolean expected, Class<?>... types) { - for (Class<?> type : types) { - - try { - provider.validate(name, type); - Assert.assertTrue(expected); - } catch (TagValueNotFoundException | MismatchTagValueTargetException e) { - Assert.assertFalse(expected); - } - } - } -} diff --git a/eugene/src/test/java/org/nuiton/eugene/models/tagvalue/TagValuesTest.java b/eugene/src/test/java/org/nuiton/eugene/models/tagvalue/TagValuesTest.java deleted file mode 100644 index c0a4b84..0000000 --- a/eugene/src/test/java/org/nuiton/eugene/models/tagvalue/TagValuesTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.nuiton.eugene.models.tagvalue; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program 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 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.junit.Assert; -import org.junit.Test; - -public class TagValuesTest { - - @Test - public void testDefaultValue() throws Exception { - String defaultValue = "whatever value"; - String value = TagValues.findTagValue("whatever.tag", defaultValue); - Assert.assertEquals(defaultValue, value); - } - - @Test - public void testGetModelMatcher() throws Exception { - TagValues.getModelMatcher("model.tagvalue.hibernateAttributeType"); - TagValues.getModelMatcher("model.tagValue.hibernateAttributeType"); - TagValues.getModelMatcher("model.tagValue.hibernateAttributeType.String"); - TagValues.getModelMatcher("model.tagValue.hibernateAttributeType.java.lang.String"); - } - - @Test - public void testPackageModelMatcher() throws Exception { - TagValues.getPackageMatcher("package.fr.ird.observe.tagvalue.hibernateAttributeType"); - TagValues.getPackageMatcher("package.fr.ird.observe.tagValue.hibernateAttributeType"); - TagValues.getPackageMatcher("package.fr.ird.observe.tagValue.hibernateAttributeType.String"); - TagValues.getPackageMatcher("package.fr.ird.observe.tagValue.hibernateAttributeType.java.lang.String"); - } - - @Test - public void testGetMatcher() throws Exception { - TagValues.getMatcher("fr.ird.observe.entities.CommentableEntity.attribute.comment.tagvalue.hibernateAttributeType"); - TagValues.getMatcher("fr.ird.observe.entities.CommentableEntity.attribute.comment.tagValue.hibernateAttributeType"); - TagValues.getMatcher("fr.ird.observe.entities.CommentableEntity.attribute.comment.tagValue.hibernateAttributeType.String"); - TagValues.getMatcher("fr.ird.observe.entities.CommentableEntity.attribute.comment.tagValue.hibernateAttributeType.java.lang.String"); - } - -} -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.