Class PathUtil


  • public final class PathUtil
    extends java.lang.Object
    Utility methods for Paths
    Author:
    Richard Smith
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean canAssignObjectToType​(java.lang.Class<?> cls, InterMineObject obj)
      Return true if given type (of a constraint) can be assigned to the InterMineObject - i.e.
      static java.util.Set<java.lang.Object> resolveCollectionPath​(Path path, java.lang.Object o)
      Return the object at the end of a given path, starting from the given object.
      static java.lang.Object resolvePath​(Path path, java.lang.Object o)
      Return the object at the end of a given path, starting from the given object.
      • Methods inherited from class java.lang.Object

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

      • resolvePath

        public static java.lang.Object resolvePath​(Path path,
                                                   java.lang.Object o)
                                            throws PathException
        Return the object at the end of a given path, starting from the given object.
        Parameters:
        path - the path to resolve
        o - the start object
        Returns:
        the attribute, object or collection at the end of the path
        Throws:
        PathException - if the path does not match the object type
      • resolveCollectionPath

        public static java.util.Set<java.lang.Object> resolveCollectionPath​(Path path,
                                                                            java.lang.Object o)
                                                                     throws PathException
        Return the object at the end of a given path, starting from the given object. Works with Collections of objects and reverse references.
        Parameters:
        path - the path to resolve
        o - the start object
        Returns:
        the attribute, object or collection at the end of the path
        Throws:
        PathException - if the path does not match the object type
      • canAssignObjectToType

        public static boolean canAssignObjectToType​(java.lang.Class<?> cls,
                                                    InterMineObject obj)
        Return true if given type (of a constraint) can be assigned to the InterMineObject - i.e. if the class or any superclass of the InterMineObject are the type. Type can be a qualified or unqualified class name.
        Parameters:
        cls - the class in the model that will be assigned to
        obj - the InterMineObject to check
        Returns:
        a boolean