Class CoreTextCreator

  • Direct Known Subclasses:
    ModelTextCreator

    @OpenApiAll
    public class CoreTextCreator
    extends java.lang.Object
    Contains methods to create representation text for model elements that are commonly used as property values of other elements
    • Field Detail

      • useStandardStereotypeChar

        private static boolean useStandardStereotypeChar
      • NEW_LINE_SEPARATOR

        public static final java.lang.String NEW_LINE_SEPARATOR
        See Also:
        Constant Field Values
    • Constructor Detail

      • CoreTextCreator

        public CoreTextCreator()
    • Method Detail

      • isUseStandardStereotypeChar

        public static boolean isUseStandardStereotypeChar()
      • setUseStandardStereotypeChar

        public static void setUseStandardStereotypeChar​(boolean useStandardStereotypeChar)
      • createTypeText

        public static TextBuilder createTypeText​(java.util.Collection<? extends Type> types,
                                                 boolean showQualifiedName,
                                                 java.util.function.Supplier<TextBuilder> builderFactory)
        Creates string representation of the given Type elements, separated by comma.
        Parameters:
        types - collection of types
        showQualifiedName - true to include type's qualified name
        builderFactory - provides TextBuilder to append the created text to
        Returns:
        builder with the types' text appended
      • createTypeText

        public static TextBuilder createTypeText​(Type type,
                                                 boolean showQualifiedName,
                                                 java.util.function.Supplier<TextBuilder> builderFactory)
        Creates string representation of the given Type.
        Parameters:
        type - element to create representation text for
        showQualifiedName - true to include type's qualified name
        builderFactory - providesTextBuilder to append the created text to
        Returns:
        builder with the type's text appended
      • createStyledTypeText

        public static TextBuilder createStyledTypeText​(Type type,
                                                       boolean showQualifiedName,
                                                       java.util.function.Supplier<TextBuilder> builderFactory)
        Creates colored string representation of the given Type.
        Parameters:
        type - element to create representation text for
        showQualifiedName - true to include type's qualified name
        builderFactory - provides TextBuilder to append the created text to
        Returns:
        builder with the type's text appended
      • createStyledTypeTextWithSeparator

        public static TextBuilder createStyledTypeTextWithSeparator​(Type type,
                                                                    boolean showQualifiedName,
                                                                    java.util.function.Supplier<TextBuilder> builderFactory)
        Creates colored string representation of the given Type. Pre-appends CoreTextCreator.TYPE_SEPARATOR
        Parameters:
        type - element to create representation text for
        showQualifiedName - true to include type's qualified name
        builderFactory - providesTextBuilder to append the created text to
        Returns:
        builder with the type's text appended
      • createTypeText

        private static TextBuilder createTypeText​(Type type,
                                                  boolean showQualifiedName,
                                                  boolean useTypeColor,
                                                  boolean addTypeSeparator,
                                                  java.util.function.Supplier<TextBuilder> builderFactory)
        Creates colored string representation of the given Type.
        Parameters:
        type - element to create representation text for
        showQualifiedName - true to include type's qualified name
        useTypeColor - true to created colored type text
        addTypeSeparator - true to pre append CoreTextCreator.TYPE_SEPARATOR
        builderFactory - providesTextBuilder to append the created text to
        Returns:
        builder with the type's text appended
      • createStringCollectionText

        public static TextBuilder createStringCollectionText​(java.util.Collection<java.lang.String> strings,
                                                             java.lang.String separator,
                                                             java.util.function.Supplier<TextBuilder> builderFactory)
        Joins strings
        Parameters:
        strings - strings to join
        separator - symbol(s) to separate each string with
        builderFactory - providesTextBuilder to append the created text to
        Returns:
        builder with the joined strings appended
      • createNamedElementListText

        public static TextBuilder createNamedElementListText​(java.util.List<? extends NamedElement> elements,
                                                             java.util.function.Supplier<TextBuilder> builderFactory)
        Creates representation text for a list of named elements, which contains names separated by a comma. Only names of the first 5 elements are included, and "..." is added in there are more elements in the list.
        Parameters:
        elements - to create joined named representation for
        Returns:
        builder with the element names appended
      • createValueSpecificationText

        public static TextBuilder createValueSpecificationText​(@CheckForNull
                                                               ValueSpecification valueSpecification,
                                                               boolean addBraces,
                                                               java.util.function.Supplier<TextBuilder> builderFactory)
        Creates string representation of the given ValueSpecification.
        Parameters:
        valueSpecification - element to create representation text for
        addBraces - true to add braces around the value specification text
        builderFactory - providesTextBuilder to append the created text to
        Returns:
        builder with the value specification's text appended
      • createValueSpecificationText

        public static <T extends TextBuilder> T createValueSpecificationText​(@CheckForNull
                                                                             ValueSpecification valueSpecification,
                                                                             java.util.function.Supplier<T> builderFactory)
        Creates string representation of the given ValueSpecification with no braces.
        Parameters:
        valueSpecification - element to create representation text for
        builderFactory - providesTextBuilder to append the created text to
        Returns:
        builder with the value specification's text appended
      • createMultiplicityText

        public static java.lang.String createMultiplicityText​(java.lang.String lower,
                                                              java.lang.String upper,
                                                              @CheckForNull
                                                              ValueSpecification lowerValue,
                                                              boolean unique,
                                                              boolean ordered,
                                                              MultiplicityTextParams textParams)
        Creates string representation of the provided multiplicity range.
        Parameters:
        lower - lower bounds of the multiplicity
        upper - upper bounds of the multiplicity
        lowerValue - value specification element that holds the value of the lower bounds
        ordered - is ordered
        unique - is unique
        textParams - text parameters
        Returns:
        builder with the multiplicity's text appended
      • createMultiplicityText

        public static TextBuilder createMultiplicityText​(TextBuilder lower,
                                                         TextBuilder upper,
                                                         @CheckForNull
                                                         ValueSpecification lowerValue,
                                                         boolean unique,
                                                         boolean ordered,
                                                         MultiplicityTextParams textParams,
                                                         java.util.function.Supplier<TextBuilder> builderFactory)
        Creates string representation of the provided multiplicity range.
        Parameters:
        lower - lower bounds of the multiplicity
        upper - upper bounds of the multiplicity
        lowerValue - value specification element that holds the value of the lower bounds
        ordered - is ordered
        unique - is unique
        textParams - text parameters
        Returns:
        builder with the multiplicity's text appended
      • createMultiplicityRangeText

        public static java.lang.String createMultiplicityRangeText​(@CheckForNull
                                                                   java.lang.Integer range)
        Creates multiplicity range text.
        Parameters:
        range - multiplicity range.
        Returns:
        multiplicity range string representation.
      • createMultiplicityText

        public static java.lang.String createMultiplicityText​(@CheckForNull
                                                              java.lang.Integer lower,
                                                              @CheckForNull
                                                              java.lang.Integer upper)
        Creates multiplicity text.
        Parameters:
        lower - Lower range.
        upper - Upper range.
        Returns:
        representation text of multiplicity value.
      • createMultiplicityText

        public static TextBuilder createMultiplicityText​(TextBuilder lower,
                                                         TextBuilder upper,
                                                         boolean ordered,
                                                         boolean unique,
                                                         MultiplicityTextParams textParams,
                                                         java.util.function.Supplier<TextBuilder> builderFactory)
        Returns text representation of given multiplicity.
        Parameters:
        lower - Lower value
        upper - Upper value
        ordered - ordered
        unique - unique
        textParams - text parameters
        Returns:
        builder with multiplicity's representation or empty string if multiplicity is null.
      • createMultiplicityText

        public static java.lang.String createMultiplicityText​(@CheckForNull
                                                              java.lang.String lower,
                                                              @CheckForNull
                                                              java.lang.String upper,
                                                              boolean ordered,
                                                              boolean unique,
                                                              MultiplicityTextParams textParams)
        Creates text representation of given multiplicity range.
        Parameters:
        lower - Lower value
        upper - Upper value
        ordered - ordered
        unique - unique
        textParams - text parameters
        Returns:
        text representation or empty string if multiplicity is null
      • createMultiplicityText

        public static TextBuilder createMultiplicityText​(@CheckForNull
                                                         MultiplicityElement element,
                                                         MultiplicityTextParams textParams,
                                                         java.util.function.Supplier<TextBuilder> builderFactory)
        Creates text representation of given element MultiplicityElement.
        Parameters:
        element - the given multiplicity element
        textParams - text parameters
        builderFactory - provides TextBuilder to append the created text to
        Returns:
        builder with the multiplicity text appended
      • join

        protected static <T> TextBuilder join​(TextBuilder textBuilder,
                                              java.lang.String delimiter,
                                              java.util.stream.Stream<T> elements,
                                              java.util.function.Function<T,​TextBuilder> map)
      • createVisibilityText

        public static java.lang.String createVisibilityText​(@CheckForNull
                                                            VisibilityKind visibility)
        Returns visibility representation(+, # or -)
        Parameters:
        visibility - the given visibility.
        Returns:
        the char representation of given visibility.
      • createStereotypesText

        public static TextBuilder createStereotypesText​(Element element,
                                                        java.lang.String separator,
                                                        StereotypeTextParams textParams,
                                                        java.util.function.Supplier<TextBuilder> builderFactory)
        Creates string representation of stereotypes that are applied to the provided element
        Parameters:
        element - to create representation text for
        separator - symbol(s) to separate each stereotype's text with
        textParams - text parameters
        builderFactory - provides TextBuilder to append the created text to
        Returns:
        builder with the stereotypes' text appended
      • createStereotypesText

        public static TextBuilder createStereotypesText​(java.util.Collection<Stereotype> stereotypes,
                                                        java.lang.String separator,
                                                        StereotypeTextParams textParams,
                                                        java.util.function.Supplier<TextBuilder> builderFactory)
        Creates string representation for the collection of Stereotype elements.
        Parameters:
        stereotypes - collection of stereotypes to create representation text for
        separator - symbol(s) to separate each stereotype's text with
        textParams - configuration that defines what to include in the text of each stereotype
        builderFactory - provides TextBuilder to append the created text to
        Returns:
        builder with the stereotypes' text appended
      • createStereotypeText

        public static TextBuilder createStereotypeText​(Stereotype stereotype,
                                                       StereotypeTextParams textParams,
                                                       java.util.function.Supplier<TextBuilder> builderFactory)
        Creates string representation of the given Stereotype.
        Parameters:
        stereotype - element to create representation text for
        textParams - configuration that defines what to include in the text of the stereotype
        builderFactory - provides TextBuilder to append the created text to
        Returns:
        builder with the stereotype's text appended
      • createStereotypeText

        public static java.lang.String createStereotypeText​(@CheckForNull
                                                            java.lang.String stereotypeName)
      • containsParentheses

        protected static boolean containsParentheses​(java.lang.String string)
      • createElementNumberText

        public static TextBuilder createElementNumberText​(Element element,
                                                          java.util.function.Supplier<TextBuilder> builderFactory)
        Create the element's number (auto id) text
        Parameters:
        element - the element that can be numbered
        builderFactory - provides TextBuilder to append the created text to
        Returns:
        builder with the number + space at the end or empty string if the number is not available