T
- type of the borrowed referencepublic interface Borrowed<T> extends AutoCloseable
Borrowed references can prevent certain actions from being executed as long as the borrowed reference is valid.
null
is not a valid borrowed reference, any attempt to borrow a null reference is
explicitly prohibited by the framework.
Borrowed references are reference counted, the user is responsible for releasing the
reference when it is no longer used. Use of convenience methods like Managed.doto(java.util.function.Function)
are encouraged to accomplish this.
Modifier and Type | Method and Description |
---|---|
void |
close()
The close method, as defined by
AutoCloseable.close() to allow for try-with-resources
statements. |
T |
get()
Fetch the borrowed reference.
|
boolean |
isValid()
Check if the borrowed reference is valid.
|
void |
release()
Release the borrowed reference.
|
boolean isValid()
A valid borrowed reference is guaranteed to have a value.
true
if the borrowed reference is valid.T get()
IllegalStateException
- if the borrowed reference is not validvoid release()
A borrowed reference can only be released once. This is required to allow the underlying framework to free up the borrowed reference when it is no longer used.
void close()
AutoCloseable.close()
to allow for try-with-resources
statements.
Override of AutoCloseable.close()
to remove throws signature.
close
in interface AutoCloseable
Copyright © 2017. All rights reserved.