Class XdtoUtil


  • public final class XdtoUtil
    extends Object
    Useful method for working with xdto package elements
    • Field Detail

      • PRIMITIVE_TYPE_NAMES

        public static final Set<String> PRIMITIVE_TYPE_NAMES
    • Method Detail

      • isAnonymousType

        public static boolean isAnonymousType​(QName typeName)
        Checks that type corresponding to the QName is anonymous
        Parameters:
        typeName - checking type, can't be null
        Returns:
        true if type corresponding to the QName is anonymous, false otherwise
      • dependencyContains

        public static boolean dependencyContains​(Package xdtoPackage,
                                                 String nsUri)
        Checks that package contains the dependency in import section
        Parameters:
        xdtoPackage - Package checking package, can't be null
        nsUri - looking up dependency uri
        Returns:
        true if dependency was found, false otherwise
      • isEquals

        public static boolean isEquals​(Type type,
                                       QName qname)
        Checks that qname link to the type
        Parameters:
        type - checking Type, can't be null
        qname - checking QName, can be null. In this case false will be returned
        Returns:
        true if qname link to the type, false otherwise
      • getMemberTypes

        public static List<QName> getMemberTypes​(QName qname,
                                                 org.eclipse.xtext.scoping.IScope scope,
                                                 XdtoAdditionalIndexInformationHelper indexHelper)
        Gets merger types of Type corresponding to the qname
        Parameters:
        qname - QName of the Type, can't be null
        scope - IScope contains all xdto types, can't be null
        indexHelper - XdtoAdditionalIndexInformationHelper for getting merger types, can't be null
        Returns:
        list of QName corresponding to the merger types of qname type, or empty list if it doesn't have it
      • getExpandName

        public static String getExpandName​(QName qname)
        Gets expand presentation of QName: "{nsUri} localName"
        Parameters:
        qname - actual QName for getting expand presentation, can't be null
        Returns:
        expand presentation of QName, never null
      • getExpandName

        public static String getExpandName​(String nsUri,
                                           String localName)
        Gets expand presentation by nsUri and local name: "{nsUri} localName"
        Parameters:
        nsUri - actual uri for getting expand presentation, can't be null
        localName - actual local name for getting expand presentation, can't be null
        Returns:
        expand presentation by nsUri and local name, never null
      • getPropertyPresentation

        public static String getPropertyPresentation​(Property property)
        Gets string presentation of Property: localName$Name$Form$ns uri
        Parameters:
        property - Property for getting presentation, can't be null
        Returns:
        string presentation of Property, never null
      • isDescendant

        public static boolean isDescendant​(QName type,
                                           QName childType,
                                           org.eclipse.xtext.scoping.IScope allTypes,
                                           org.eclipse.xtext.naming.IQualifiedNameProvider qualifiedNameProvider,
                                           XdtoAdditionalIndexInformationHelper additionalIndexInformationHelper)
        Checks that type is descendant for childType. Step by step compare type and base types of childType
        Parameters:
        type - comparing type for checking descendant, can't be null
        childType - Type checking for descendant, can't be null
        allTypes - IScope of all available xdto Types, can't be null
        Returns:
        true if type is descendant for childType, false otherwise
      • getPrimitiveType

        public static Type getPrimitiveType​(Type type,
                                            org.eclipse.xtext.scoping.IScope allTypes,
                                            org.eclipse.xtext.naming.IQualifiedNameProvider qualifiedNameProvider,
                                            Version version)
        Gets primitive xdto type corresponding to the type
        Parameters:
        type - Type for getting it primitive type, can't be null
        allTypes - IScope of all available xdto Types, can't be null
        qualifiedNameProvider - actual IQualifiedNameProvider for xdto, can't be null
        version - actual project version, can't be null
        Returns:
        found primitive type or null if it wasn't found
      • isFacetAvailable

        public static boolean isFacetAvailable​(Type primitiveType,
                                               XdtoUtil.FacetKind facetKind)
        Checks that facet of primitive type can be fill
        Parameters:
        primitiveType - checking primitive xdto type, can't be null
        facetKind - type of facet, can't be null
        Returns:
        true if value of facet kind can be set, false otherwise
      • getPropertyName

        public static String getPropertyName​(Property property)
        Gets actual Property name: if Property.getName() is null or empty return name of reference property
        Parameters:
        property - Property for getting name, can't be null
        Returns:
        actual Property name: if Property.getName() is null or empty return name of reference property. Can be null if property and reference property don't have names or there is no refernce property
      • createQName

        public static QName createQName​(String name,
                                        String nsUri)
        Creates QName
        Parameters:
        name - local name for QName, can't be null
        nsUri - ns uri for QName, can't be null
        Returns:
        crteated QName, never null
      • getName

        public static String getName​(org.eclipse.emf.ecore.EObject eObject)
        Gets package model element e-object name.
        Parameters:
        eObject - e-object, cannot be null
        Returns:
        object name or null if not supported