Class AggregateUtil


  • public class AggregateUtil
    extends Object
    operations to aggregates or arrays
    • Constructor Detail

      • AggregateUtil

        public AggregateUtil()
    • Method Detail

      • findSeparator

        public static int findSeparator​(String s)
        finds the first occurrence of . or [ after the last /
        Parameters:
        s -
        Returns:
        the position of the first occurrence of . or [ after the last slash; returns -1 if not found
      • parseReference

        public static PathElement[] parseReference​(String name)
        parses a reference of shape
         x.y[3][4].z
         
        into an array of PathElement
        Parameters:
        name -
        Returns:
      • verifyPath

        public static boolean verifyPath​(ParameterType parameterType,
                                         PathElement[] path)
        Verify that the path exists in the parameter type
        Parameters:
        parameterType -
        path -
        Returns:
      • extractMember

        public static PartialParameterValue extractMember​(ParameterValue pv,
                                                          PathElement[] path)
        Create a parameter value with a member from the passed parameter value as found following the path. Returns null if there is no such member.
        Parameters:
        pv -
        path -
        Returns:
      • updateMember

        public static void updateMember​(ParameterValue pv,
                                        PartialParameterValue patch)
        Patches a parameter value with a new value for one member of an aggregate or array Currently this does not extend an array
        Parameters:
        pv -
        patch -
        Throws:
        IllegalArgumentException - if the member to be updated or the array element does not exist
      • getMemberValue

        public static Value getMemberValue​(Value value,
                                           PathElement[] path)
        This function is used to retrieve values from hierarchical aggregates. It is equivalent with a chain of getMemberValue() calls:
           getMemberValue(getMemberValue(getMemberValue(value, path[0]),path[1])...,path[n])
         
        It returns null if the path does not lead to a valid aggregate member.
        Parameters:
        path - - the path to be traversed, can be empty.
        Returns:
        the member value found by traversing the path or null if no such member exists. In case the path is empty, this value itself will be returned.