Package com._1c.g5.v8.dt.mcore.util
Class McoreUtil
- java.lang.Object
-
- com._1c.g5.v8.dt.mcore.util.McoreUtil
-
public class McoreUtil extends Object
Utility class containing static methods for working with Mcore objects.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
append(TypedValueList valList, Value val)
Добавить значение к спискуstatic Value
cloneValue(org.eclipse.emf.common.util.EList<Value> values)
Создать ValueList или Value из списка значений для пустого списка возвращает UndefinedValue, для списка, содержащего одно значение, копию этого значения для списка с более чем одним значением, создает ValueList и копирует в него эти значенияstatic boolean
containsType(TypeDescription type, String typeName)
Checks whether the TypeDescription contains the type name or not.static EmptyContextDef
emptyContextDef()
Gets single instance ofEmptyContextDef
static List<TypeItem>
flatTypes(TypeDescription type)
Flats types only, contained in sourceTypeDescription
: Single types and type sets will be copied as is from source to new type list.static List<TypeItem>
flatTypes(List<TypeItem> primaryTypeItems, org.eclipse.emf.ecore.EObject context)
Flats types only from primary type items on selected contextEObject
: Single types and type sets will be copied as is from source to new type list.static List<Field>
getAllFields(FieldSource fieldSource)
Returns all fields provided by the given field source.static String
getEnvironmentText(Environment env)
Function gets localized textual representation of environment.static String
getTypeCategory(TypeItem typeItem)
Returns type category.static String
getTypeCategoryRu(TypeItem typeItem)
Returns the russian type category.static String
getTypeName(TypeItem typeItem)
Returns type name.static String
getTypeNameRu(TypeItem typeItem)
Returns russian type name.static boolean
hasCtor(Type type, int paramCount)
Function determines whether the type contains constructor for specified number of parameters.static boolean
isCompoundType(TypeDescription type)
Compound type is theTypeDescription
which has 2 or more TypeItem.static boolean
isEnum(TypeItem type)
Определить, тип - системное перечисление или нетstatic boolean
isUserDefinedType(List<TypeItem> primaryTypeItems, Set<String> typeCategories)
Determines whether the type set isDefinedType
or characteristic.static TypeDescription
merge(TypeDescription original, TypeDescription other)
Performs merge type descriptionfrom
toto
.static void
mergeValueList(TypedValueList dst, TypedValueList src)
Объединить два ValueList
-
-
-
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 benull
.paramCount
- number of parameters.- Returns:
true
if type contains appropriate ctor for paramCount. Otherwisefalse
.
-
getAllFields
public static List<Field> getAllFields(FieldSource fieldSource)
Returns all fields provided by the given field source.- Parameters:
fieldSource
- notnull
- 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 benull
.- Returns:
- localized textual representation of environment.
Not
null
.
-
merge
public static TypeDescription merge(TypeDescription original, TypeDescription other)
Performs merge type descriptionfrom
toto
. Result is new instance.- Parameters:
original
- the type description to merge data from (notnull
)other
- the type description to merge data to (notnull
)- Returns:
- new type description - merge result (never
null
)
-
isCompoundType
public static boolean isCompoundType(TypeDescription type)
Compound type is theTypeDescription
which has 2 or more TypeItem.- Parameters:
type
- can't benull
- Returns:
true
, if it's compound,false
otherwise.
-
getTypeName
public static String getTypeName(TypeItem typeItem)
Returns type name. If givetypeItem
is proxy, this implementation tries to get name from proxy uri.- Parameters:
typeItem
- theTypeItem
instance (notnull
)- Returns:
- type name or
null
in case the resolution failed.
-
getTypeNameRu
public static String getTypeNameRu(TypeItem typeItem)
Returns russian type name. If givetypeItem
is proxy, this implementation tries to get name from proxy uri.- Parameters:
typeItem
- theTypeItem
instance (notnull
)- Returns:
- type name or
null
in case the resolution failed.
-
getTypeCategory
public static String getTypeCategory(TypeItem typeItem)
Returns type category.- Parameters:
typeItem
- theTypeItem
instance (notnull
).- Returns:
- type category.
-
getTypeCategoryRu
public static String getTypeCategoryRu(TypeItem typeItem)
Returns the russian type category.- Parameters:
typeItem
- theTypeItem
instance, cannot benull
- 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 benull
typeName
- the type name, can benull
- 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 contextEObject
:- 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 benull
context
- the context object, cannot benull
.- Returns:
- the flatten types, cannot be
null
-
isUserDefinedType
public static boolean isUserDefinedType(List<TypeItem> primaryTypeItems, Set<String> typeCategories)
Determines whether the type set isDefinedType
or characteristic. Depends on typeCategories.- Parameters:
primaryTypeItems
- the primary type items, cannot benull
typeCategories
- set of categories considered as user defined types, cannot benull
- Returns:
true
if the type set isDefinedType
or characteristic.
-
flatTypes
public static List<TypeItem> flatTypes(TypeDescription type)
Flats types only, contained in sourceTypeDescription
:- 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 benull
- Returns:
- the flatten types, cannot be
null
-
emptyContextDef
public static EmptyContextDef emptyContextDef()
Gets single instance ofEmptyContextDef
- Returns:
- single instance of
EmptyContextDef
, cannot benull
-
-