T - type of unsafe entitypublic class AbstractUnsafeCodeDecorator<T> extends Object
Abstract class for decorating unsafe entities (e.g. classes from plugins).
This class is intended to help implementing classes wrap methods from the underlying entity and react on unexpected exceptions by logging them instead of rethrowing.
This class exposes some utility methods to wrap execution of actual methods with BambooPluginUtils.callUnsafeCode(BambooPluginUtils.Callable).
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractUnsafeCodeDecorator(T entity)
Creates a new instance of the decorator for the entity.
|
| Modifier and Type | Method and Description |
|---|---|
protected <V> V |
executeUnsafeCode(@NotNull String methodName,
@NotNull Callable<V> unsafeCallable)
Helper method to execute unsafe code and log exception if any occurs.
|
protected <V> V |
executeUnsafeCode(@NotNull String methodName,
@NotNull Callable<V> unsafeCallable,
@NotNull Supplier<V> defaultValueSupplier)
Helper method to execute unsafe code and log exception if any occurs.
|
protected <V> V |
executeUnsafeCode(@NotNull String methodName,
@NotNull Callable<V> unsafeCallable,
V defaultValue)
Helper method to execute unsafe code and log exception if any occurs.
|
protected void |
executeUnsafeCode(@NotNull String methodName,
@NotNull Runnable unsafeRunnable)
Helper method to execute unsafe code and log exception if any occurs.
|
T |
getEntity()
Wrapped entity.
|
protected AbstractUnsafeCodeDecorator(@NotNull
T entity)
entity - entity to decorate@NotNull public T getEntity()
@Nullable
protected <V> V executeUnsafeCode(@NotNull
@NotNull String methodName,
@NotNull
@NotNull Callable<V> unsafeCallable)
V - result typemethodName - name of the executed methodunsafeCallable - callable which will execute the unsafe method@NotNull
protected <V> V executeUnsafeCode(@NotNull
@NotNull String methodName,
@NotNull
@NotNull Callable<V> unsafeCallable,
@NotNull
V defaultValue)
V - result typemethodName - name of the executed methodunsafeCallable - callable which will execute the unsafe methoddefaultValue - default value to return if unexpected exception occurs@NotNull
protected <V> V executeUnsafeCode(@NotNull
@NotNull String methodName,
@NotNull
@NotNull Callable<V> unsafeCallable,
@NotNull
@NotNull Supplier<V> defaultValueSupplier)
V - result typemethodName - name of the executed methodunsafeCallable - callable which will execute the unsafe methoddefaultValueSupplier - supplier of default value to return if unexpected exception occursprotected void executeUnsafeCode(@NotNull
@NotNull String methodName,
@NotNull
@NotNull Runnable unsafeRunnable)
methodName - name of the executed methodunsafeRunnable - runnable which will execute the unsafe methodCopyright © 2022 Atlassian Software Systems Pty Ltd. All rights reserved.