Class Bags


  • public final class Bags
    extends Object
    This class consists exclusively of static methods that operate on or return Bags. NOTE: do not merge this into Bag at risk of violating the Acyclic Dependencies principle.
    • Field Detail

      • DUMB_VALIDATOR

        public static final Bag.Validator DUMB_VALIDATOR
        Dumb validator that does nothing, typically used for MustBePresent=False on XACML AttributeDesignator/AttributeSelector elements
    • Method Detail

      • empty

        public static <AV extends AttributeValueBag<AV> empty​(Datatype<AV> elementDatatype,
                                                                IndeterminateEvaluationException causeForEmpty)
                                                         throws IllegalArgumentException
        Creates instance of immutable empty bag with given exception as reason for bag being empty (no attribute value), e.g. error occurred during evaluation
        Parameters:
        causeForEmpty - reason for empty bag (optional but should be specified whenever possible, to help troubleshoot)
        elementDatatype - bag element datatype
        Returns:
        bag
        Throws:
        IllegalArgumentException - if elementDatatype == null
      • emptyAttributeBag

        public static <AV extends AttributeValueAttributeBag<AV> emptyAttributeBag​(Datatype<AV> elementDatatype,
                                                                                     IndeterminateEvaluationException causeForEmpty,
                                                                                     AttributeSource attributeValueSource)
                                                                              throws IllegalArgumentException
        Creates instance of immutable empty attribute bag containing val and only val value with given exception as reason for bag being empty (no attribute value), e.g. error occurred during evaluation,
        Parameters:
        elementDatatype - bag element datatype
        causeForEmpty - reason for empty bag (optional but should be specified whenever possible, to help troubleshoot)
        attributeValueSource - attribute value source
        Returns:
        bag
        Throws:
        IllegalArgumentException - if val == null || elementDatatype == null
      • singleton

        public static <AV extends AttributeValueBag<AV> singleton​(Datatype<AV> elementDatatype,
                                                                    AV val)
                                                             throws IllegalArgumentException
        Creates instance of immutable bag containing val and only val value
        Parameters:
        elementDatatype - bag element datatype
        val - the val and only val value in the bag
        Returns:
        bag
        Throws:
        IllegalArgumentException - if val == null || elementDatatype == null
      • singletonAttributeBag

        public static <AV extends AttributeValueAttributeBag<AV> singletonAttributeBag​(Datatype<AV> elementDatatype,
                                                                                         AV val,
                                                                                         AttributeSource attributeValueSource)
                                                                                  throws IllegalArgumentException
        Creates instance of immutable attribute bag containing val and only val value
        Parameters:
        elementDatatype - bag element datatype
        val - the val and only val value in the bag
        attributeValueSource - attribute value source
        Returns:
        bag
        Throws:
        IllegalArgumentException - if val == null || elementDatatype == null
      • newBag

        public static <AV extends AttributeValueBag<AV> newBag​(Datatype<AV> elementDatatype,
                                                                 Collection<AV> values)
                                                          throws IllegalArgumentException
        Creates instance of immutable bag of values.
        Parameters:
        values - bag values, typically a List for ordered results, e.g. attribute values for which order matters; or it may be a Set for result of bag/Set functions (intersection, union...)
        elementDatatype - bag element datatype
        Returns:
        bag
        Throws:
        IllegalArgumentException - if elementDatatype == null or values has at least one element which is null: values != null && !values.isEmpty() && values.iterator().next() == null
      • newAttributeBag

        public static <AV extends AttributeValueAttributeBag<AV> newAttributeBag​(Datatype<AV> elementDatatype,
                                                                                   Collection<AV> values,
                                                                                   AttributeSource attributeBagSource)
                                                                            throws IllegalArgumentException
        Creates instance of immutable attribute bag.
        Parameters:
        values - bag values, typically a List for ordered results, e.g. attribute values for which order matters; or it may be a Set for result of bag/Set functions (intersection, union...)
        elementDatatype - bag element datatype
        attributeBagSource - source of the attribute values
        Returns:
        attribute bag
        Throws:
        IllegalArgumentException - if elementDatatype == null or values has at least one element which is null: values != null && !values.isEmpty() && values.iterator().next() == null
      • newAttributeBag

        public static <AV extends AttributeValueAttributeBag<AV> newAttributeBag​(Datatype<AV> elementDatatype,
                                                                                   Collection<AV> values)
                                                                            throws IllegalArgumentException
        Creates instance of immutable attribute bag with AttributeSources.REQUEST as attribute source. Use newAttributeBag(Datatype, Collection, AttributeSource) instead if attribute bag comes from another source, e.g. AttributeProvider.
        Parameters:
        values - bag values, typically a List for ordered results, e.g. attribute values for which order matters; or it may be a Set for result of bag/Set functions (intersection, union...)
        elementDatatype - bag element datatype
        Returns:
        attribute bag
        Throws:
        IllegalArgumentException - if elementDatatype == null or values has at least one element which is null: values != null && !values.isEmpty() && values.iterator().next() == null