Package com.nomagic.magicdraw.uml.text
Class CoreTextCreator
java.lang.Object
com.nomagic.magicdraw.uml.text.CoreTextCreator
- Direct Known Subclasses:
ModelTextCreator
Contains methods to create representation text for model elements that are commonly used as property values of other elements
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static boolean
containsParentheses
(String string) static TextBuilder
createElementNumberText
(Element element, Supplier<TextBuilder> builderFactory) Create the element's number (auto id) textstatic String
Creates multiplicity range text.static TextBuilder
createMultiplicityText
(TextBuilder lower, TextBuilder upper, boolean ordered, boolean unique, MultiplicityTextParams textParams, Supplier<TextBuilder> builderFactory) Returns text representation of given multiplicity.static TextBuilder
createMultiplicityText
(TextBuilder lower, TextBuilder upper, ValueSpecification lowerValue, boolean unique, boolean ordered, MultiplicityTextParams textParams, Supplier<TextBuilder> builderFactory) Creates string representation of the provided multiplicity range.static TextBuilder
createMultiplicityText
(MultiplicityElement element, MultiplicityTextParams textParams, Supplier<TextBuilder> builderFactory) Creates text representation of given elementMultiplicityElement
.static String
createMultiplicityText
(Integer lower, Integer upper) Creates multiplicity text.static String
createMultiplicityText
(String lower, String upper, boolean ordered, boolean unique, MultiplicityTextParams textParams) Creates text representation of given multiplicity range.static String
createMultiplicityText
(String lower, String upper, ValueSpecification lowerValue, boolean unique, boolean ordered, MultiplicityTextParams textParams) Creates string representation of the provided multiplicity range.static TextBuilder
createNamedElementListText
(List<? extends NamedElement> elements, Supplier<TextBuilder> builderFactory) Creates representation text for a list of named elements, which contains names separated by a comma.static TextBuilder
createStereotypesText
(Element element, String separator, StereotypeTextParams textParams, Supplier<TextBuilder> builderFactory) Creates string representation of stereotypes that are applied to the provided elementstatic TextBuilder
createStereotypesText
(Collection<Stereotype> stereotypes, String separator, StereotypeTextParams textParams, Supplier<TextBuilder> builderFactory) Creates string representation for the collection ofStereotype
elements.static TextBuilder
createStereotypeText
(Stereotype stereotype, StereotypeTextParams textParams, Supplier<TextBuilder> builderFactory) Creates string representation of the givenStereotype
.static String
createStereotypeText
(String stereotypeName) static TextBuilder
createStringCollectionText
(Collection<String> strings, String separator, Supplier<TextBuilder> builderFactory) Joins stringsstatic TextBuilder
createStyledTypeText
(Type type, boolean showQualifiedName, Supplier<TextBuilder> builderFactory) Creates colored string representation of the givenType
.static TextBuilder
createStyledTypeTextWithSeparator
(Type type, boolean showQualifiedName, Supplier<TextBuilder> builderFactory) Creates colored string representation of the givenType
.static TextBuilder
createTypeText
(Type type, boolean showQualifiedName, Supplier<TextBuilder> builderFactory) Creates string representation of the givenType
.static TextBuilder
createTypeText
(Collection<? extends Type> types, boolean showQualifiedName, Supplier<TextBuilder> builderFactory) Creates string representation of the givenType
elements, separated by comma.static TextBuilder
createValueSpecificationText
(ValueSpecification valueSpecification, boolean addBraces, Supplier<TextBuilder> builderFactory) Creates string representation of the givenValueSpecification
.static <T extends TextBuilder>
TcreateValueSpecificationText
(ValueSpecification valueSpecification, Supplier<T> builderFactory) Creates string representation of the givenValueSpecification
with no braces.static String
createVisibilityText
(VisibilityKind visibility) Returns visibility representation(+, # or -)static boolean
protected static <T> TextBuilder
join
(TextBuilder textBuilder, String delimiter, Stream<T> elements, Function<T, TextBuilder> map) static void
setUseStandardStereotypeChar
(boolean useStandardStereotypeChar)
-
Field Details
-
TYPE_SEPARATOR
- See Also:
-
NEW_LINE_SEPARATOR
- See Also:
-
VALUE_SEPARATOR
- See Also:
-
-
Constructor Details
-
CoreTextCreator
public CoreTextCreator()
-
-
Method Details
-
isUseStandardStereotypeChar
public static boolean isUseStandardStereotypeChar() -
setUseStandardStereotypeChar
public static void setUseStandardStereotypeChar(boolean useStandardStereotypeChar) -
createTypeText
public static TextBuilder createTypeText(Collection<? extends Type> types, boolean showQualifiedName, Supplier<TextBuilder> builderFactory) Creates string representation of the givenType
elements, separated by comma.- Parameters:
types
- collection of typesshowQualifiedName
- true to include type's qualified namebuilderFactory
- providesTextBuilder
to append the created text to- Returns:
- builder with the types' text appended
-
createTypeText
public static TextBuilder createTypeText(Type type, boolean showQualifiedName, Supplier<TextBuilder> builderFactory) Creates string representation of the givenType
.- Parameters:
type
- element to create representation text forshowQualifiedName
- true to include type's qualified namebuilderFactory
- providesTextBuilder
to append the created text to- Returns:
- builder with the type's text appended
-
createStyledTypeText
public static TextBuilder createStyledTypeText(Type type, boolean showQualifiedName, Supplier<TextBuilder> builderFactory) Creates colored string representation of the givenType
.- Parameters:
type
- element to create representation text forshowQualifiedName
- true to include type's qualified namebuilderFactory
- providesTextBuilder
to append the created text to- Returns:
- builder with the type's text appended
-
createStyledTypeTextWithSeparator
public static TextBuilder createStyledTypeTextWithSeparator(Type type, boolean showQualifiedName, Supplier<TextBuilder> builderFactory) Creates colored string representation of the givenType
. Pre-appends CoreTextCreator.TYPE_SEPARATOR- Parameters:
type
- element to create representation text forshowQualifiedName
- true to include type's qualified namebuilderFactory
- providesTextBuilder
to append the created text to- Returns:
- builder with the type's text appended
-
createStringCollectionText
public static TextBuilder createStringCollectionText(Collection<String> strings, String separator, Supplier<TextBuilder> builderFactory) Joins strings- Parameters:
strings
- strings to joinseparator
- symbol(s) to separate each string withbuilderFactory
- providesTextBuilder
to append the created text to- Returns:
- builder with the joined strings appended
-
createNamedElementListText
public static TextBuilder createNamedElementListText(List<? extends NamedElement> elements, 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, Supplier<TextBuilder> builderFactory) Creates string representation of the givenValueSpecification
.- Parameters:
valueSpecification
- element to create representation text foraddBraces
- true to add braces around the value specification textbuilderFactory
- 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, Supplier<T> builderFactory) Creates string representation of the givenValueSpecification
with no braces.- Parameters:
valueSpecification
- element to create representation text forbuilderFactory
- providesTextBuilder
to append the created text to- Returns:
- builder with the value specification's text appended
-
createMultiplicityText
public static String createMultiplicityText(String lower, 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 multiplicityupper
- upper bounds of the multiplicitylowerValue
- value specification element that holds the value of the lower boundsordered
- is orderedunique
- is uniquetextParams
- 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, Supplier<TextBuilder> builderFactory) Creates string representation of the provided multiplicity range.- Parameters:
lower
- lower bounds of the multiplicityupper
- upper bounds of the multiplicitylowerValue
- value specification element that holds the value of the lower boundsordered
- is orderedunique
- is uniquetextParams
- text parameters- Returns:
- builder with the multiplicity's text appended
-
createMultiplicityRangeText
Creates multiplicity range text.- Parameters:
range
- multiplicity range.- Returns:
- multiplicity range string representation.
-
createMultiplicityText
public static String createMultiplicityText(@CheckForNull Integer lower, @CheckForNull 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, Supplier<TextBuilder> builderFactory) Returns text representation of given multiplicity.- Parameters:
lower
- Lower valueupper
- Upper valueordered
- orderedunique
- uniquetextParams
- text parameters- Returns:
- builder with multiplicity's representation or empty string if multiplicity is null.
-
createMultiplicityText
public static String createMultiplicityText(@CheckForNull String lower, @CheckForNull String upper, boolean ordered, boolean unique, MultiplicityTextParams textParams) Creates text representation of given multiplicity range.- Parameters:
lower
- Lower valueupper
- Upper valueordered
- orderedunique
- uniquetextParams
- text parameters- Returns:
- text representation or empty string if multiplicity is null
-
createMultiplicityText
public static TextBuilder createMultiplicityText(@CheckForNull MultiplicityElement element, MultiplicityTextParams textParams, Supplier<TextBuilder> builderFactory) Creates text representation of given elementMultiplicityElement
.- Parameters:
element
- the given multiplicity elementtextParams
- text parametersbuilderFactory
- providesTextBuilder
to append the created text to- Returns:
- builder with the multiplicity text appended
-
join
protected static <T> TextBuilder join(TextBuilder textBuilder, String delimiter, Stream<T> elements, Function<T, TextBuilder> map) -
createVisibilityText
Returns visibility representation(+, # or -)- Parameters:
visibility
- the given visibility.- Returns:
- the char representation of given visibility.
-
createStereotypesText
public static TextBuilder createStereotypesText(Element element, String separator, StereotypeTextParams textParams, Supplier<TextBuilder> builderFactory) Creates string representation of stereotypes that are applied to the provided element- Parameters:
element
- to create representation text forseparator
- symbol(s) to separate each stereotype's text withtextParams
- text parametersbuilderFactory
- providesTextBuilder
to append the created text to- Returns:
- builder with the stereotypes' text appended
-
createStereotypesText
public static TextBuilder createStereotypesText(Collection<Stereotype> stereotypes, String separator, StereotypeTextParams textParams, Supplier<TextBuilder> builderFactory) Creates string representation for the collection ofStereotype
elements.- Parameters:
stereotypes
- collection of stereotypes to create representation text forseparator
- symbol(s) to separate each stereotype's text withtextParams
- configuration that defines what to include in the text of each stereotypebuilderFactory
- providesTextBuilder
to append the created text to- Returns:
- builder with the stereotypes' text appended
-
createStereotypeText
public static TextBuilder createStereotypeText(Stereotype stereotype, StereotypeTextParams textParams, Supplier<TextBuilder> builderFactory) Creates string representation of the givenStereotype
.- Parameters:
stereotype
- element to create representation text fortextParams
- configuration that defines what to include in the text of the stereotypebuilderFactory
- providesTextBuilder
to append the created text to- Returns:
- builder with the stereotype's text appended
-
createStereotypeText
-
containsParentheses
-
createElementNumberText
public static TextBuilder createElementNumberText(Element element, Supplier<TextBuilder> builderFactory) Create the element's number (auto id) text- Parameters:
element
- the element that can be numberedbuilderFactory
- providesTextBuilder
to append the created text to- Returns:
- builder with the number + space at the end or empty string if the number is not available
-