Package org.jetbrains.mps.openapi.model
Class SModelName
- java.lang.Object
-
- org.jetbrains.mps.openapi.model.SModelName
-
public final class SModelName extends Object
Name of a model is complicated matter, we distinguish qualified/long and simple name, namespace fraction, and optional stereotype fraction of it.[ {namespace} '.'] {simple name} [ '@' {stereotype} ]
To avoid use of utility methods scattered around the code that extract certain fractions of the model name, this object gives access to all relevant parts of the name.- Since:
- 3.4
-
-
Constructor Summary
Constructors Constructor Description SModelName(CharSequence qualifiedName, CharSequence stereotype)
SModelName(CharSequence namespace, CharSequence simpleName, CharSequence stereotype)
SModelName(String qualifiedCompleteName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
String
getLongName()
String
getNamespace()
String
getSimpleName()
String
getStereotype()
String
getValue()
int
hashCode()
boolean
hasStereotype()
boolean
isEmpty()
Covers the case when we constructed aSModelReference
withSModelId
only, unaware of actual model name.String
toString()
SModelName
withoutStereotype()
Construct a name with the identical qualified name, and without any stereotype.SModelName
withStereotype(CharSequence newStereotype)
-
-
-
Constructor Detail
-
SModelName
public SModelName(@Nullable CharSequence namespace, @NotNull CharSequence simpleName, @Nullable CharSequence stereotype)
-
SModelName
public SModelName(@NotNull CharSequence qualifiedName, @Nullable CharSequence stereotype)
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Covers the case when we constructed aSModelReference
withSModelId
only, unaware of actual model name.- Returns:
true
iff model name is blank.
-
getValue
@NotNull public String getValue()
- Returns:
- complete name of the model which includes optional namespace part, model name and optional stereotype, such as 'generator' or 'tests', separated by the '@' character e.g. 'jetbrains.mps.sample.generator.main@generator'
-
getLongName
@NotNull public String getLongName()
- Returns:
- qualified model name (namespace and simple name), without stereotype
-
getSimpleName
@NotNull public String getSimpleName()
- Returns:
- name of the model without namespace nor stereotype, empty string iff model name is blank.
-
hasStereotype
public boolean hasStereotype()
- Returns:
true
iffgetStereotype()
would return non-empty value
-
withStereotype
@NotNull public SModelName withStereotype(@Nullable CharSequence newStereotype)
- Parameters:
newStereotype
- stereotype for the constructed name, ornull
to indicate new name shall not specify stereotype (identical towithoutStereotype()
- Returns:
- model name with qualified name identical to this model name and with a given stereotype. May return same instance if new stereotype is the same as actual.
-
withoutStereotype
@NotNull public SModelName withoutStereotype()
Construct a name with the identical qualified name, and without any stereotype. May returnthis
if there's no stereotype in the actual name (SModelName
is immutable).- Returns:
- model name without a stereotype, never
null
-
-