Class Functions


  • public class Functions
    extends Object
    This class implements a whole slew of java.util.function implementations, which can be used as a hack to get streams working in Beanshell.

    This can simplify code enormously.

    For example, you could do something like:

    someMethod(Object item) { // Beanshell function that does something interesting with the item }

    // Creates a Consumer that invokes the specified Beanshell method someMethodFunction = Functions.c(this, “someMethod”);

    list.forEach(someMethodFunction);

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Function<sailpoint.object.ProvisioningPlan,​Stream<sailpoint.object.ProvisioningPlan.AccountRequest>> accountRequests()
      A flatMap() function to extract the account requests from a plan
      static <T> Predicate<T> alwaysFalse()
      Returns a predicate that is always false
      static <T> Predicate<T> alwaysTrue()
      Returns a predicate that is always true
      static <T> Consumer<T> appendTo​(List<? super T> values)
      Returns a Consumer that will append all inputs to the given List.
      static <T> Consumer<T> appendTo​(Set<? super T> values)
      Returns a Consumer that will append all inputs to the given List.
      static Predicate<? extends sailpoint.object.SailPointObject> attributeEquals​(String attributeName, Object testValue)
      Creates a Predicate that resolves to true if the given attribute on the argument resolves to the given value.
      static Function<sailpoint.object.ProvisioningPlan.AccountRequest,​Stream<sailpoint.object.ProvisioningPlan.AttributeRequest>> attributeRequests()
      Creates a flatMap() stream to extract attribute requests from an account request
      static Predicate<? extends sailpoint.object.SailPointObject> attributeSame​(String attributeName, Object testValue)
      Create a Predicate that resolves to true if the given attribute value is the same (per Sameness) as the given test value.
      static BiConsumer<?,​?> bc​(bsh.This bshThis, String methodName)
      Creates a BiConsumer that invokes the given Beanshell method, passing the inputs to the consumer.
      static Class<?> box​(Class<?> prim)
      Returns the ‘boxed’ class corresponding to the given primitive.
      static Functions.ConsumerWithError<Object> c​(bsh.This bshThis, String methodName)
      Creates a Consumer that passes each input to the given beanshell method in the given namespace.
      static Functions.ConsumerWithError<Object> c​(String methodName)
      Creates a Consumer to invoke a method on each input.
      static Functions.ConsumerWithError<Object> c​(String methodName, Object... inputs)
      Creates a Consumer to invoke a method on an object passed to it.
      static <T> Function<Object,​T> cast​(Class<T> target)
      Returns a function that will cast the input object to the given type or throw a ClassCastException.
      static Comparator<Object> comparator​(bsh.This bshThis, String methodName)
      Creates a Comparator that directly passes the two input objects to the given Beanshell method.
      static Comparator<Object> comparator​(String property)
      Returns a Comparator that extracts the given property (by path) from the two input objects, then compares them.
      static Comparator<Object> comparator​(String property, bsh.This bshThis, String methodName)
      Creates a Comparator that extracts the given property from the two input objects, then passes them both to the given Beanshell method, which must return an appropriate Comparator integer result.
      static Functions.ConsumerWithError<Object> cs​(Class<?> sourceType, String methodName)
      Creates a Consumer that invokes the given static method on the given class for each input object.
      static Functions.ConsumerWithError<Object> cs​(Class<?> sourceType, String methodName, Object param1)
      Creates a Consumer that invokes the given static method on the given class for each input object, passing the object as the first method parameter and the given param1 as the second.
      static Functions.ConsumerWithError<Object> cs​(Class<?> sourceType, String methodName, Object param1, Object param2)
      Creates a Consumer that invokes the given static method on the given class for each input object, passing the object as the first method parameter, the given param1 as the second, and the given param2 as the third.
      static <T> Consumer<T> debug()
      Logs whatever is passed in at debug level, if the logger has debug enabled
      static <T> Consumer<T> debug​(org.apache.commons.logging.Log logger)
      Logs whatever is passed in at debug level, if the logger has debug enabled
      static <T extends sailpoint.tools.xml.AbstractXmlObject>
      Consumer<T>
      debugXml()
      Logs the input as XML, useful with peek() in a stream.
      static <T extends sailpoint.tools.xml.AbstractXmlObject>
      Consumer<T>
      debugXml​(org.apache.commons.logging.Log logger)
      Logs the input as XML, useful with peek() in a stream
      static Predicate<String> endsWith​(String suffix)
      Creates a Predicate that returns true if the input string ends with the given suffix
      static <K,​T>
      Predicate<K>
      eq​(Function<K,​T> valueExtractor, Object testValue)
      Returns a Predicate that returns true if the extracted value from the input is equal (in a null-safe way) to the test value.
      static <T> Predicate<? extends T> eq​(T value)
      Returns a Predicate that returns true if the two values are null-safe equals.
      static Predicate<String> eqIgnoreCase​(String value)
      Returns a Predicate that resolves to true when tested against an object that is equal to the input to this method.
      static Function<String,​Optional<String>> extractRegexMatchGroup​(String regex, int matchGroup)
      Returns a function that extracts the Nth matching group from applying the regular expression to the input string.
      static Function<Object,​Object> f​(bsh.This bshThis, String methodName)
      Creates a Function that invokes the named Beanshell method, passing the input object as its parameter, and returning the method’s return value.
      static <B> Function<Object,​B> f​(bsh.This bshThis, String methodName, Class<B> expectedResult, Object... parameters)
      Creates a Function that invokes the named Beanshell method, passing the input object as its parameter, and returning the method’s return value.
      static <T> Function<Object,​T> f​(Object target, String methodName, Class<T> expectedType)
      Creates a Function that invokes the named method on the given target object, passing the input item as its parameter.
      static <K> Function<K,​Object> f​(String methodName)
      Type-free version of f(String, Class)
      static <K,​T>
      Function<K,​T>
      f​(String methodName, Class<T> expectedType)
      Creates a Function that invokes the given method on the input object, and returns the output of that method.
      static <K,​T>
      Function<K,​T>
      f​(String methodName, Class<T> expectedType, Object... parameters)
      Creates a Function that invokes the given method on the input object, and returns the output of that method.
      static <K> Function<K,​Object> f​(String methodName, Object... parameters)
      Type-free version of f(String, Class, Object...)
      static Method findMethod​(Class<?> toSearch, String name, boolean findStatic, Object... params)
      Finds the most specific accessible Method on the given Class that accepts the parameters provided.
      static Function<sailpoint.object.ProvisioningPlan,​List<sailpoint.object.ProvisioningPlan.AccountRequest>> findRequests​(String application)
      Transforms a provisioning plan into a list of requests for the given application
      static Function<sailpoint.object.ProvisioningPlan,​List<sailpoint.object.ProvisioningPlan.AccountRequest>> findRequests​(sailpoint.object.ProvisioningPlan.AccountRequest.Operation operation)
      Transforms a provisioning plan into a list of requests with the given operation
      static <T> void forEach​(Collection<T> values, Consumer<T> consumer)
      Runs the given consumer for each item in the collection
      static <A> void forEach​(Iterator<A> values, Consumer<A> consumer)
      Runs the given consumer for each remaining item returned by the Iterator
      static <A,​B>
      void
      forEach​(Map<A,​B> values, BiConsumer<A,​B> consumer)
      Runs the given bi-consumer for all of the values in the map
      static <A,​B>
      void
      forEach​(Map<A,​B> values, Consumer<Map.Entry<A,​B>> consumer)
      Runs the given consumer for each entry in the map
      static <T> Function<Object,​T> fs​(Class<?> targetClass, String methodName, Class<T> expectedType)
      Invokes the named static function on the given class, passing the input object to it.
      static <In,​Out>
      Supplier<Out>
      ftoc​(In inputObject, Function<? super In,​? extends Out> function)
      Constructs a Supplier that ‘curries’ the given Function, applying it to the input object and returning the result.
      static <T> Function<Object,​T> get​(Class<T> expectedType, String beanPath)
      Functionally implements the Utilities.getProperty(Object, String) method.
      static Function<Object,​Object> get​(String beanPath)
      Functionally implements the Utilities.getProperty(Object, String) method
      static Function<? extends sailpoint.object.SailPointObject,​Object> getAttribute​(String attributeName)
      If the input object has Attributes, retrieves the attribute with the given name, otherwise returns null.
      static Function<? extends sailpoint.object.SailPointObject,​Boolean> getBooleanAttribute​(String attributeName)
      Extracts a boolean attribute from the input object, or false if the attribute is not present.
      static Function<? extends sailpoint.object.SailPointObject,​Boolean> getBooleanAttribute​(String attributeName, boolean defaultValue)
      Extracts a boolean attribute from the input object, or the default value if the attribute is not present.
      static Function<sailpoint.object.Identity,​List<sailpoint.object.IdentityEntitlement>> getEntitlements​(sailpoint.api.SailPointContext context, sailpoint.object.Filter optionalFilter)
      Extracts the list of entitlements from the given Identity object, optionally filtering them with the filter if provided.
      static Function<sailpoint.object.Identity,​List<sailpoint.object.Link>> getLinks()
      Gets all links associated with the given Identity.
      static Function<sailpoint.object.Identity,​List<sailpoint.object.Link>> getLinks​(String applicationName, String... moreApplicationNames)
      Gets all links associated with the given Identity on the given Application(s).
      static Function<sailpoint.object.Identity,​List<sailpoint.object.Link>> getLinks​(sailpoint.object.Application application)
      Gets all links associated with the given Identity on the given Application
      static Function<? extends sailpoint.object.SailPointObject,​String> getStringAttribute​(String attributeName)
      Gets the given attribute as a string from the input object
      static Function<? extends sailpoint.object.SailPointObject,​List<String>> getStringListAttribute​(String attributeName)
      Gets the given attribute as a string list from the input object
      static Predicate<sailpoint.object.ProvisioningPlan.AccountRequest> hasAllAttributeRequest​(String... attributeName)
      Returns a Predicate that resolves to true if the input AccountRequest has at least one AttributeRequest corresponding to every one of the attribute names given
      static Predicate<sailpoint.object.ProvisioningPlan.AccountRequest> hasAnyAttributeRequest​(String... attributeName)
      Returns a Predicate that resolves to true if the input AccountRequest has at least one AttributeRequest corresponding to any of the attribute names given
      static Predicate<? extends sailpoint.object.SailPointObject> hasAttribute​(String attributeName)
      Resolves to true if the input object has a non-null value for the given attribute
      static Predicate<sailpoint.object.ProvisioningPlan.AccountRequest> hasAttributeRequest​(boolean useAnd, String... attributeName)
      Returns a predicate that resolves to true if the account request has the attribute(s) in question, controlled by the ‘useAnd’ parameter.
      static Function<? extends sailpoint.object.SailPointObject,​String> id()
      Resolves to the ID of the input SailPointObject
      static Predicate<?> in​(List<String> list)
      Resolves to true if the input object is in the given list
      static Predicate<?> in​(Set<String> list)
      Resolves to true if the input object is in the given set
      static boolean isAssignableFrom​(Class<?> targetType, Class<?> otherType)
      Returns true if targetType is assignable from otherType, e.g.
      static Predicate<? extends sailpoint.object.SailPointObject> isBooleanAttribute​(String attributeName)
      A predicate that resolves to true if the boolean attribute of the input object is true according to Attributes.getBoolean(String).
      static Predicate<? extends sailpoint.object.SailPointObject> isBooleanAttribute​(String attributeName, boolean defaultValue)
      A predicate that resolves to true if the boolean attribute of the input object is true according to Attributes.getBoolean(String, boolean).
      static Predicate<? extends sailpoint.object.SailPointObject> isBooleanProperty​(String attributeName)
      A predicate that resolves to true if the boolean property of the input object is true according to Util.otob(Object)
      static Predicate<? extends sailpoint.object.SailPointObject> isBooleanProperty​(String attributeName, boolean defaultValue)
      A predicate that resolves to true if the boolean property of the input object is true according to Util.otob(Object)
      static <T extends sailpoint.object.SailPointObject>
      Predicate<T>
      isDisabled()
      A predicate that resolves to true if the input is disabled.
      static <T> Predicate<T> isEmpty()
      Returns a predicate that resolves to true if the input is empty according to Sameness
      static <T> Predicate<T> isInstanceOf​(Class<?> target)
      Resolves to true if the input object is an instance of the target class.
      static Predicate<sailpoint.object.Link> isNativeIdentity​(String nativeIdentity)
      Returns a Predicate that resolves to true if the input Link’s native identity is equal to the comparison value.
      static Predicate<String> isNotNullOrEmpty()  
      static <T> Predicate<T> isNull()
      Resolves to true if the object is not null
      static Predicate<String> isNullOrEmpty()
      Functional equivalent to Util.isNullOrEmpty
      static <T> Predicate<T> isNullOrEmpty​(String propertyPath)
      Resolves to true if the given property on the given object is not null or empty.
      static <T> Function<Map.Entry<T,​?>,​T> key()
      Extracts the key from the given map entry
      static Predicate<? extends String> like​(String pattern, sailpoint.object.Filter.MatchMode matchMode)
      Returns a Predicate that resolves to true if the input string matches the given pattern, as equivalent to the Filter like() method
      static Function<sailpoint.object.Link,​sailpoint.object.Identity> linkGetIdentity()
      Returns the Identity for the given Link object
      static Predicate<sailpoint.object.Link> linkIsApplication​(String applicationName)
      Creates a predicate that tests whether the Link has the given application name
      static Predicate<sailpoint.object.Link> linkIsApplication​(sailpoint.object.Application application)
      Creates a predicate that tests whether the Link has the given application name.
      static <T> Function<List<T>,​T> listSafeGet​(int index)
      Returns a functional getter for a map of a given type
      static <T> Consumer<T> log()
      Logs the input object at warn() level in the default Functions logger.
      static <T> Consumer<T> log​(org.apache.commons.logging.Log logger)
      Logs the input object at warn() level in the provided logger This is intended for use with peek() in the middle of a stream.
      static <T extends sailpoint.tools.xml.AbstractXmlObject>
      Consumer<T>
      logXml()
      Converts the given object to XML and logs it to the default logger as a warning
      static <T extends sailpoint.tools.xml.AbstractXmlObject>
      Consumer<T>
      logXml​(org.apache.commons.logging.Log logger)
      Converts the given object to XML and logs it to the given logger
      static Function<Map<String,​Object>,​Object> lookup​(String key)
      For the given input map, returns the value at the key.
      static <B> Function<Map<String,​B>,​B> lookup​(String key, Class<B> expectedType)
      Same as lookup(String), but casts the output to the expected type
      static Function<String,​Object> lookup​(Map<String,​Object> map)
      For the given input key, returns the value of that key in the given map.
      static <T extends sailpoint.object.SailPointObject>
      Function<String,​T>
      lookup​(sailpoint.api.SailPointContext context, Class<T> sailpointClass)
      Returns a Function converting a string to an object of the given type, looked up using the given SailPointContext.
      static <T,​U>
      Function<Map<T,​? extends U>,​U>
      mapGet​(T key)
      Returns a functional getter for a map of a given type
      static <T,​U>
      Functions.PredicateWithError<Map<T,​U>>
      mapMatches​(sailpoint.object.Filter filter)
      Returns a functional predicate to compare a Map to the filter provided.
      static <K> Comparator<Map<K,​Object>> mapValueComparator​(K key, K... keys)
      Creates a map comparator for sorting a map against the given key(s).
      static <T,​U>
      Predicate<Map<T,​? extends U>>
      mapValueEquals​(T key, U value)
      Creates a Predicate that retrieves the key of the given name from the input Map and returns true if the value equals the given value.
      static Functions.PredicateWithError<? extends sailpoint.object.SailPointObject> matches​(String filterString)
      Resolves to true if the input object matches the filter.
      static Functions.PredicateWithError<? extends sailpoint.object.SailPointObject> matches​(sailpoint.object.Filter filter)
      Resolves to true if the input object matches the filter.
      static <T> Functions.PredicateWithError<T> matches​(sailpoint.object.Filter filter, Class<T> matchType)
      Resolves to true if the input object matches the filter.
      static Function<? extends sailpoint.object.SailPointObject,​String> name()
      Maps to the name of the input object
      static <T> Predicate<? extends T> ne​(T value)
      Resolves to true if the input object does not equal the value
      static <T> Supplier<List<T>> newList()
      Returns a supplier returning a new, writeable list.
      static <T> Supplier<Set<T>> newSet()
      Returns a supplier returning a new, writeable set.
      static Predicate<?> nonNull()
      Returns a predicate that resolves to true if the input item is not null
      static Function<String,​String> normalize()
      A very basic normalizer function that trims spaces and lowercases the input string, then removes all non-ASCII characters.
      static Functions.NullConsumer nothing()
      Implements a generic “black hole” or “dev null” consumer that swallows the object.
      static <T> Function<T,​Optional<T>> nothingToOptional()
      Returns a function that transforms a value into an Optional that will be empty if the value matches Utilities.isNothing(Object).
      static <T> Function<T,​Stream<T>> nothingToStream()
      Returns a function that transforms a value into a Stream that will be empty if the value matches Utilities.isNothing(Object).
      static BiFunction<Object,​Object,​Boolean> nullSafeEq()
      Creates a BiFunction that resolves to Boolean true if the two input objects are equal, ignoring case
      static Function<Object,​String> nullToEmpty()
      Transforms the input object into a non-null string
      static Predicate<sailpoint.object.ProvisioningPlan.AccountRequest> operationEquals​(sailpoint.object.ProvisioningPlan.AccountRequest.Operation operation)
      Resolves to true if the given AccountRequest’s operation equals the given value
      static Predicate<sailpoint.object.ProvisioningPlan.AttributeRequest> operationEquals​(sailpoint.object.ProvisioningPlan.Operation operation)
      Resolves to true if the given provisioning plan’s operation equals the given value
      static Predicate<Optional<?>> optionalEmpty()
      Returns a predicate that resolves to true if the input Optional is empty
      static Predicate<Optional<?>> optionalPresent()
      Returns a predicate that resolves to true if the input Optional is present
      static <T> Function<Optional<T>,​Stream<T>> optionalToStream()
      Returns a Beanshell-friendly equivalent to the JDK 9 Optional::stream function.
      static <T> Function<T,​String> otoa()
      Creates a function equivalent to Util::otoa
      static Functions.OtobWrapper otob()
      Returns an object that implements both Function and Predicate and returns the result of Util::otob on the input object
      static <T> Function<T,​Integer> otoi()
      Creates a function equivalent to Util::otoi
      static <T> Function<T,​List<String>> otol()
      Creates a function equivalent to Util::otol
      static Predicate<?> p​(bsh.This bshThis, String methodName)
      Invokes the given Beanshell method, which will receive the input object as its sole parameter, and then resolves to true if the method returns an otob truthy value.
      static Predicate<?> p​(Object target, String methodName)
      Invokes the given method against the target object, passing the input object as its only parameter, then resolves to true if the output is otob truthy.
      static <T> Predicate<T> p​(String methodName)
      Invokes the given method on the input object, resolving to the otob truthy conversion of its output.
      static Predicate<?> p​(String methodName, Object... inputs)
      Constructs a Predicate that invokes the given method against the input object, providing the additional inputs as needed, then returns true if the result is ‘otob’ truthy.
      static <T> Predicate<T> p​(Function<T,​Boolean> f)
      Transforms a Function that returns a boolean into a predicate
      static Function<String,​Date> parseDate​(String format)
      Parses each incoming string as a date according to the provided format, returning null if there is a parse exception
      static Predicate<sailpoint.object.ProvisioningPlan> planHasAttribute​(String application, String attribute)
      Returns a Predicate that resolves to true if the given plan has the given attribute on the given application.
      static Predicate<sailpoint.object.ProvisioningPlan> planHasOperation​(String application, sailpoint.object.ProvisioningPlan.AccountRequest.Operation operation)
      Creates a Predicate that returns true if provided a ProvisioningPlan that contains an AccountRequest with the given application name and request operation
      static Predicate<sailpoint.object.ProvisioningPlan> planHasOperation​(sailpoint.object.ProvisioningPlan.AccountRequest.Operation operation)
      Creates a Predicate that returns true if provided a ProvisioningPlan that contains an AccountRequest with the given Operation
      static Function<sailpoint.object.ProvisioningProject,​Stream<sailpoint.object.ProvisioningPlan>> plans()
      Maps to a Stream of provisioning plans (for use with flatMap) in the given project
      static Predicate<Object> propertyAfter​(String propertyPath, Date test)
      Resolves to true if the given property value on the input object can be coerced to a Date and is after the given Date.
      static Predicate<Object> propertyBefore​(String propertyPath, Date test)
      Resolves to true if the given property value on the input object can be coerced to a Date and is before the given Date.
      static Predicate<Object> propertyEquals​(String propertyPath, Object test)
      Returns a Predicate that resolves to true if the given property on the input object equals the test value
      static Predicate<Object> propertyMatchesRegex​(String propertyPath, String regexString)
      Returns a Predicate that resolves to true if the property at the given path matches the given regex.
      static Predicate<Object> propertySame​(String propertyPath, Object test)
      Returns a Predicate that resolves to true if the given property on the input object is the same as the test value, per Sameness rules
      static Predicate<String> regexMatches​(String regex)
      Returns a Predicate that evaluates to true if the predicate’s input string matches the given regular expression.
      static Predicate<String> regexMatches​(Pattern regex)
      Returns a Predicate that evaluates to true if the predicate’s input string matches the given regular expression.
      static Predicate<String> regexMatchesPartial​(String regex)
      Returns a Predicate that evaluates to true if the predicate’s input string matches the given regular expression.
      static <T> Function<Object,​T> safeCast​(Class<T> expectedClass)
      Safely casts the value to the given class, returning null if it can’t be cast to that value.
      static <T> Function<Object,​T> safeGet​(String propertyName, Class<T> expectedClass)
      Safely retrieves the given property from the input object, returning null if the property value is not of the expected type.
      static <T> Function<Object,​T> safeGet​(String propertyName, T defaultValue, Class<T> expectedClass)
      Safely retrieves the given property from the input object, returning the default value if the result is null or throws an exception.
      static Function<Object,​List<String>> safeListify()  
      static Predicate<?> sameAs​(Object value)
      Returns a Predicate that resolves to true if the input value is the same as the given test value, per Sameness rules
      static Predicate<?> sameAs​(Object value, boolean ignoreCase)
      Returns a Predicate that resolves to true if the input value is the same as the given test value, ignoring case, per Sameness rules
      static Functions.SupplierWithError<Boolean> sb​(bsh.This bsh, String methodName, Object... params)
      Supplies a value by invoking the given Beanshell method with the given parameters.
      static <ListItem> Comparator<ListItem> sortListOrder​(List<ListItem> order)
      Creates a comparator that sorts in the order specified, leaving the input objects alone.
      static <ListItem,​SortType>
      Comparator<ListItem>
      sortListOrder​(List<SortType> order, Function<ListItem,​SortType> keyExtractor)
      Creates a comparator that sorts in the order specified, translating input values into sort keys first via the provided translator.
      static Predicate<String> startsWith​(String prefix)
      Returns a Predicate that resolves to true if the input string starts with the given prefix
      static <A,​T>
      Function<A,​Stream<T>>
      stream​(Function<A,​?> input, Class<T> expectedType)
      Applies the given function to the input object and then makes a Stream out of it.
      static <A> Function<A,​Stream<Object>> stream​(Function<A,​? extends Object> input)
      Equivalent to stream(Function, Class) if passed Object.class
      static <A extends sailpoint.object.SailPointObject>
      Stream<A>
      stream​(sailpoint.api.SailPointContext context, Class<A> spoClass, sailpoint.object.QueryOptions qo)
      Creates a stream out of the given SailPoint search
      static <A extends sailpoint.object.SailPointObject>
      Stream<Object[]>
      stream​(sailpoint.api.SailPointContext context, Class<A> spoClass, sailpoint.object.QueryOptions qo, List<String> props)
      Creates a stream out of the given SailPoint projection search
      static Supplier<String> toJson​(Object obj)
      Returns a supplier that serializes the given object to JSON.
      static Supplier<String> toXml​(sailpoint.tools.xml.AbstractXmlObject spo)
      Returns a Supplier that translates the given AbstractXmlObject to XML.
      static <T> Function<Map.Entry<?,​T>,​T> value()
      Returns a mapping function producing the value of the input map entry
    • Method Detail

      • accountRequests

        public static Function<sailpoint.object.ProvisioningPlan,​Stream<sailpoint.object.ProvisioningPlan.AccountRequest>> accountRequests()
        A flatMap() function to extract the account requests from a plan
      • alwaysFalse

        public static <T> Predicate<T> alwaysFalse()
        Returns a predicate that is always false
        Type Parameters:
        T - The arbitrary type
        Returns:
        The predicate
      • alwaysTrue

        public static <T> Predicate<T> alwaysTrue()
        Returns a predicate that is always true
        Type Parameters:
        T - The arbitrary type
        Returns:
        The predicate
      • appendTo

        public static <T> Consumer<T> appendTo​(List<? super T> values)
        Returns a Consumer that will append all inputs to the given List.

        If the list is not modifiable, the error will occur at runtime.

        Type Parameters:
        T - The type of the items
        Parameters:
        values - The List to which things should be added
        Returns:
        The function to add items to that list
      • appendTo

        public static <T> Consumer<T> appendTo​(Set<? super T> values)
        Returns a Consumer that will append all inputs to the given List.

        If the set is not modifiable, the error will occur at runtime.

        Type Parameters:
        T - The type of the items
        Parameters:
        values - The Set to which things should be added
        Returns:
        The function to add items to that set
      • attributeEquals

        public static Predicate<? extends sailpoint.object.SailPointObject> attributeEquals​(String attributeName,
                                                                                            Object testValue)
        Creates a Predicate that resolves to true if the given attribute on the argument resolves to the given value.
      • attributeRequests

        public static Function<sailpoint.object.ProvisioningPlan.AccountRequest,​Stream<sailpoint.object.ProvisioningPlan.AttributeRequest>> attributeRequests()
        Creates a flatMap() stream to extract attribute requests from an account request
      • attributeSame

        public static Predicate<? extends sailpoint.object.SailPointObject> attributeSame​(String attributeName,
                                                                                          Object testValue)
        Create a Predicate that resolves to true if the given attribute value is the same (per Sameness) as the given test value.
      • bc

        public static BiConsumer<?,​?> bc​(bsh.This bshThis,
                                               String methodName)
        Creates a BiConsumer that invokes the given Beanshell method, passing the inputs to the consumer.
        Parameters:
        bshThis - The Beanshell ‘this’ context
        methodName - The method name to invoke
        Returns:
        The BiConsumer
      • box

        public static Class<?> box​(Class<?> prim)
        Returns the ‘boxed’ class corresponding to the given primitive.
        Parameters:
        prim - The primitive class, e.g. Long.TYPE
        Returns:
        The boxed class, e.g., java.lang.Long
      • c

        public static Functions.ConsumerWithError<Objectc​(String methodName,
                                                            Object... inputs)
        Creates a Consumer to invoke a method on an object passed to it.

        The remaining inputs arguments will be provided as arguments to the method.

      • cast

        public static <T> Function<Object,​T> cast​(Class<T> target)
        Returns a function that will cast the input object to the given type or throw a ClassCastException.
      • comparator

        public static Comparator<Objectcomparator​(String property)
        Returns a Comparator that extracts the given property (by path) from the two input objects, then compares them.

        The property values must be Comparable to each other.

      • comparator

        public static Comparator<Objectcomparator​(String property,
                                                    bsh.This bshThis,
                                                    String methodName)
        Creates a Comparator that extracts the given property from the two input objects, then passes them both to the given Beanshell method, which must return an appropriate Comparator integer result.
      • comparator

        public static Comparator<Objectcomparator​(bsh.This bshThis,
                                                    String methodName)
        Creates a Comparator that directly passes the two input objects to the given Beanshell method.

        The method must return an appropriate Comparator integer result.

      • cs

        public static Functions.ConsumerWithError<Objectcs​(Class<?> sourceType,
                                                             String methodName)
        Creates a Consumer that invokes the given static method on the given class for each input object.

        (The “cs” stands for consumer static.)

      • cs

        public static Functions.ConsumerWithError<Objectcs​(Class<?> sourceType,
                                                             String methodName,
                                                             Object param1)
        Creates a Consumer that invokes the given static method on the given class for each input object, passing the object as the first method parameter and the given param1 as the second.

        (The “cs” stands for consumer static.)

      • cs

        public static Functions.ConsumerWithError<Objectcs​(Class<?> sourceType,
                                                             String methodName,
                                                             Object param1,
                                                             Object param2)
        Creates a Consumer that invokes the given static method on the given class for each input object, passing the object as the first method parameter, the given param1 as the second, and the given param2 as the third.
      • debug

        public static <T> Consumer<T> debug()
        Logs whatever is passed in at debug level, if the logger has debug enabled
        Type Parameters:
        T - The type of the object
        Returns:
        The consumer
      • debug

        public static <T> Consumer<T> debug​(org.apache.commons.logging.Log logger)
        Logs whatever is passed in at debug level, if the logger has debug enabled
        Type Parameters:
        T - The type of the object
        Parameters:
        logger - The logger to which the value should be logged
        Returns:
        The consumer
      • debugXml

        public static <T extends sailpoint.tools.xml.AbstractXmlObject> Consumer<T> debugXml()
        Logs the input as XML, useful with peek() in a stream.

        Since no logger is specified, uses this class’s own logger.

        Type Parameters:
        T - the input type
        Returns:
        The consumer
      • debugXml

        public static <T extends sailpoint.tools.xml.AbstractXmlObject> Consumer<T> debugXml​(org.apache.commons.logging.Log logger)
        Logs the input as XML, useful with peek() in a stream
        Type Parameters:
        T - the input type
        Parameters:
        logger - The logger to which the object should be logged
        Returns:
        The consumer
      • endsWith

        public static Predicate<StringendsWith​(String suffix)
        Creates a Predicate that returns true if the input string ends with the given suffix
        Parameters:
        suffix - The suffix
        Returns:
        True if the input string ends with the suffix
      • eq

        public static <T> Predicate<? extends T> eq​(T value)
        Returns a Predicate that returns true if the two values are null-safe equals.

        Two null values will be considered equal.

        Util.nullSafeEq(Object, Object) is used under the hood.

        Type Parameters:
        T - The type of the input expected
        Parameters:
        value - The value to which each input should be compared
        Returns:
        The predicate
      • eq

        public static <K,​T> Predicate<K> eq​(Function<K,​T> valueExtractor,
                                                  Object testValue)
        Returns a Predicate that returns true if the extracted value from the input is equal (in a null-safe way) to the test value.

        If your test value is itself a Predicate, it will be invoked to test the extracted value.

        Parameters:
        valueExtractor - A function to extract a value for comparison from the actual input object
        testValue - The text value
      • eqIgnoreCase

        public static Predicate<StringeqIgnoreCase​(String value)
        Returns a Predicate that resolves to true when tested against an object that is equal to the input to this method.
        Parameters:
        value - The value to test for equality with the Predicate input
        Returns:
        The predicate
      • extractRegexMatchGroup

        public static Function<String,​Optional<String>> extractRegexMatchGroup​(String regex,
                                                                                     int matchGroup)
        Returns a function that extracts the Nth matching group from applying the regular expression to the input string.

        The return value will be an empty Optional if the input does not match the regular expression or if the group was not matched. Otherwise, it will be an Optional containing the contents of the matched group.

        Parameters:
        regex - The regular expression
        matchGroup - Which match group to return (starting with 1)
        Returns:
        A function with the above behavior
      • f

        public static <K,​T> Function<K,​T> f​(String methodName,
                                                        Class<T> expectedType,
                                                        Object... parameters)
        Creates a Function that invokes the given method on the input object, and returns the output of that method.

        The given parameters will be passed to the method.

        NOTE: Beanshell will be confused if you don’t pass at least one argument.

        Type Parameters:
        T - The value
        Parameters:
        methodName - The method name to invoke
        expectedType - The expected type of the output
        parameters - The remaining parameters to pass to the method
        Returns:
        The function
      • f

        public static Function<Object,​Objectf​(bsh.This bshThis,
                                                      String methodName)
        Creates a Function that invokes the named Beanshell method, passing the input object as its parameter, and returning the method’s return value.

        A simplified type-free version of f(This, String, Class, Object...)

        Parameters:
        bshThis - The object on which the method should be invoked
        methodName - The method name to invoke
        Returns:
        The function
      • f

        public static <B> Function<Object,​B> f​(bsh.This bshThis,
                                                     String methodName,
                                                     Class<B> expectedResult,
                                                     Object... parameters)
        Creates a Function that invokes the named Beanshell method, passing the input object as its parameter, and returning the method’s return value.

        This is roughly equivalent to the class method syntax, ClassName::method.

        Type Parameters:
        B - The type of the output
        Parameters:
        bshThis - The object on which the method should be invoked
        methodName - The method name to invoke
        expectedResult - The expected type of the output
        parameters - The other parameters to pass to the method
        Returns:
        The function
      • f

        public static <T> Function<Object,​T> f​(Object target,
                                                     String methodName,
                                                     Class<T> expectedType)
        Creates a Function that invokes the named method on the given target object, passing the input item as its parameter.

        This is roughly equivalent to the instance method syntax, obj::method, and can be used to do stuff equivalent to:

        list.stream().filter(map::containsKey)…

        Type Parameters:
        T - The type of the output
        Parameters:
        target - The object on which the method should be invoked
        methodName - The method name to invoke
        expectedType - The expected type of the output
        Returns:
        The function
      • f

        public static <K,​T> Function<K,​T> f​(String methodName,
                                                        Class<T> expectedType)
        Creates a Function that invokes the given method on the input object, and returns the output of that method.

        This is essentially equivalent to the class method reference syntax Class::method.

        Type Parameters:
        T - The value
        K - The input type
        Parameters:
        methodName - The method name to invoke
        expectedType - The expected type of the output
        Returns:
        The function
      • findMethod

        public static Method findMethod​(Class<?> toSearch,
                                        String name,
                                        boolean findStatic,
                                        Object... params)
        Finds the most specific accessible Method on the given Class that accepts the parameters provided.

        If two methods are equally specific, which would usually result in an “ambiguous method call” compiler error, an arbitrary one will be returned.

        Parameters:
        toSearch - The class to search for the method
        name - The name of the method to locate
        findStatic - True if we should look at static methods, false if we should look at instance methods
        params - The intended parameters to the method
        Returns:
        The Method discovered, or null if none match
      • findRequests

        public static Function<sailpoint.object.ProvisioningPlan,​List<sailpoint.object.ProvisioningPlan.AccountRequest>> findRequests​(String application)
        Transforms a provisioning plan into a list of requests for the given application
        Parameters:
        application - The application name
        Returns:
        The list of account requests
      • findRequests

        public static Function<sailpoint.object.ProvisioningPlan,​List<sailpoint.object.ProvisioningPlan.AccountRequest>> findRequests​(sailpoint.object.ProvisioningPlan.AccountRequest.Operation operation)
        Transforms a provisioning plan into a list of requests with the given operation
        Parameters:
        operation - The operation to look for
        Returns:
        The list of account requests
      • forEach

        public static <T> void forEach​(Collection<T> values,
                                       Consumer<T> consumer)
        Runs the given consumer for each item in the collection
        Type Parameters:
        T - The type of the collection
        Parameters:
        values - The values to iterate
        consumer - The consumer to apply to each
      • forEach

        public static <A,​B> void forEach​(Map<A,​B> values,
                                               Consumer<Map.Entry<A,​B>> consumer)
        Runs the given consumer for each entry in the map
        Type Parameters:
        A - The key type
        B - The value type
        Parameters:
        values - The map of values
        consumer - The consumer of the map entries
      • forEach

        public static <A,​B> void forEach​(Map<A,​B> values,
                                               BiConsumer<A,​B> consumer)
        Runs the given bi-consumer for all of the values in the map
        Type Parameters:
        A - The key type
        B - The value type
        Parameters:
        values - The values
        consumer - The bi-consumer to be passed the key and value
      • forEach

        public static <A> void forEach​(Iterator<A> values,
                                       Consumer<A> consumer)
        Runs the given consumer for each remaining item returned by the Iterator
        Type Parameters:
        A - The type of the values
        Parameters:
        values - The values to iterate
        consumer - The consumer to apply to each
      • fs

        public static <T> Function<Object,​T> fs​(Class<?> targetClass,
                                                      String methodName,
                                                      Class<T> expectedType)
        Invokes the named static function on the given class, passing the input object to it.

        The output will be cast to the expected type and returned.

      • ftoc

        public static <In,​Out> Supplier<Out> ftoc​(In inputObject,
                                                        Function<? super In,​? extends Out> function)
        Constructs a Supplier that ‘curries’ the given Function, applying it to the input object and returning the result.

        This allows you to do logger-related structures like this in Beanshell:

        ftoc(someObject, getStringAttribute(“hi”))

        Type Parameters:
        In - The input object type
        Out - The output object type
        Parameters:
        inputObject - The input object to curry
        function - The function to apply to the input object
        Returns:
        A supplier wrapping the object and function call
      • getAttribute

        public static Function<? extends sailpoint.object.SailPointObject,​ObjectgetAttribute​(String attributeName)
        If the input object has Attributes, retrieves the attribute with the given name, otherwise returns null.
        Parameters:
        attributeName - The attribute name to retrieve
        Returns:
        The function
      • getBooleanAttribute

        public static Function<? extends sailpoint.object.SailPointObject,​BooleangetBooleanAttribute​(String attributeName)
        Extracts a boolean attribute from the input object, or false if the attribute is not present.
        Parameters:
        attributeName - The attribute name
        Returns:
        The function
      • getBooleanAttribute

        public static Function<? extends sailpoint.object.SailPointObject,​BooleangetBooleanAttribute​(String attributeName,
                                                                                                             boolean defaultValue)
        Extracts a boolean attribute from the input object, or the default value if the attribute is not present.
        Parameters:
        attributeName - The attribute name
        defaultValue - The default value
        Returns:
        The function
      • getEntitlements

        public static Function<sailpoint.object.Identity,​List<sailpoint.object.IdentityEntitlement>> getEntitlements​(sailpoint.api.SailPointContext context,
                                                                                                                           sailpoint.object.Filter optionalFilter)
        Extracts the list of entitlements from the given Identity object, optionally filtering them with the filter if provided.

        This is a direct query against the database.

        Parameters:
        context - The context
        optionalFilter - An optional filter which will be used to decide which entitlements to return
        Returns:
        The function
      • getLinks

        public static Function<sailpoint.object.Identity,​List<sailpoint.object.Link>> getLinks()
        Gets all links associated with the given Identity.

        This will use IdentityService to do a database query rather than pulling the links from the Identity object, because the Identity object’s list can be unreliable in long-running DB sessions.

      • getLinks

        public static Function<sailpoint.object.Identity,​List<sailpoint.object.Link>> getLinks​(String applicationName,
                                                                                                     String... moreApplicationNames)
        Gets all links associated with the given Identity on the given Application(s).
      • getLinks

        public static Function<sailpoint.object.Identity,​List<sailpoint.object.Link>> getLinks​(sailpoint.object.Application application)
        Gets all links associated with the given Identity on the given Application
      • getStringAttribute

        public static Function<? extends sailpoint.object.SailPointObject,​StringgetStringAttribute​(String attributeName)
        Gets the given attribute as a string from the input object
      • hasAllAttributeRequest

        public static Predicate<sailpoint.object.ProvisioningPlan.AccountRequest> hasAllAttributeRequest​(String... attributeName)
        Returns a Predicate that resolves to true if the input AccountRequest has at least one AttributeRequest corresponding to every one of the attribute names given
        Parameters:
        attributeName - The list of names to match against
        Returns:
        The predicate
      • hasAnyAttributeRequest

        public static Predicate<sailpoint.object.ProvisioningPlan.AccountRequest> hasAnyAttributeRequest​(String... attributeName)
        Returns a Predicate that resolves to true if the input AccountRequest has at least one AttributeRequest corresponding to any of the attribute names given
        Parameters:
        attributeName - The list of names to match against
        Returns:
        The predicate
      • hasAttribute

        public static Predicate<? extends sailpoint.object.SailPointObject> hasAttribute​(String attributeName)
        Resolves to true if the input object has a non-null value for the given attribute
      • hasAttributeRequest

        public static Predicate<sailpoint.object.ProvisioningPlan.AccountRequest> hasAttributeRequest​(boolean useAnd,
                                                                                                      String... attributeName)
        Returns a predicate that resolves to true if the account request has the attribute(s) in question, controlled by the ‘useAnd’ parameter.
        Parameters:
        useAnd - If true, all names must match an AttributeRequest. If false, only one match will resolve in a true.
        attributeName - The list of attribute names
      • id

        public static Function<? extends sailpoint.object.SailPointObject,​Stringid()
        Resolves to the ID of the input SailPointObject
      • in

        public static Predicate<?> in​(List<String> list)
        Resolves to true if the input object is in the given list
      • in

        public static Predicate<?> in​(Set<String> list)
        Resolves to true if the input object is in the given set
      • isAssignableFrom

        public static boolean isAssignableFrom​(Class<?> targetType,
                                               Class<?> otherType)
        Returns true if targetType is assignable from otherType, e.g.

        if the following code would not fail to compile:

        OtherType ot = new OtherType(); TargetType tt = ot;

        This is also equivalent to ‘b instanceof A’ or ‘otherType extends targetType’.

        Primitive types and their boxed equivalents have special handling.

        Parameters:
        targetType - The first (parent-ish) class
        otherType - The second (child-ish) class
        Returns:
        True if cls1 is assignable from cls2
      • isBooleanAttribute

        public static Predicate<? extends sailpoint.object.SailPointObject> isBooleanAttribute​(String attributeName)
        A predicate that resolves to true if the boolean attribute of the input object is true according to Attributes.getBoolean(String).
        Parameters:
        attributeName - The attribute name to query
        Returns:
        The predicate
      • isBooleanAttribute

        public static Predicate<? extends sailpoint.object.SailPointObject> isBooleanAttribute​(String attributeName,
                                                                                               boolean defaultValue)
        A predicate that resolves to true if the boolean attribute of the input object is true according to Attributes.getBoolean(String, boolean).
        Parameters:
        attributeName - The attribute name to query
        defaultValue - The default to use if the attribute is empty
        Returns:
        The predicate
      • isBooleanProperty

        public static Predicate<? extends sailpoint.object.SailPointObject> isBooleanProperty​(String attributeName)
        A predicate that resolves to true if the boolean property of the input object is true according to Util.otob(Object)
        Parameters:
        attributeName - The property name to query
        Returns:
        The predicate
      • isBooleanProperty

        public static Predicate<? extends sailpoint.object.SailPointObject> isBooleanProperty​(String attributeName,
                                                                                              boolean defaultValue)
        A predicate that resolves to true if the boolean property of the input object is true according to Util.otob(Object)
        Parameters:
        attributeName - The property name to query
        defaultValue - The default to use if the property is empty
        Returns:
        The predicate
      • isDisabled

        public static <T extends sailpoint.object.SailPointObject> Predicate<T> isDisabled()
        A predicate that resolves to true if the input is disabled.

        If the input object is of type Identity, its Identity.isInactive() will be called. Otherwise, SailPointObject.isDisabled().

        Type Parameters:
        T - The type of the object
        Returns:
        The predicate
      • isEmpty

        public static <T> Predicate<T> isEmpty()
        Returns a predicate that resolves to true if the input is empty according to Sameness
        Type Parameters:
        T - The type of the object
        Returns:
        The preidcate
      • isInstanceOf

        public static <T> Predicate<T> isInstanceOf​(Class<?> target)
        Resolves to true if the input object is an instance of the target class.

        For specific common classes, this uses a quicker instanceof, and for everything else, it passes off to isAssignableFrom.

        Null inputs will always be false.

      • isNativeIdentity

        public static Predicate<sailpoint.object.Link> isNativeIdentity​(String nativeIdentity)
        Returns a Predicate that resolves to true if the input Link’s native identity is equal to the comparison value.
      • isNull

        public static <T> Predicate<T> isNull()
        Resolves to true if the object is not null
      • isNullOrEmpty

        public static <T> Predicate<T> isNullOrEmpty​(String propertyPath)
        Resolves to true if the given property on the given object is not null or empty.

        Emptiness is defined by this class’s isEmpty().

      • key

        public static <T> Function<Map.Entry<T,​?>,​T> key()
        Extracts the key from the given map entry
      • like

        public static Predicate<? extends Stringlike​(String pattern,
                                                       sailpoint.object.Filter.MatchMode matchMode)
        Returns a Predicate that resolves to true if the input string matches the given pattern, as equivalent to the Filter like() method
      • linkGetIdentity

        public static Function<sailpoint.object.Link,​sailpoint.object.Identity> linkGetIdentity()
        Returns the Identity for the given Link object
        Returns:
        Gets the Link identity
      • linkIsApplication

        public static Predicate<sailpoint.object.Link> linkIsApplication​(String applicationName)
        Creates a predicate that tests whether the Link has the given application name
        Parameters:
        applicationName - The application name
        Returns:
        The predicate
      • linkIsApplication

        public static Predicate<sailpoint.object.Link> linkIsApplication​(sailpoint.object.Application application)
        Creates a predicate that tests whether the Link has the given application name.

        The ID will be cached in the closure, so you do not need to keep the Application object in the same Hibernate scope.

        Parameters:
        application - The application object
        Returns:
        The predicate
      • listSafeGet

        public static <T> Function<List<T>,​T> listSafeGet​(int index)
        Returns a functional getter for a map of a given type
        Type Parameters:
        T - The type stored in the list
        Parameters:
        index - The index to get
        Returns:
        The output
      • log

        public static <T> Consumer<T> log()
        Logs the input object at warn() level in the default Functions logger.

        This is intended for use with peek() in the middle of a stream.

      • log

        public static <T> Consumer<T> log​(org.apache.commons.logging.Log logger)
        Logs the input object at warn() level in the provided logger This is intended for use with peek() in the middle of a stream.
      • logXml

        public static <T extends sailpoint.tools.xml.AbstractXmlObject> Consumer<T> logXml()
        Converts the given object to XML and logs it to the default logger as a warning
        Type Parameters:
        T - The object type
        Returns:
        A consumer that will log the object
      • logXml

        public static <T extends sailpoint.tools.xml.AbstractXmlObject> Consumer<T> logXml​(org.apache.commons.logging.Log logger)
        Converts the given object to XML and logs it to the given logger
        Type Parameters:
        T - The object type
        Parameters:
        logger - The logger
        Returns:
        A consumer that will log the object
      • lookup

        public static Function<String,​Objectlookup​(Map<String,​Object> map)
        For the given input key, returns the value of that key in the given map.
        Parameters:
        map - Returns the result of MapUtil.get(Map, String)
        Returns:
        A function that takes a string and returns the proper value from the Map
      • lookup

        public static Function<Map<String,​Object>,​Objectlookup​(String key)
        For the given input map, returns the value at the key.

        The key is a MapUtil path.

        Parameters:
        key - Returns the result of MapUtil.get(Map, String)
        Returns:
        A function that takes a Map and returns the value of the given key in that map
      • lookup

        public static <B> Function<Map<String,​B>,​B> lookup​(String key,
                                                                       Class<B> expectedType)
        Same as lookup(String), but casts the output to the expected type
      • lookup

        public static <T extends sailpoint.object.SailPointObject> Function<String,​T> lookup​(sailpoint.api.SailPointContext context,
                                                                                                   Class<T> sailpointClass)
        Returns a Function converting a string to an object of the given type, looked up using the given SailPointContext.

        In 8.4, ensure that the SailPointContext is the correct one for the object type. Certain objects are now in the Access History context.

        Type Parameters:
        T - The type of SailPointObject to look up
        Parameters:
        context - The context to use to look up the object
        sailpointClass - The object type to read
        Returns:
        A function to look up objects of the given type by ID or name
      • mapGet

        public static <T,​U> Function<Map<T,​? extends U>,​U> mapGet​(T key)
        Returns a functional getter for a map of a given type
        Type Parameters:
        T - The key type of the map
        U - The value type of the map
        Parameters:
        key - The key to get
        Returns:
        The output
      • mapMatches

        public static <T,​U> Functions.PredicateWithError<Map<T,​U>> mapMatches​(sailpoint.object.Filter filter)
        Returns a functional predicate to compare a Map to the filter provided.
        Type Parameters:
        T - The key type of the map
        U - The value type of the map
        Parameters:
        filter - The filter to execute against the Map
        Returns:
        The output
      • mapValueComparator

        @SafeVarargs
        public static <K> Comparator<Map<K,​Object>> mapValueComparator​(K key,
                                                                             K... keys)
        Creates a map comparator for sorting a map against the given key(s).

        Additional keys are implemented using recursive calls back to this method.

        Parameters:
        key - The first key for comparing
        keys - A list of additional keys for comparing
        Returns:
        The comparator
      • mapValueEquals

        public static <T,​U> Predicate<Map<T,​? extends U>> mapValueEquals​(T key,
                                                                                     U value)
        Creates a Predicate that retrieves the key of the given name from the input Map and returns true if the value equals the given value.
        Parameters:
        key - The key to query in the map
        value - The value to query in the map
      • matches

        public static Functions.PredicateWithError<? extends sailpoint.object.SailPointObject> matches​(sailpoint.object.Filter filter)
        Resolves to true if the input object matches the filter.

        This ought to be thread-safe if the SailPointFactory’s current context is correct for the thread.

        HybridObjectMatcher is used to do the matching.

        Parameters:
        filter - The Filter to evaluate against the input object
        Returns:
        A predicate returning true when the filter matches the input
      • matches

        public static <T> Functions.PredicateWithError<T> matches​(sailpoint.object.Filter filter,
                                                                  Class<T> matchType)
        Resolves to true if the input object matches the filter.

        This ought to be thread-safe if the SailPointFactory’s current context is correct for the thread.

        HybridObjectMatcher is used to do the matching.

        Parameters:
        filter - The Filter to evaluate against the input object
        matchType - The class to match, which does not need to be a SailPointObject
        Returns:
        A predicate returning true when the filter matches the input
      • matches

        public static Functions.PredicateWithError<? extends sailpoint.object.SailPointObject> matches​(String filterString)
        Resolves to true if the input object matches the filter.

        The filter will be compiled when this method is called, and then the remainder is a simple forward to matches(Filter).

        Parameters:
        filterString - The filter string to evaluate against the input object
        Returns:
        A predicate returning true when the filter matches the input
      • name

        public static Function<? extends sailpoint.object.SailPointObject,​Stringname()
        Maps to the name of the input object
      • ne

        public static <T> Predicate<? extends T> ne​(T value)
        Resolves to true if the input object does not equal the value
      • newSet

        public static <T> Supplier<Set<T>> newSet()
        Returns a supplier returning a new, writeable set.

        This can be passed to Collectors.toCollection(Supplier) for example.

        Type Parameters:
        T - The type of the list
        Returns:
        the new HashSet supplier
      • nonNull

        public static Predicate<?> nonNull()
        Returns a predicate that resolves to true if the input item is not null
        Returns:
        The predicate
      • normalize

        public static Function<String,​Stringnormalize()
        A very basic normalizer function that trims spaces and lowercases the input string, then removes all non-ASCII characters.

        This should be replaced with a better normalization algorithm in most cases.

        Returns:
        The function
      • nothing

        public static Functions.NullConsumer nothing()
        Implements a generic “black hole” or “dev null” consumer that swallows the object.

        This can be used as a sane default where another consumer is required.

      • nothingToOptional

        public static <T> Function<T,​Optional<T>> nothingToOptional()
        Returns a function that transforms a value into an Optional that will be empty if the value matches Utilities.isNothing(Object).
        Type Parameters:
        T - The type of the object
        Returns:
        A function that transforms a value into an Optional
      • nothingToStream

        public static <T> Function<T,​Stream<T>> nothingToStream()
        Returns a function that transforms a value into a Stream that will be empty if the value matches Utilities.isNothing(Object).
        Type Parameters:
        T - The type of the object
        Returns:
        A function that transforms a value into an Optional
      • nullSafeEq

        public static BiFunction<Object,​Object,​BooleannullSafeEq()
        Creates a BiFunction that resolves to Boolean true if the two input objects are equal, ignoring case
        Returns:
        the BiFunction
      • operationEquals

        public static Predicate<sailpoint.object.ProvisioningPlan.AccountRequest> operationEquals​(sailpoint.object.ProvisioningPlan.AccountRequest.Operation operation)
        Resolves to true if the given AccountRequest’s operation equals the given value
      • operationEquals

        public static Predicate<sailpoint.object.ProvisioningPlan.AttributeRequest> operationEquals​(sailpoint.object.ProvisioningPlan.Operation operation)
        Resolves to true if the given provisioning plan’s operation equals the given value
      • optionalEmpty

        public static Predicate<Optional<?>> optionalEmpty()
        Returns a predicate that resolves to true if the input Optional is empty
        Returns:
        The predicate
      • optionalPresent

        public static Predicate<Optional<?>> optionalPresent()
        Returns a predicate that resolves to true if the input Optional is present
        Returns:
        The predicate
      • optionalToStream

        public static <T> Function<Optional<T>,​Stream<T>> optionalToStream()
        Returns a Beanshell-friendly equivalent to the JDK 9 Optional::stream function.

        The stream will have zero or one elements and is intended for use with Stream.flatMap(Function).

        Type Parameters:
        T - The type of the object
        Returns:
        A function from an Optional to a Stream
      • otoa

        public static <T> Function<T,​Stringotoa()
        Creates a function equivalent to Util::otoa
        Returns:
        The function
      • otob

        public static Functions.OtobWrapper otob()
        Returns an object that implements both Function and Predicate and returns the result of Util::otob on the input object
        Returns:
        The function/predicate
      • otoi

        public static <T> Function<T,​Integerotoi()
        Creates a function equivalent to Util::otoi
        Returns:
        The function
      • otol

        public static <T> Function<T,​List<String>> otol()
        Creates a function equivalent to Util::otol
        Returns:
        The function
      • p

        public static <T> Predicate<T> p​(Function<T,​Boolean> f)
        Transforms a Function that returns a boolean into a predicate
        Parameters:
        f - The function to transform
        Returns:
        The predicate
      • p

        public static <T> Predicate<T> p​(String methodName)
        Invokes the given method on the input object, resolving to the otob truthy conversion of its output.
      • p

        public static Predicate<?> p​(Object target,
                                     String methodName)
        Invokes the given method against the target object, passing the input object as its only parameter, then resolves to true if the output is otob truthy.
      • p

        public static Predicate<?> p​(String methodName,
                                     Object... inputs)
        Constructs a Predicate that invokes the given method against the input object, providing the additional inputs as needed, then returns true if the result is ‘otob’ truthy.
      • p

        public static Predicate<?> p​(bsh.This bshThis,
                                     String methodName)
        Invokes the given Beanshell method, which will receive the input object as its sole parameter, and then resolves to true if the method returns an otob truthy value.
      • parseDate

        public static Function<String,​DateparseDate​(String format)
        Parses each incoming string as a date according to the provided format, returning null if there is a parse exception
      • planHasAttribute

        public static Predicate<sailpoint.object.ProvisioningPlan> planHasAttribute​(String application,
                                                                                    String attribute)
        Returns a Predicate that resolves to true if the given plan has the given attribute on the given application.

        This can be done in a more fluent way using Plans.find if desired.

      • planHasOperation

        public static Predicate<sailpoint.object.ProvisioningPlan> planHasOperation​(sailpoint.object.ProvisioningPlan.AccountRequest.Operation operation)
        Creates a Predicate that returns true if provided a ProvisioningPlan that contains an AccountRequest with the given Operation
        Parameters:
        operation - The operation to check for
        Returns:
        The predicate
      • planHasOperation

        public static Predicate<sailpoint.object.ProvisioningPlan> planHasOperation​(String application,
                                                                                    sailpoint.object.ProvisioningPlan.AccountRequest.Operation operation)
        Creates a Predicate that returns true if provided a ProvisioningPlan that contains an AccountRequest with the given application name and request operation
        Parameters:
        application - The name of the application
        operation - The operation to check for
        Returns:
        The predicate
      • plans

        public static Function<sailpoint.object.ProvisioningProject,​Stream<sailpoint.object.ProvisioningPlan>> plans()
        Maps to a Stream of provisioning plans (for use with flatMap) in the given project
      • propertyAfter

        public static Predicate<ObjectpropertyAfter​(String propertyPath,
                                                      Date test)
        Resolves to true if the given property value on the input object can be coerced to a Date and is after the given Date.
      • propertyBefore

        public static Predicate<ObjectpropertyBefore​(String propertyPath,
                                                       Date test)
        Resolves to true if the given property value on the input object can be coerced to a Date and is before the given Date.
      • propertyEquals

        public static Predicate<ObjectpropertyEquals​(String propertyPath,
                                                       Object test)
        Returns a Predicate that resolves to true if the given property on the input object equals the test value
      • propertyMatchesRegex

        public static Predicate<ObjectpropertyMatchesRegex​(String propertyPath,
                                                             String regexString)
        Returns a Predicate that resolves to true if the property at the given path matches the given regex.

        If the property is a string it will be used directly. If the property is a List containing only one string, that string will be extracted and used.

        In all other cases, including parse errors, false will be returned.

        Parameters:
        propertyPath - The path to the property via Utilities.getProperty(Object, String)
        regexString - The regular expression string
        Returns:
        A predicate that returns true if the property extracted matches the
      • propertySame

        public static Predicate<ObjectpropertySame​(String propertyPath,
                                                     Object test)
        Returns a Predicate that resolves to true if the given property on the input object is the same as the test value, per Sameness rules
      • regexMatches

        public static Predicate<StringregexMatches​(String regex)
        Returns a Predicate that evaluates to true if the predicate’s input string matches the given regular expression.
        Parameters:
        regex - The regex
        Returns:
        A predicate that matches the regex
      • regexMatches

        public static Predicate<StringregexMatches​(Pattern regex)
        Returns a Predicate that evaluates to true if the predicate’s input string matches the given regular expression.

        Unlike the version of regexMatches(String) taking a String, this one uses Matcher.find(), meaning it will match partial strings.

        Parameters:
        regex - The regex
        Returns:
        A predicate that matches the regex
      • regexMatchesPartial

        public static Predicate<StringregexMatchesPartial​(String regex)
        Returns a Predicate that evaluates to true if the predicate’s input string matches the given regular expression.
        Parameters:
        regex - The regex
        Returns:
        A predicate that matches the regex
      • safeCast

        public static <T> Function<Object,​T> safeCast​(Class<T> expectedClass)
        Safely casts the value to the given class, returning null if it can’t be cast to that value.
        Type Parameters:
        T - The expected class type
        Parameters:
        expectedClass - The expected class
        Returns:
        The value cast to the given type, or null if not that type
      • safeGet

        public static <T> Function<Object,​T> safeGet​(String propertyName,
                                                           T defaultValue,
                                                           Class<T> expectedClass)
        Safely retrieves the given property from the input object, returning the default value if the result is null or throws an exception.
      • safeGet

        public static <T> Function<Object,​T> safeGet​(String propertyName,
                                                           Class<T> expectedClass)
        Safely retrieves the given property from the input object, returning null if the property value is not of the expected type.
      • sameAs

        public static Predicate<?> sameAs​(Object value)
        Returns a Predicate that resolves to true if the input value is the same as the given test value, per Sameness rules
      • sameAs

        public static Predicate<?> sameAs​(Object value,
                                          boolean ignoreCase)
        Returns a Predicate that resolves to true if the input value is the same as the given test value, ignoring case, per Sameness rules
      • sortListOrder

        public static <ListItem> Comparator<ListItem> sortListOrder​(List<ListItem> order)
        Creates a comparator that sorts in the order specified, leaving the input objects alone.

        Equivalent to calling sortListOrder and passing Function.identity() as the translator.

      • sortListOrder

        public static <ListItem,​SortType> Comparator<ListItem> sortListOrder​(List<SortType> order,
                                                                                   Function<ListItem,​SortType> keyExtractor)
        Creates a comparator that sorts in the order specified, translating input values into sort keys first via the provided translator.

        Values not in the order list will be sorted to the end of the list.

        For example, you might sort a list of Links into a specific order by application to create a precedence structure.

        If no order is specified, the resulting Comparator will laboriously leave the list in the original order.

        Type Parameters:
        ListItem - The type of the item being sorted
        SortType - The type of item in the ordering list
        Parameters:
        order - The ordering to apply
        keyExtractor - The translator
        Returns:
        The comparator
      • startsWith

        public static Predicate<StringstartsWith​(String prefix)
        Returns a Predicate that resolves to true if the input string starts with the given prefix
      • stream

        public static <A extends sailpoint.object.SailPointObject> Stream<A> stream​(sailpoint.api.SailPointContext context,
                                                                                    Class<A> spoClass,
                                                                                    sailpoint.object.QueryOptions qo)
                                                                             throws sailpoint.tools.GeneralException
        Creates a stream out of the given SailPoint search
        Type Parameters:
        A - The object type
        Parameters:
        context - The context
        spoClass - The SailPointObject to search
        qo - The QueryOptions
        Returns:
        The stream
        Throws:
        sailpoint.tools.GeneralException - if the query fails
      • stream

        public static <A extends sailpoint.object.SailPointObject> Stream<Object[]> stream​(sailpoint.api.SailPointContext context,
                                                                                           Class<A> spoClass,
                                                                                           sailpoint.object.QueryOptions qo,
                                                                                           List<String> props)
                                                                                    throws sailpoint.tools.GeneralException
        Creates a stream out of the given SailPoint projection search
        Type Parameters:
        A - The object type to query
        Parameters:
        context - The context
        spoClass - The SailPoint class
        qo - The query filters
        props - The query properties to query
        Returns:
        The stream
        Throws:
        sailpoint.tools.GeneralException - if the query fails
      • stream

        public static <A,​T> Function<A,​Stream<T>> stream​(Function<A,​?> input,
                                                                     Class<T> expectedType)
        Applies the given function to the input object and then makes a Stream out of it.

        When used with other functions, this is handy for flatMap.

        If the result of the function is not of the expected type, or is not a List, Map, or Set of them, returns an empty Stream.

        Parameters:
        input - A function to transform the input object
        expectedType - The expected type of the output
        Returns:
        A function from an input object to a Stream of output objects
      • toJson

        public static Supplier<StringtoJson​(Object obj)
        Returns a supplier that serializes the given object to JSON.

        The JSON text is lazily determined only on supplier invocation.

        If an error occurs during JSON invocation, a warning will be logged and an empty string will be returned.

        Parameters:
        obj - The object to serialize when the supplier is called
        Returns:
        A supplier to JSON
      • toXml

        public static Supplier<StringtoXml​(sailpoint.tools.xml.AbstractXmlObject spo)
        Returns a Supplier that translates the given AbstractXmlObject to XML.

        This can be used with modern log4j2 invocations, notably. The call to AbstractXmlObject.toXml() happens on invocation. The result is not cached, so if the object is changed, subsequent invocations of the Supplier may produce different output.

        Parameters:
        spo - The SailPointObject to serialize
        Returns:
        A supplier that translates the SPO to XML when invoked
      • value

        public static <T> Function<Map.Entry<?,​T>,​T> value()
        Returns a mapping function producing the value of the input map entry
        Type Parameters:
        T - The map entry’s value type
        Returns:
        A function producing the resulting value