Class AttributeDeltaUtil


  • public final class AttributeDeltaUtil
    extends Object
    Utility methods to retrieve values from instances of AttributeDelta.
    • Method Detail

      • getStringValue

        public static String getStringValue​(AttributeDelta attrDelta)
        Get the string value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the string value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the string value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not a string.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
      • getCharacterValue

        public static Character getCharacterValue​(AttributeDelta attrDelta)
        Get the character value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the character value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the character value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not a character.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
        Since:
        1.4
      • getGuardedByteArrayValue

        public static GuardedByteArray getGuardedByteArrayValue​(AttributeDelta attrDelta)
        Get the GuardedByteArray value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the guarded byte array value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the guarded byte array value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not a GuardedByteArray.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
        Since:
        1.4
      • getGuardedStringValue

        public static GuardedString getGuardedStringValue​(AttributeDelta attrDelta)
        Get the GuardedString value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the guarded string value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the guarded string value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not a GuardedString.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
      • getAsStringValue

        public static String getAsStringValue​(AttributeDelta attrDelta)
        Get the string value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the string value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the string value from list valuesToReplace for the attributeDelta.
        Throws:
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
      • getByteValue

        public static Byte getByteValue​(AttributeDelta attrDelta)
        Get the byte value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the byte value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the byte value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not a byte.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
        Since:
        1.4
      • getByteArrayValue

        public static Byte[] getByteArrayValue​(AttributeDelta attrDelta)
        Get the byte array value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the byte array value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the byte array value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not a byte array.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
        Since:
        1.4
      • getIntegerValue

        public static Integer getIntegerValue​(AttributeDelta attrDelta)
        Get the integer value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the integer value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the integer value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not an integer.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
      • getLongValue

        public static Long getLongValue​(AttributeDelta attrDelta)
        Get the long value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the long value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the long value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not a long.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
      • getFloatValue

        public static Float getFloatValue​(AttributeDelta attrDelta)
        Get the float value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the float value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the float value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not a float.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
        Since:
        1.4
      • getDateValue

        public static Date getDateValue​(AttributeDelta attrDelta)
        Get the date value from the specified (single-valued) attributeDelta that contains a long.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the date value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the date value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not a long.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
      • getDoubleValue

        public static Double getDoubleValue​(AttributeDelta attrDelta)
        Get the double value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the double value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the double value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not a double.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
      • getBigDecimalValue

        public static BigDecimal getBigDecimalValue​(AttributeDelta attrDelta)
        Get the big decimal value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the big decimal value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the big decimal value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not a big decimal.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
      • getBigIntegerValue

        public static BigInteger getBigIntegerValue​(AttributeDelta attrDelta)
        Get the big integer value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the big integer value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the big integer value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not a big integer.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
        Since:
        1.4
      • getBooleanValue

        public static Boolean getBooleanValue​(AttributeDelta attrDelta)
        Get the boolean value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the boolean value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the boolean value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not an Boolean.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
      • getMapValue

        public static Map<String,​Object> getMapValue​(AttributeDelta attrDelta)
        Get the map value from the specified (single-valued) attributeDelta.
        Parameters:
        attrDelta - AttributeDelta from which to retrieve the map value.
        Returns:
        null if the value is null or attributeDelta doesn't include valuesToReplace otherwise the map value from list valuesToReplace for the attributeDelta.
        Throws:
        ClassCastException - if the object in the attributeDelta is not an Map.
        IllegalArgumentException - if the attributeDelta is a multi-valued (rather than single-valued) or valuesToReplace is null.
      • getSingleValue

        public static Object getSingleValue​(AttributeDelta attr)
        Get the Object value from the specified (single-valued) attributeDelta.
        Returns:
        null if the attributeDelta's list of valuesToReplace is null or empty.
      • toMap

        public static Map<String,​AttributeDelta> toMap​(Collection<? extends AttributeDelta> attributesDelta)
        Transform a Collection of AttributeDelta instances into a Map. The key to each element in the map is the name of an AttributeDelta. The value of each element in the map is the AttributeDelta instance with that name.
        Parameters:
        attributesDelta - set of attributesDelta to transform to a map.
        Returns:
        a map of string and attributesDelta.
        Throws:
        NullPointerException - if the parameter attributesDelta is null.
      • getBasicAttributes

        public static Set<AttributeDelta> getBasicAttributes​(Set<AttributeDelta> attrsDelta)
        Filter out any special attributeDelta from the specified set. Special attributes include Name, Uid, and OperationalAttributes.
        Parameters:
        attrsDelta - set of AttributeDeltas to filter out the operational and default attributes.
        Returns:
        a set that only contains plain attributesDelta or empty.
      • getSpecialAttributes

        public static Set<AttributeDelta> getSpecialAttributes​(Set<AttributeDelta> attrsDelta)
        Filter out any basic attributes from the specified set, leaving only special attributes. Special attributes include Name, Uid, and OperationalAttributes.
        Parameters:
        attrsDelta - set of AttributeDeltas to filter out the basic attributes
        Returns:
        a set that only contains special attributes or an empty set if there are none.
      • filterUid

        public static Set<AttributeDelta> filterUid​(Set<AttributeDelta> attrsDelta)
        Returns a mutable copy of the original set with the uid attributeDelta removed.
        Parameters:
        attrsDelta - The original set. Must not be null.
        Returns:
        A mutable copy of the original set with the uid attributeDelta removed.
      • addUid

        public static Set<AttributeDelta> addUid​(Set<AttributeDelta> attrsDelta,
                                                 Object... values)
        Returns a mutable copy of the original set with the uid attributeDelta added.
        Parameters:
        attrsDelta - The original set. Must not be null.
        values - The uid's values. Must not be null.
        Returns:
        A mutable copy of the original set with the uid attributeDelta added.
      • isSpecialName

        public static boolean isSpecialName​(String name)
        Determines whether the specified attribute name is special in the sense of #createSpecialName.
        Parameters:
        name - the attribute name to test against.
        Returns:
        true if the attribute name is special.
      • namesEqual

        public static boolean namesEqual​(String name1,
                                         String name2)
        Compares two attributeDelta names for equality.
        Parameters:
        name1 - the first attributeDelta name.
        name2 - the second attributeDelta name.
        Returns:
        true if the two attributeDelta names are equal.
      • getAttributeDeltaForName

        public static AttributeDelta getAttributeDeltaForName​(Set<AttributeDelta> attrsDelta)
        Get the AttributeDelta attributeDelta for attribute Name from the specified set of attributesDelta.
        Parameters:
        attrsDelta - set of attributesDelta to search against.
        Returns:
        the AttributeDelta attributeDelta for attribute Name if it exist otherwise null.
      • getEnableDate

        public static Date getEnableDate​(Set<AttributeDelta> attrsDelta)
        Get the enable date from the set of attributesDelta.
        Parameters:
        attrsDelta - set of attributeDelta to find the enable date AttributeDelta.
        Returns:
        null if the attributeDelta does not exist and the value of the AttributeDelta if it does.