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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleancontainsProperty(String name) Check whether a property with the given name is present and readable.Create a newThreadContextcontaining all properties of this context.boolean<T> io.vavr.control.Try<T>getPropertyValue(String name) Retrieves aTryof the property's value for the given name.inthashCode()<T> io.vavr.control.Option<Property<T>>removeProperty(String name) Removes the property with the given name.voidsetPropertyIfAbsent(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, waitMethods inherited from interface com.sap.cloud.sdk.cloudplatform.thread.ThreadContext
setProperty, setPropertyIfAbsent
-
Constructor Details
-
DefaultThreadContext
public DefaultThreadContext()
-
-
Method Details
-
getPropertyValue
Description copied from interface:ThreadContextRetrieves aTryof the property's value for the given name. TheTryis 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:
getPropertyValuein 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:ThreadContextSets 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:
setPropertyIfAbsentin 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:ThreadContextRemoves the property with the given name.Caution: Implementations may not be thread-safe!
- Specified by:
removePropertyin interfaceThreadContext- Type Parameters:
T- The generic value type.- Parameters:
name- The name of the property.- Returns:
- A
Optionholding 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:ThreadContextCheck whether a property with the given name is present and readable.Caution: Implementations may not be thread-safe!
- Specified by:
containsPropertyin 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:ThreadContextCreate a newThreadContextcontaining 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:
duplicatein interfaceThreadContext- Returns:
- A new instance of
ThreadContext.
-
toString
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getProperties
-