Class McoreUtil


  • public class McoreUtil
    extends Object
    Utility class containing static methods for working with Mcore objects.
    • Method Detail

      • hasCtor

        public static boolean hasCtor​(Type type,
                                      int paramCount)
        Function determines whether the type contains constructor for specified number of parameters.
        Parameters:
        type - Type in question. Can't be null.
        paramCount - number of parameters.
        Returns:
        true if type contains appropriate ctor for paramCount. Otherwise false.
      • getAllFields

        public static List<Field> getAllFields​(FieldSource fieldSource)
        Returns all fields provided by the given field source.
        Parameters:
        fieldSource - not null
        Returns:
        all fields provided by the given field source (never null)
      • getEnvironmentText

        public static String getEnvironmentText​(Environment env)
        Function gets localized textual representation of environment.
        Parameters:
        env - environment. Can't be null.
        Returns:
        localized textual representation of environment. Not null.
      • merge

        public static TypeDescription merge​(TypeDescription original,
                                            TypeDescription other)
        Performs merge type description from to to. Result is new instance.
        Parameters:
        original - the type description to merge data from (not null)
        other - the type description to merge data to (not null)
        Returns:
        new type description - merge result (never null)
      • isCompoundType

        public static boolean isCompoundType​(TypeDescription type)
        Compound type is the TypeDescription which has 2 or more TypeItem.
        Parameters:
        type - can't be null
        Returns:
        true, if it's compound,false otherwise.
      • getTypeName

        public static String getTypeName​(TypeItem typeItem)
        Returns type name. If give typeItem is proxy, this implementation tries to get name from proxy uri.
        Parameters:
        typeItem - the TypeItem instance (not null)
        Returns:
        type name or null in case the resolution failed.
      • getTypeNameRu

        public static String getTypeNameRu​(TypeItem typeItem)
        Returns russian type name. If give typeItem is proxy, this implementation tries to get name from proxy uri.
        Parameters:
        typeItem - the TypeItem instance (not null)
        Returns:
        type name or null in case the resolution failed.
      • getTypeCategory

        public static String getTypeCategory​(TypeItem typeItem)
        Returns type category.
        Parameters:
        typeItem - the TypeItem instance (not null).
        Returns:
        type category.
      • getTypeCategoryRu

        public static String getTypeCategoryRu​(TypeItem typeItem)
        Returns the russian type category.
        Parameters:
        typeItem - the TypeItem instance, cannot be null
        Returns:
        type category, never null
      • containsType

        public static boolean containsType​(TypeDescription type,
                                           String typeName)
        Checks whether the TypeDescription contains the type name or not.
        Parameters:
        type - the type description, can be null
        typeName - the type name, can be null
        Returns:
        true if type description has the given type name
      • isEnum

        public static boolean isEnum​(TypeItem type)
        Определить, тип - системное перечисление или нет
        Parameters:
        type - тип
        Returns:
        истина, если системное перечисление
      • cloneValue

        public static Value cloneValue​(org.eclipse.emf.common.util.EList<Value> values)
        Создать ValueList или Value из списка значений для пустого списка возвращает UndefinedValue, для списка, содержащего одно значение, копию этого значения для списка с более чем одним значением, создает ValueList и копирует в него эти значения
        Parameters:
        values - список значений
        Returns:
        результирующий ValueList или Value
      • mergeValueList

        public static void mergeValueList​(TypedValueList dst,
                                          TypedValueList src)
        Объединить два ValueList
        Parameters:
        dst - первый список и результат
        src - второй список
      • append

        public static void append​(TypedValueList valList,
                                  Value val)
        Добавить значение к списку
        Parameters:
        valList - список
        val - значение
      • flatTypes

        public static List<TypeItem> flatTypes​(List<TypeItem> primaryTypeItems,
                                               org.eclipse.emf.ecore.EObject context)
        Flats types only from primary type items on selected context EObject:
        • Single types and type sets will be copied as is from source to new type list.
        • If type set is DefinedType or characteristic then will be flatten to types and merges with existing types.
        Parameters:
        primaryTypeItems - the primary type items, cannot be null
        context - the context object, cannot be null.
        Returns:
        the flatten types, cannot be null
      • isUserDefinedType

        public static boolean isUserDefinedType​(List<TypeItem> primaryTypeItems,
                                                Set<String> typeCategories)
        Determines whether the type set is DefinedType or characteristic. Depends on typeCategories.
        Parameters:
        primaryTypeItems - the primary type items, cannot be null
        typeCategories - set of categories considered as user defined types, cannot be null
        Returns:
        true if the type set is DefinedType or characteristic.
      • flatTypes

        public static List<TypeItem> flatTypes​(TypeDescription type)
        Flats types only, contained in source TypeDescription:
        • Single types and type sets will be copied as is from source to new type list.
        • If type set is DefinedType or characteristic then will be flatten to types and merges with existing types.
        Parameters:
        type - the type, cannot be null
        Returns:
        the flatten types, cannot be null