org.eclipse.ocl.examples.domain.utilities
Class DomainUtil

java.lang.Object
  extended by org.eclipse.ocl.examples.domain.utilities.DomainUtil
Direct Known Subclasses:
PivotUtil

public class DomainUtil
extends java.lang.Object


Nested Class Summary
static class DomainUtil.EAnnotationComparator
           
static class DomainUtil.ENamedElementComparator
           
static class DomainUtil.NameableComparator
           
 
Field Summary
static DomainUtil.NameableComparator NAMEABLE_COMPARATOR
           
 
Constructor Summary
DomainUtil()
           
 
Method Summary
static java.lang.String bind(java.lang.String messageTemplate, java.lang.Object... bindings)
           
static java.lang.String convertFromOCLString(java.lang.String javaString)
          Mostly copied from Properties.loadConvert(char[], int, int, char[]) via Strings.convertFromJavaString(java.lang.String, boolean)
static java.lang.String convertToOCLString(java.lang.String theString)
          Mostly copied from Properties.saveConvert(java.lang.String, boolean, boolean) via Strings.convertToJavaString(java.lang.String)
static java.lang.Number createNumberFromString(java.lang.String aValue)
           
static java.lang.String debugEventType(int eventType)
           
static java.lang.String debugFullName(java.lang.Object object)
           
static java.lang.String debugSimpleName(java.lang.Object object)
           
static void formatMultiplicity(java.lang.StringBuilder s, long lower, long upper)
          Append a multiplicity string such as "[1..5]" to a StringBuilder.
static org.eclipse.emf.ecore.EAnnotation getEAnnotation(org.eclipse.emf.ecore.EModelElement eModelElement, java.lang.String sourceURI)
          Return the sourceURI annotation of eModelElement, creating and installing it if required.
static java.lang.String getIndentation(int depth, java.lang.String string)
           
static java.lang.String getLabel(org.eclipse.emf.ecore.EClassifier eClassifier, java.lang.Object object, java.util.Map<java.lang.Object,java.lang.Object> context)
          Return a simple readable description of object.
static java.lang.String getLabel(org.eclipse.emf.ecore.EObject eObject)
          Return a simple readable description of eObject using an IItemLabelProvider if possible.
static DomainType[] getLambdaParameterTypes(DomainLambdaType lambdaType)
           
static
<T extends Nameable>
T
getNamedElement(java.lang.Iterable<T> elements, java.lang.String name)
           
static DomainType[] getOperationParameterTypes(DomainOperation anOperation)
           
static java.lang.String getSafeName(Nameable aNameable)
           
static boolean isRegistered(org.eclipse.emf.ecore.resource.Resource resource)
          Return true if resource is a registered resource; hosting a compile Java model.
static
<T> T
nonNullEMF(T aT)
          Return aT, checking the assertion that this call would not be necessary if EMF had comprehensive @NonNull annotations.
static
<T> T
nonNullModel(T aT)
          Check for an in appropriate model state which should have been detected by a model validation pass.
static
<T> T
nonNullPivot(T aT)
          Return aT, checking the assertion that this call would not be necessary if the Pivot model was guaranteed to be valid.
static
<T> T
nonNullState(T aT)
          Check for an in appropriate program state.
static
<T extends java.lang.Comparable<T>>
int
safeCompareTo(T object, T otherObject)
          Safely determines the relative order of object and otherObject, i.e.
static boolean safeEquals(java.lang.Object object, java.lang.Object otherObject)
          Safely determines whether object equals otherObject, i.e.
static void suppressThrowWarnings()
          Deprecated.  
static char toHex(int nibble)
          Copied from Properties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMEABLE_COMPARATOR

public static final DomainUtil.NameableComparator NAMEABLE_COMPARATOR
Constructor Detail

DomainUtil

public DomainUtil()
Method Detail

bind

@NonNull
public static java.lang.String bind(java.lang.String messageTemplate,
                                            java.lang.Object... bindings)

convertFromOCLString

@NonNull
public static java.lang.String convertFromOCLString(@NonNull
                                                            java.lang.String javaString)
Mostly copied from Properties.loadConvert(char[], int, int, char[]) via Strings.convertFromJavaString(java.lang.String, boolean)


convertToOCLString

public static java.lang.String convertToOCLString(java.lang.String theString)
Mostly copied from Properties.saveConvert(java.lang.String, boolean, boolean) via Strings.convertToJavaString(java.lang.String)


createNumberFromString

@NonNull
public static java.lang.Number createNumberFromString(@NonNull
                                                              java.lang.String aValue)
                                               throws java.lang.NumberFormatException
Throws:
java.lang.NumberFormatException

debugEventType

public static java.lang.String debugEventType(int eventType)

debugFullName

public static java.lang.String debugFullName(java.lang.Object object)

debugSimpleName

public static java.lang.String debugSimpleName(java.lang.Object object)

formatMultiplicity

public static void formatMultiplicity(@NonNull
                                      java.lang.StringBuilder s,
                                      long lower,
                                      long upper)
Append a multiplicity string such as "[1..5]" to a StringBuilder.
Shortforms such as "[?]", "[+]", "[*]", "[1]", "[2..*]" are used if possible.
A -ve upper signals unlimited.


getEAnnotation

@NonNull
public static org.eclipse.emf.ecore.EAnnotation getEAnnotation(@NonNull
                                                                       org.eclipse.emf.ecore.EModelElement eModelElement,
                                                                       java.lang.String sourceURI)
Return the sourceURI annotation of eModelElement, creating and installing it if required.


getLabel

public static java.lang.String getLabel(org.eclipse.emf.ecore.EObject eObject)
Return a simple readable description of eObject using an IItemLabelProvider if possible.


getIndentation

public static java.lang.String getIndentation(int depth,
                                              @NonNull
                                              java.lang.String string)

getLabel

public static java.lang.String getLabel(org.eclipse.emf.ecore.EClassifier eClassifier,
                                        java.lang.Object object,
                                        java.util.Map<java.lang.Object,java.lang.Object> context)
Return a simple readable description of object. If non-null eClassifier identifies the type of object. If non-null context may provide an ESubstitutionLabelProvider.


getLambdaParameterTypes

@NonNull
public static DomainType[] getLambdaParameterTypes(@NonNull
                                                           DomainLambdaType lambdaType)

getNamedElement

public static <T extends Nameable> T getNamedElement(java.lang.Iterable<T> elements,
                                                     java.lang.String name)

getOperationParameterTypes

@NonNull
public static DomainType[] getOperationParameterTypes(@NonNull
                                                              DomainOperation anOperation)

getSafeName

@NonNull
public static java.lang.String getSafeName(@Nullable
                                                   Nameable aNameable)

isRegistered

public static boolean isRegistered(org.eclipse.emf.ecore.resource.Resource resource)
Return true if resource is a registered resource; hosting a compile Java model.


nonNullEMF

@NonNull
public static <T> T nonNullEMF(@Nullable
                                       T aT)
Return aT, checking the assertion that this call would not be necessary if EMF had comprehensive @NonNull annotations.


nonNullModel

@NonNull
public static <T> T nonNullModel(@Nullable
                                         T aT)
Check for an in appropriate model state which should have been detected by a model validation pass. Typical problems that nonNullModel detects are null mandatory model elements.

Return aT, checking the assertion that this call would not be necessary if the Ecore model was guaranteed to be valid.


nonNullPivot

@NonNull
public static <T> T nonNullPivot(@Nullable
                                         T aT)
Return aT, checking the assertion that this call would not be necessary if the Pivot model was guaranteed to be valid.


nonNullState

@NonNull
public static <T> T nonNullState(@Nullable
                                         T aT)
Check for an in appropriate program state. This should not happen, but is not impossible. For instance a Resource should be contained in a ResourceSet, but that doesn;t mean it always is.

If the inappropriate state really cannot happen, an assertion should be used instead to avoid non-debug run-time cost.

Return aT, throwing an IllegalStateException if null.


safeCompareTo

public static <T extends java.lang.Comparable<T>> int safeCompareTo(@Nullable
                                                                    T object,
                                                                    @Nullable
                                                                    T otherObject)
Safely determines the relative order of object and otherObject, i.e. without throwing an exception if object is null.


safeEquals

public static boolean safeEquals(@Nullable
                                 java.lang.Object object,
                                 @Nullable
                                 java.lang.Object otherObject)
Safely determines whether object equals otherObject, i.e. without throwing an exception if object is null.

Parameters:
object - The first object to compare.
otherObject - The second object to compare.
Returns:
true if object equals otherObject; false otherwise.

suppressThrowWarnings

@Deprecated
public static void suppressThrowWarnings()
Deprecated. 

This dummy function may be invoked from auto-generated code that does not throw an exception to avoid a compilation error.

Throws:
InvalidValueException

toHex

public static char toHex(int nibble)
Copied from Properties