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(String methodName,
Callable<V> unsafeCallable)
Helper method to execute unsafe code and log exception if any occurs.
|
protected <V> V |
executeUnsafeCode(String methodName,
Callable<V> unsafeCallable,
Supplier<V> defaultValueSupplier)
Helper method to execute unsafe code and log exception if any occurs.
|
protected <V> V |
executeUnsafeCode(String methodName,
Callable<V> unsafeCallable,
V defaultValue)
Helper method to execute unsafe code and log exception if any occurs.
|
protected void |
executeUnsafeCode(String methodName,
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 String methodName, @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 String methodName, @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 String methodName, @NotNull Callable<V> unsafeCallable, @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 occursCopyright © 2017 Atlassian Software Systems Pty Ltd. All rights reserved.