Class DefaultThreadContext
java.lang.Object
com.sap.cloud.sdk.cloudplatform.thread.DefaultThreadContext
- All Implemented Interfaces:
ThreadContext
This class represents the default implementation of
ThreadContext
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
containsProperty
(String name) Check whether a property with the given name is present and readable.Create a newThreadContext
containing all properties of this context.boolean
<T> io.vavr.control.Try<T>
getPropertyValue
(String name) Retrieves aTry
of the property's value for the given name.int
hashCode()
<T> io.vavr.control.Option<Property<T>>
removeProperty
(String name) Removes the property with the given name.void
setPropertyIfAbsent
(String name, Property<?> value) Sets a value for the property for the given name, if it has not been set before.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.sap.cloud.sdk.cloudplatform.thread.ThreadContext
setProperty, setPropertyIfAbsent
-
Constructor Details
-
DefaultThreadContext
public DefaultThreadContext()
-
-
Method Details
-
getPropertyValue
Description copied from interface:ThreadContext
Retrieves aTry
of the property's value for the given name. TheTry
is considered to fail in case of exceptions or if the property does not exist. Implementations have to ensure that this method is thread-safe.- Specified by:
getPropertyValue
in interfaceThreadContext
- Type Parameters:
T
- The generic value type.- Parameters:
name
- The name of the property.- Returns:
- The value wrapped in a
Try
.
-
setPropertyIfAbsent
public void setPropertyIfAbsent(@Nonnull String name, @Nonnull Property<?> value) throws ThreadContextPropertyException Description copied from interface:ThreadContext
Sets a value for the property for the given name, if it has not been set before. Implementations have to ensure that this method is thread-safe.- Specified by:
setPropertyIfAbsent
in interfaceThreadContext
- Parameters:
name
- The name of the property.value
- AProperty
.- Throws:
ThreadContextPropertyException
- If there is an issue while setting the property.
-
removeProperty
@Nonnull public <T> io.vavr.control.Option<Property<T>> removeProperty(@Nonnull String name) throws ClassCastException Description copied from interface:ThreadContext
Removes the property with the given name.Caution: Implementations may not be thread-safe!
- Specified by:
removeProperty
in interfaceThreadContext
- Type Parameters:
T
- The generic value type.- Parameters:
name
- The name of the property.- Returns:
- A
Option
holding the removed value, orOption.none()
if the property did not exist before. - Throws:
ClassCastException
- If the property cannot be cast to the desired type.
-
containsProperty
Description copied from interface:ThreadContext
Check whether a property with the given name is present and readable.Caution: Implementations may not be thread-safe!
- Specified by:
containsProperty
in interfaceThreadContext
- Parameters:
name
- The name of the property.- Returns:
- A boolean indicating whether the property does exist and is readable.
-
duplicate
Description copied from interface:ThreadContext
Create a newThreadContext
containing all properties of this context. Both the new and the existing context will point to the same property objects. This is useful for passing on a context to a new thread, without the two contexts interfering with each other.Caution: Implementations may not be thread-safe!
- Specified by:
duplicate
in interfaceThreadContext
- Returns:
- A new instance of
ThreadContext
.
-
toString
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getProperties
-