Interface Boolean2ObjectFunction<V>
-
- All Known Implementing Classes:
AbstractBoolean2ObjectFunction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Boolean2ObjectFunction<V> extends Function<Boolean,V>
A type-specificFunction; provides some additional methods that use polymorphism to avoid (un)boxing.Type-specific versions of
get(),put()andremove()cannot rely onnullto denote absence of a key. Rather, they return a default return value, which is set to 0/false at creation, but can be changed using thedefaultReturnValue()method.For uniformity reasons, even functions returning objects implement the default return value (of course, in this case the default return value is initialized to
null).The default implementation of optional operations just throw an
UnsupportedOperationException, except for the type-specificcontainsKey(), which return true. Generic versions of accessors delegate to the corresponding type-specific counterparts following the interface rules.Warning: to fall in line as much as possible with the standard map interface, it is required that standard versions of
get(),put()andremove()for maps with primitive-type keys or values returnnullto denote missing keys rather than wrap the default return value in an object. In case both keys and values are reference types, the default return value must be returned instead, thus violating the standard map interface when the default return value is notnull.- See Also:
Function
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default Boolean2ByteFunctionandThenByte(Object2ByteFunction<V> after)default Boolean2CharFunctionandThenChar(Object2CharFunction<V> after)default Boolean2DoubleFunctionandThenDouble(Object2DoubleFunction<V> after)default Boolean2FloatFunctionandThenFloat(Object2FloatFunction<V> after)default Boolean2IntFunctionandThenInt(Object2IntFunction<V> after)default Boolean2LongFunctionandThenLong(Object2LongFunction<V> after)default <T> Boolean2ObjectFunction<T>andThenObject(Object2ObjectFunction<V,T> after)default <T> Boolean2ReferenceFunction<T>andThenReference(Object2ReferenceFunction<V,T> after)default Boolean2ShortFunctionandThenShort(Object2ShortFunction<V> after)default Byte2ObjectFunction<V>composeByte(Byte2BooleanFunction before)default Char2ObjectFunction<V>composeChar(Char2BooleanFunction before)default Double2ObjectFunction<V>composeDouble(Double2BooleanFunction before)default Float2ObjectFunction<V>composeFloat(Float2BooleanFunction before)default Int2ObjectFunction<V>composeInt(Int2BooleanFunction before)default Long2ObjectFunction<V>composeLong(Long2BooleanFunction before)default <T> Object2ObjectFunction<T,V>composeObject(Object2BooleanFunction<T> before)default <T> Reference2ObjectFunction<T,V>composeReference(Reference2BooleanFunction<T> before)default Short2ObjectFunction<V>composeShort(Short2BooleanFunction before)default booleancontainsKey(boolean key)Returns true if this function contains a mapping for the specified key.default booleancontainsKey(Object key)Deprecated.Please use the corresponding type-specific method instead.default VdefaultReturnValue()Gets the default return value.default voiddefaultReturnValue(V rv)Sets the default return value (optional operation).Vget(boolean key)Returns the value to which the given key is mapped.default Vget(Object key)Deprecated.Please use the corresponding type-specific method instead.default Vput(boolean key, V value)Adds a pair to the map (optional operation).default Vput(Boolean key, V value)Deprecated.Please use the corresponding type-specific method instead.default Vremove(boolean key)Removes the mapping with the given key (optional operation).default Vremove(Object key)Deprecated.Please use the corresponding type-specific method instead.
-
-
-
Method Detail
-
put
default V put(boolean key, V value)
Adds a pair to the map (optional operation).- Parameters:
key- the key.value- the value.- Returns:
- the old value, or the default return value if no value was present for the given key.
- See Also:
Function.put(Object,Object)
-
get
V get(boolean key)
Returns the value to which the given key is mapped.- Parameters:
key- the key.- Returns:
- the corresponding value, or the default return value if no value was present for the given key.
- See Also:
Function.get(Object)
-
remove
default V remove(boolean key)
Removes the mapping with the given key (optional operation).- Parameters:
key- the key.- Returns:
- the old value, or the default return value if no value was present for the given key.
- See Also:
Function.remove(Object)
-
put
@Deprecated default V put(Boolean key, V value)
Deprecated.Please use the corresponding type-specific method instead.Associates the specified value with the specified key in this function (optional operation).- Specified by:
putin interfaceFunction<Boolean,V>- Parameters:
key- the key.value- the value.- Returns:
- the old value, or
nullif no value was present for the given key. - See Also:
Map.put(Object,Object)
-
get
@Deprecated default V get(Object key)
Deprecated.Please use the corresponding type-specific method instead.Returns the value associated by this function to the specified key.- Specified by:
getin interfaceFunction<Boolean,V>- Parameters:
key- the key.- Returns:
- the corresponding value, or
nullif no value was present for the given key. - See Also:
Map.get(Object)
-
remove
@Deprecated default V remove(Object key)
Deprecated.Please use the corresponding type-specific method instead.Removes this key and the associated value from this function if it is present (optional operation).- Specified by:
removein interfaceFunction<Boolean,V>- Parameters:
key- the key.- Returns:
- the old value, or
nullif no value was present for the given key. - See Also:
Map.remove(Object)
-
containsKey
default boolean containsKey(boolean key)
Returns true if this function contains a mapping for the specified key.Note that for some kind of functions (e.g., hashes) this method will always return true. In particular, this default implementation always returns true.
- Parameters:
key- the key.- Returns:
- true if this function associates a value to
key. - See Also:
Function.containsKey(Object)
-
containsKey
@Deprecated default boolean containsKey(Object key)
Deprecated.Please use the corresponding type-specific method instead.Returns true if this function contains a mapping for the specified key.Note that for some kind of functions (e.g., hashes) this method will always return true. This default implementation, in particular, always return true.
- Specified by:
containsKeyin interfaceFunction<Boolean,V>- Parameters:
key- the key.- Returns:
- true if this function associates a value to
key. - See Also:
Map.containsKey(Object)
-
defaultReturnValue
default void defaultReturnValue(V rv)
Sets the default return value (optional operation). This value must be returned by type-specific versions ofget(),put()andremove()to denote that the map does not contain the specified key. It must be 0/false/nullby default.- Parameters:
rv- the new default return value.- See Also:
defaultReturnValue()
-
defaultReturnValue
default V defaultReturnValue()
Gets the default return value.This default implementation just return the default null value of the type (
nullfor objects, 0 for scalars, false for Booleans).- Returns:
- the current default return value.
-
andThenByte
default Boolean2ByteFunction andThenByte(Object2ByteFunction<V> after)
-
composeByte
default Byte2ObjectFunction<V> composeByte(Byte2BooleanFunction before)
-
andThenShort
default Boolean2ShortFunction andThenShort(Object2ShortFunction<V> after)
-
composeShort
default Short2ObjectFunction<V> composeShort(Short2BooleanFunction before)
-
andThenInt
default Boolean2IntFunction andThenInt(Object2IntFunction<V> after)
-
composeInt
default Int2ObjectFunction<V> composeInt(Int2BooleanFunction before)
-
andThenLong
default Boolean2LongFunction andThenLong(Object2LongFunction<V> after)
-
composeLong
default Long2ObjectFunction<V> composeLong(Long2BooleanFunction before)
-
andThenChar
default Boolean2CharFunction andThenChar(Object2CharFunction<V> after)
-
composeChar
default Char2ObjectFunction<V> composeChar(Char2BooleanFunction before)
-
andThenFloat
default Boolean2FloatFunction andThenFloat(Object2FloatFunction<V> after)
-
composeFloat
default Float2ObjectFunction<V> composeFloat(Float2BooleanFunction before)
-
andThenDouble
default Boolean2DoubleFunction andThenDouble(Object2DoubleFunction<V> after)
-
composeDouble
default Double2ObjectFunction<V> composeDouble(Double2BooleanFunction before)
-
andThenObject
default <T> Boolean2ObjectFunction<T> andThenObject(Object2ObjectFunction<V,T> after)
-
composeObject
default <T> Object2ObjectFunction<T,V> composeObject(Object2BooleanFunction<T> before)
-
andThenReference
default <T> Boolean2ReferenceFunction<T> andThenReference(Object2ReferenceFunction<V,T> after)
-
composeReference
default <T> Reference2ObjectFunction<T,V> composeReference(Reference2BooleanFunction<T> before)
-
-