Class DescriptorUtils


  • public final class DescriptorUtils
    extends java.lang.Object
    Author:
    Alex Kalderimis
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<ClassDescriptor> findCommonClasses​(java.util.Collection<ClassDescriptor> classes)
      Return a list of the classes which present in the inheritance tree of all the given classes.
      static ClassDescriptor findIntersectionType​(java.util.Collection<ClassDescriptor> classes)
      Find the ClassDescriptor for the type that any two or more objects must be of where those objects are randomly selected from a collection containing objects which are of the types represented by the class descriptors in the provided collection.
      static ClassDescriptor findSumType​(java.util.Collection<ClassDescriptor> classes)
      Find the ClassDescriptor for the type that any random element selected from a collection of objects must be an instance of, where each object is an instance of one of the classes represented by the class descriptors in the input collection.
      • Methods inherited from class java.lang.Object

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

      • findSumType

        public static ClassDescriptor findSumType​(java.util.Collection<ClassDescriptor> classes)
                                           throws MetaDataException
        Find the ClassDescriptor for the type that any random element selected from a collection of objects must be an instance of, where each object is an instance of one of the classes represented by the class descriptors in the input collection. This method does not consider any of the sub-types of the classes in question. eg:
        Given [Employee, Manager, CEO]
        returns Employee
        Given [CEO, Company]
        returns HasAddress
        Given [HasAddress, Employable]
        throws an exception
        Given []
        throws an exception
        Parameters:
        classes - The classes to consider.
        Returns:
        The lowest common denominator.
        Throws:
        MetaDataException - if no such type exists.
      • findIntersectionType

        public static ClassDescriptor findIntersectionType​(java.util.Collection<ClassDescriptor> classes)
                                                    throws MetaDataException
        Find the ClassDescriptor for the type that any two or more objects must be of where those objects are randomly selected from a collection containing objects which are of the types represented by the class descriptors in the provided collection. In the case where the classes given share a common super type, but do not themselves contain it, then that super type is returned. Where the classes present a lineage (eg. Employee → Manager → CEO then the bottom of the lineage is returned. For cases where the type structure contains a lineage that branches (eg. Thing → Employable → [Employee, Contractor] the bottom of the lineage before the branch (the last common ancestor) will be returned.
        Parameters:
        classes - The classes to consider.
        Returns:
        The most specific common type.
        Throws:
        MetaDataException - If no such type exists.
      • findCommonClasses

        public static java.util.List<ClassDescriptor> findCommonClasses​(java.util.Collection<ClassDescriptor> classes)
                                                                 throws MetaDataException
        Return a list of the classes which present in the inheritance tree of all the given classes. If more than one is returned, they will be sorted so that the most specific one is at the head of the list. ie:, given Employee, Manager, CEO, this method should return a list such as Employee, Employable, HasAddress, Thing. The returned list should never contain InterMineObject. All returned classes are guaranteed to be subclasses of InterMineObject. The returned list is guaranteed to never be empty.
        Parameters:
        classes - The classes to investigate.
        Returns:
        A liat of classes common to the inheritance tree of all of them.
        Throws:
        MetaDataException - If