Package org.wildfly.security.authz
Interface Attributes
- All Known Implementing Classes:
AggregateAttributes,MapAttributes
public interface Attributes
A collection of string attributes.
By default, this interface provides a default implementation for all methods that perform writes to the collection. The default
implementation will always throw a UnsupportedOperationException, which means the collection is read-only by default.
If an implementation needs to also support writes it must override and implement all these default methods.
- Author:
- David M. Lloyd
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThe entry collection for a mapping.static interfaceThe entry collection for a mapping whose values are a distinct set. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault voidAdd a mapping for the given key at the given position.default booleanaddAll(String key, Collection<String> values) Add all the values from the given collection to the value collection for the given key.default booleanaddAll(Map<String, ? extends Collection<String>> map) Add all the values from the given map to this attributes collection.default voidAdd a value before the first mapping for the given key.default voidAdd a value after the last mapping for the given key.default AttributesReturns a read-only instance of this instance.default voidclear()Clear this collection, resetting its size to zero.default booleancontainsKey(String key) Determine if the given key has values in this collection.default booleancontainsValue(String key, String value) Determine if the given key has a mapping for the given value in this collection.copyAndRemove(String key) Remove all values for the given key from this collection, copying the values into a list which is returned.copyAndReplace(String key, Collection<String> values) Replace the mapping for the given key with the values copied from the given collection.entries()Get the entry collection.Get the collection of values for the given key.Get the mapping for the given key at the given position.default StringGet the first value mapped to the given key.default StringGet the last value mapped to the given key.default intGet the index of the first occurrence of the given value at the given key, if any.default booleanisEmpty()Determine if this collection is empty.keySet()Get a set comprised of all the keys in this collection.default intlastIndexOf(String key, String value) Get the index of the last occurrence of the given value at the given key, if any.default booleanRemove all values for the given key from this collection.default StringRemove and return the mapping for the given key at the given position.default booleanRemove the mapping for the given key at the given position if it matches the given existing value.default booleanRemove the all occurrences of the given value under the given key, if any.default StringremoveFirst(String key) Remove the first value mapped to the given key.default booleanremoveFirst(String key, String value) Remove the first occurrence of the given value under the given key, if any.default StringremoveLast(String key) Remove the last value mapped to the given key.default booleanremoveLast(String key, String value) Remove the last occurrence of the given value under the given key, if any.default voidremoveRange(String key, int from, int to) Remove all the values for the given key between thefromindex (inclusive) and thetoindex (exclusive).default StringModify the mapping for the given key at the given position.default booleanConditionally set a specific value of a given key to a new value, if the existing value matches theexpectparameter.intsize()Get the number of keys in this attribute collection.intGet the number of values mapped to the given key.default Collection<String>values()Get all the values of all the keys in this collection.
-
Field Details
-
EMPTY
Empty, read-only attribute collection.
-
-
Method Details
-
entries
Collection<Attributes.Entry> entries()Get the entry collection. Changes to the entry collection will modify this attribute collection, if it is writable. The returned entries will remain up to date with the state of this collection.- Returns:
- the entry collection
-
size
Get the number of values mapped to the given key.- Parameters:
key- the key- Returns:
- the number of mapped values
-
get
Get the collection of values for the given key. The result may implementAttributes.SetEntryif the values are distinct (for example, a role or group set).- Parameters:
key- the attribute name- Returns:
- the (possibly empty) attribute value collection
-
get
Get the mapping for the given key at the given position.- Parameters:
key- the keyidx- the index- Returns:
- the mapping value
- Throws:
IndexOutOfBoundsException- ifidxis less than 0 or greater than or equal tosize(key)
-
size
int size()Get the number of keys in this attribute collection.- Returns:
- the number of keys
-
remove
Remove all values for the given key from this collection.- Parameters:
key- the key- Returns:
trueif the key was found,falseotherwise- Throws:
UnsupportedOperationException- if this method is not implemented and the operation is not supported
-
add
Add a mapping for the given key at the given position.- Parameters:
key- the keyidx- the indexvalue- the mapping value- Throws:
IndexOutOfBoundsException- ifidxis less than 0 or greater than or equal tosize(key)UnsupportedOperationException- if this method is not implemented and the operation is not supported
-
set
Modify the mapping for the given key at the given position.- Parameters:
key- the keyidx- the indexvalue- the mapping value- Returns:
- the previous mapping value
- Throws:
IndexOutOfBoundsException- ifidxis less than 0 or greater than or equal tosize(key)UnsupportedOperationException- if this method is not implemented and the operation is not supported
-
remove
Remove and return the mapping for the given key at the given position. All later entries for that key are shifted up to fill in the gap left by the removed element.- Parameters:
key- the keyidx- the index- Returns:
- the previous mapping value
- Throws:
IndexOutOfBoundsException- ifidxis less than 0 or greater than or equal tosize(key)UnsupportedOperationException- if this method is not implemented and the operation is not supported
-
clear
default void clear()Clear this collection, resetting its size to zero.- Throws:
UnsupportedOperationException- if this method is not implemented and the operation is not supported
-
copyAndRemove
Remove all values for the given key from this collection, copying the values into a list which is returned.- Parameters:
key- the key- Returns:
- the values as a list (not
null)
-
values
Get all the values of all the keys in this collection. The returned collection can be used to modify this attributes collection.- Returns:
- the collection of all values (not
null)
-
keySet
Get a set comprised of all the keys in this collection. The returned set can be used to modify this attributes collection.- Returns:
- the set of all keys (not
null)
-
set
Conditionally set a specific value of a given key to a new value, if the existing value matches theexpectparameter.- Parameters:
key- the keyidx- the indexexpect- the expected valueupdate- the value to set- Returns:
trueif the actual value matched the expected value and was updated,falseotherwise- Throws:
IndexOutOfBoundsException- ifidxis less than 0 or greater than or equal tosize(key)
-
indexOf
Get the index of the first occurrence of the given value at the given key, if any.- Parameters:
key- the keyvalue- the value- Returns:
- the index, or -1 if the value was not found at the given key
-
lastIndexOf
Get the index of the last occurrence of the given value at the given key, if any.- Parameters:
key- the keyvalue- the value- Returns:
- the index, or -1 if the value was not found at the given key
-
removeRange
Remove all the values for the given key between thefromindex (inclusive) and thetoindex (exclusive).- Parameters:
key- the keyfrom- the start index (inclusive)to- the end index (exclusive)- Throws:
IndexOutOfBoundsException- ifidxis less than 0 or greater than or equal tosize(key)
-
getFirst
Get the first value mapped to the given key.- Parameters:
key- the key- Returns:
- the value
- Throws:
IndexOutOfBoundsException- if there are no values for the given key
-
getLast
Get the last value mapped to the given key.- Parameters:
key- the key- Returns:
- the value
- Throws:
IndexOutOfBoundsException- if there are no values for the given key
-
addFirst
Add a value before the first mapping for the given key.- Parameters:
key- the keyvalue- the value
-
addLast
Add a value after the last mapping for the given key.- Parameters:
key- the keyvalue- the value
-
removeFirst
Remove the first value mapped to the given key.- Parameters:
key- the key- Returns:
- the value
- Throws:
IndexOutOfBoundsException- if there are no values for the given key
-
removeLast
Remove the last value mapped to the given key.- Parameters:
key- the key- Returns:
- the value
- Throws:
IndexOutOfBoundsException- if there are no values for the given key
-
remove
Remove the mapping for the given key at the given position if it matches the given existing value. All later entries for that key are shifted up to fill in the gap left by the removed element.- Parameters:
key- the keyidx- the indexvalue- the expected previous mapping value- Returns:
trueif the value matched and was removed,falseotherwise- Throws:
IndexOutOfBoundsException- ifidxis less than 0 or greater than or equal tosize(key)
-
removeFirst
Remove the first occurrence of the given value under the given key, if any.- Parameters:
key- the keyvalue- the value to remove- Returns:
trueif the value was found and removed,falseotherwise
-
removeLast
Remove the last occurrence of the given value under the given key, if any.- Parameters:
key- the keyvalue- the value to remove- Returns:
trueif the value was found and removed,falseotherwise
-
removeAll
Remove the all occurrences of the given value under the given key, if any.- Parameters:
key- the keyvalue- the value to remove- Returns:
trueif the value was found and removed,falseotherwise
-
addAll
Add all the values from the given map to this attributes collection.- Parameters:
map- the map to copy from- Returns:
trueif elements were added,falseotherwise
-
addAll
Add all the values from the given collection to the value collection for the given key.- Parameters:
key- the keyvalues- the values to add- Returns:
trueif elements were added,falseotherwise
-
containsKey
Determine if the given key has values in this collection.- Parameters:
key- the key- Returns:
trueif the key has values,falseotherwise
-
containsValue
Determine if the given key has a mapping for the given value in this collection.- Parameters:
key- the keyvalue- the value- Returns:
trueif the key has a mapping to the given value,falseotherwise
-
copyAndReplace
Replace the mapping for the given key with the values copied from the given collection.- Parameters:
key- the keyvalues- the new values- Returns:
- a list containing the previously mapped values
-
isEmpty
default boolean isEmpty()Determine if this collection is empty.- Returns:
trueif the collection is empty,falseotherwise
-
asReadOnly
Returns a read-only instance of this instance.- Returns:
- a read-only instance of this instance.
-