Class Utils


  • public class Utils
    extends java.lang.Object
    Some public utility methods.
    Author:
    Holger Eichelberger
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Utils.SplitResult
      The result of splitting a contents object.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Utils()
      Prevents this class from being instantiated from outside.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static void alreadyDefinedError​(java.lang.String name, org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EStructuralFeature feature)
      Emits an already defined error.
      private static <T> java.util.List<T> assign​(java.util.List<T> list, java.lang.Object element, java.lang.Class<T> type)
      Helper function to assign the element to list if element is of type type and to create list if not defined before.
      (package private) static void assignComments​(net.ssehub.easy.varModel.model.StructuredComment target, java.util.List<?> elements, java.util.List<net.ssehub.easy.varModel.model.Comment> comments, net.ssehub.easy.varModel.model.IModelElement parent)
      Assigns the comments in comments to the corresponding model elements in elements.
      (package private) static void checkDefaultParamSequence​(de.uni_hildesheim.sse.ivml.OpDefStatement op, net.ssehub.easy.varModel.model.DecisionVariableDeclaration[] param, net.ssehub.easy.dslCore.translation.MessageReceiver receiver)
      Checks the sequence of default and non-default parameters.
      (package private) static net.ssehub.easy.varModel.model.StructuredComment createStructuredComment​(org.eclipse.emf.ecore.EObject object, TypeContext context, java.util.List<net.ssehub.easy.varModel.model.Comment> comments)
      Creates a structured comment for the given object in context depending on the contents of comments, i.e.
      static java.lang.String getQualifiedNameString​(de.uni_hildesheim.sse.ivml.QualifiedName name)
      Returns a string representing a qualified name.
      static java.lang.String getQualifiedNameString​(de.uni_hildesheim.sse.ivml.QualifiedName name, de.uni_hildesheim.sse.ivml.AccessName aName)
      Returns a string representing a qualified name.
      static boolean isImportResolutionEnabled()
      Returns whether the import resolution shall be enabled.
      static <T> java.util.List<T> select​(java.util.List<org.eclipse.emf.ecore.EObject> list, java.lang.Class<T> type)
      Selects those elements out of list which are an instance of type.
      (package private) static void setAnnotations​(de.uni_hildesheim.sse.ivml.OpDefStatement op, net.ssehub.easy.varModel.model.datatypes.CustomOperation operation, net.ssehub.easy.varModel.model.Project project, net.ssehub.easy.dslCore.translation.MessageReceiver receiver)
      Defines the annotations for an operation and validates them for the given operation.
      static Utils.SplitResult split​(java.util.List<org.eclipse.emf.ecore.EObject> elements)
      Splits the now heterogeneous list of elements in elements into individual lists stored in the result instance.
      static void split​(java.util.List<org.eclipse.emf.ecore.EObject> elements, Utils.SplitResult result)
      Splits the now heterogeneous list of elements in elements into individual lists stored in result instance.
      static java.lang.String toString​(de.uni_hildesheim.sse.ivml.VariableDeclaration varDecl)
      Turns the declared variable names of the varDecl into a string.
      (package private) static java.lang.String toString​(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclarationPart> parts)
      Turns variable declaration parts into strings for debugging.
      (package private) static java.lang.String unqualified​(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
      Returns the unqualified name of type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Utils

        private Utils()
        Prevents this class from being instantiated from outside.
    • Method Detail

      • getQualifiedNameString

        public static java.lang.String getQualifiedNameString​(de.uni_hildesheim.sse.ivml.QualifiedName name)
        Returns a string representing a qualified name. (May change in future to structured qualified names.)
        Parameters:
        name - the qualified name
        Returns:
        the corresponding string representation
      • getQualifiedNameString

        public static java.lang.String getQualifiedNameString​(de.uni_hildesheim.sse.ivml.QualifiedName name,
                                                              de.uni_hildesheim.sse.ivml.AccessName aName)
        Returns a string representing a qualified name. (May change in future to structured qualified names.)
        Parameters:
        name - the qualified name
        aName - optional access to a compound (may be null)
        Returns:
        the corresponding string representation
      • select

        public static <T> java.util.List<T> select​(java.util.List<org.eclipse.emf.ecore.EObject> list,
                                                   java.lang.Class<T> type)
        Selects those elements out of list which are an instance of type.
        Type Parameters:
        T - the type of elements to be selected
        Parameters:
        list - the list to select from
        type - the type to select upon
        Returns:
        a list of elements which are an instance of type
      • assign

        private static <T> java.util.List<T> assign​(java.util.List<T> list,
                                                    java.lang.Object element,
                                                    java.lang.Class<T> type)
        Helper function to assign the element to list if element is of type type and to create list if not defined before.
        Type Parameters:
        T - the type of elements to be processed
        Parameters:
        list - the list to insert element into
        element - the element to be inserted
        type - the type to check for
        Returns:
        list or a new list including element if type matches
      • split

        public static Utils.SplitResult split​(java.util.List<org.eclipse.emf.ecore.EObject> elements)
        Splits the now heterogeneous list of elements in elements into individual lists stored in the result instance.
        Parameters:
        elements - the elements to split
        Returns:
        the result instance
      • split

        public static void split​(java.util.List<org.eclipse.emf.ecore.EObject> elements,
                                 Utils.SplitResult result)
        Splits the now heterogeneous list of elements in elements into individual lists stored in result instance.
        Parameters:
        elements - the elements to split
        result - the result instance to be modified as a side effect
      • isImportResolutionEnabled

        public static final boolean isImportResolutionEnabled()
        Returns whether the import resolution shall be enabled. This method is legacy and was created while the editor was in an early stage. Please check and remove if adequate.
        Returns:
        true if import resolution is enabled, false else
      • toString

        public static java.lang.String toString​(de.uni_hildesheim.sse.ivml.VariableDeclaration varDecl)
        Turns the declared variable names of the varDecl into a string. [debugging]
        Parameters:
        varDecl - the variable declaration
        Returns:
        the names of the declared variables
      • unqualified

        static java.lang.String unqualified​(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
        Returns the unqualified name of type.
        Parameters:
        type - the type
        Returns:
        the unqualified name
      • createStructuredComment

        static net.ssehub.easy.varModel.model.StructuredComment createStructuredComment​(org.eclipse.emf.ecore.EObject object,
                                                                                        TypeContext context,
                                                                                        java.util.List<net.ssehub.easy.varModel.model.Comment> comments)
        Creates a structured comment for the given object in context depending on the contents of comments, i.e. whether there are comments or not.
        Parameters:
        object - the EObject to create the comment for
        context - the type context to assign the created context to
        comments - the comments to consider
        Returns:
        the created comment object or null
      • assignComments

        static void assignComments​(net.ssehub.easy.varModel.model.StructuredComment target,
                                   java.util.List<?> elements,
                                   java.util.List<net.ssehub.easy.varModel.model.Comment> comments,
                                   net.ssehub.easy.varModel.model.IModelElement parent)
        Assigns the comments in comments to the corresponding model elements in elements.
        Parameters:
        target - the structured comment to store the mapping in
        elements - the elements to be assigned to the comments
        comments - the comments (must be of same size)
        parent - the explicit parent element of the comments
      • setAnnotations

        static void setAnnotations​(de.uni_hildesheim.sse.ivml.OpDefStatement op,
                                   net.ssehub.easy.varModel.model.datatypes.CustomOperation operation,
                                   net.ssehub.easy.varModel.model.Project project,
                                   net.ssehub.easy.dslCore.translation.MessageReceiver receiver)
        Defines the annotations for an operation and validates them for the given operation.
        Parameters:
        op - the defining operation statement
        operation - the translated IVML operation
        project - the actual project
        receiver - the message receiver for warnings and errors
      • checkDefaultParamSequence

        static void checkDefaultParamSequence​(de.uni_hildesheim.sse.ivml.OpDefStatement op,
                                              net.ssehub.easy.varModel.model.DecisionVariableDeclaration[] param,
                                              net.ssehub.easy.dslCore.translation.MessageReceiver receiver)
        Checks the sequence of default and non-default parameters.
        Parameters:
        op - the operation declaration
        param - the parameters to check
        receiver - the message receiver for warnings and errors
      • alreadyDefinedError

        static void alreadyDefinedError​(java.lang.String name,
                                        org.eclipse.emf.ecore.EObject object,
                                        org.eclipse.emf.ecore.EStructuralFeature feature)
                                 throws net.ssehub.easy.dslCore.translation.TranslatorException
        Emits an already defined error.
        Parameters:
        name - the already defined name
        object - the causing Ecore object
        feature - the causing feature
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - the corresponding exception always
      • toString

        static java.lang.String toString​(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclarationPart> parts)
        Turns variable declaration parts into strings for debugging.
        Parameters:
        parts - the parts
        Returns:
        the names