Class ObjectValuePath


  • public class ObjectValuePath
    extends java.lang.Object
    • Constructor Detail

      • ObjectValuePath

        protected ObjectValuePath()
      • ObjectValuePath

        protected ObjectValuePath​(java.lang.String... elements)
    • Method Detail

      • getPath

        public static java.lang.String getPath​(java.lang.String... elements)
        Gets full validation path for specified elements.
        Parameters:
        elements - path elements
        Returns:
        full validation path built with provided path elements
      • getLocaleFromPath

        public static java.lang.String getLocaleFromPath​(java.lang.String path)
        Gets a locale from provided path if it is a path with locale included
        Parameters:
        path - path to be checked
        Returns:
        locale from path or null
      • isLocalizedPath

        public static boolean isLocalizedPath​(java.lang.String path)
        Checks whether provided path is a path with locale included
        Parameters:
        path - path to be checked
        Returns:
        true if path contains locale specification
      • isLocalePath

        public static boolean isLocalePath​(java.lang.String path,
                                           java.lang.String locale)
        Checks whether provided path contains specified locale
        Parameters:
        path - path to be checked
        locale - locale expected
        Returns:
        true if path contains locale specification and it points to locale provided
      • getNotLocalizedPath

        public static java.lang.String getNotLocalizedPath​(java.lang.String path)
        Removes all locale specifications from path.
        Parameters:
        path - path to be cleared
        Returns:
        path with no locale specifications
      • getLocalePath

        public static java.lang.String getLocalePath​(java.lang.String path,
                                                     java.lang.String locale)
        Appends locale specification to provided path.

        Any current locale specification in provided path will be removed.

        Parameters:
        path - path to be decorated
        locale - locale to be added
        Returns:
        path with locale added
      • parse

        public static ObjectValuePath parse​(java.lang.String path)
        Parses provided path
        Parameters:
        path - full path String representation
        Returns:
        parsed path
        See Also:
        buildPath()
      • empty

        public static ObjectValuePath empty()
        Creates an instance of empty path
        Returns:
        empty path
      • unmodifiable

        public static ObjectValuePath unmodifiable​(ObjectValuePath path)
        Creates a reference to provided path that prevents it from changing
        Parameters:
        path - referenced path
        Returns:
        a reference that may not be changed
      • createPath

        protected java.util.List<java.lang.String> createPath​(java.lang.String... elements)
      • isEmpty

        public boolean isEmpty()
        Checks whether path contains any elements
        Returns:
        true if path does not contain any elements
      • size

        public int size()
        Gets number of elements in path
        Returns:
        number of path elements
      • getRoot

        public ObjectValuePath getRoot()
        Get a root of current path.
        Returns:
        root or empty path if no root exists
      • getParent

        public ObjectValuePath getParent()
        Gets a parent path for current.
        Returns:
        parent path or empty path if no parent exists
      • append

        public ObjectValuePath append​(java.lang.String element)
        Adds new element of path at the end of path.

        Method actually changes current path.

        Parameters:
        element - new path element
        Returns:
        current path after change
      • appendPath

        public ObjectValuePath appendPath​(ObjectValuePath path)
        Adds path at the end of path.

        Method actually changes current path.

        Parameters:
        path - new path
        Returns:
        current path after change
      • appendPath

        public ObjectValuePath appendPath​(java.lang.String path)
        Parses provided path and adds it at the end of path.

        Method actually changes current path.

        Parameters:
        path - new path
        Returns:
        current path after change
      • localize

        public ObjectValuePath localize​(java.lang.String locale)
        Adds localization to path

        Method actually changes current path.

        Parameters:
        locale - localization symbol
        Returns:
        current path after change
      • internationalize

        public ObjectValuePath internationalize()
        Removes localization from path

        Method actually changes current path.

        Returns:
        current path after change
      • isLocalized

        public boolean isLocalized()
        Checks whether path contains localization definition
        Returns:
        true if path is localized
      • getLocale

        public java.lang.String getLocale()
        Gets localization code from path
        Returns:
        locale or null if path is not localized
        See Also:
        Locale.getLanguage()
      • prepend

        public ObjectValuePath prepend​(java.lang.String element)
        Adds new path at the beginning of path.

        Method actually changes current path.

        Parameters:
        element - path to be prepended
        Returns:
        current path after change
      • prepend

        public ObjectValuePath prepend​(ObjectValuePath root)
        Adds new path at the beginning of path.

        Method actually changes current path.

        Parameters:
        root - path to be prepended
        Returns:
        current path after change
      • startsWith

        public boolean startsWith​(java.lang.String root)
        Checks whether current path starts with provided
        Parameters:
        root - reference path
        Returns:
        true if current path is relative or equal to provided
      • startsWith

        public boolean startsWith​(ObjectValuePath root)
        Checks whether current path starts with provided
        Parameters:
        root - reference path
        Returns:
        true if current path is relative or equal to provided
      • getRelative

        public ObjectValuePath getRelative​(java.lang.String root)
        Builds new path that should be interpreted as relative to provided
        Parameters:
        root - reference path
        Returns:
        current path as relative to provided
        Throws:
        java.lang.IllegalArgumentException - thrown if current path is not relative to provided
      • getRelative

        public ObjectValuePath getRelative​(ObjectValuePath root)
        Builds new path that should be interpreted as relative to provided
        Parameters:
        root - reference path
        Returns:
        current path as relative to provided
        Throws:
        java.lang.IllegalArgumentException - thrown if current path is not relative to provided
      • split

        public java.lang.String[] split()
        Splits current path to array fo elements
        Returns:
        arrays of elements in path
      • buildPath

        public java.lang.String buildPath()
        Merges all path elements into single String representation
        Returns:
        path representation
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object