public final class ProxyDestructor extends java.lang.Object implements CleanAction<java.lang.Class<?>>
Native proxies do not implement any interface (e.g., CloseableNativeProxy
)
and use this class so that there is no public #close method available in the interface
of the proxy, making the risk of misuse smaller.
All method parameters are non-null by default.
This class is not thread-safe.
Constructor and Description |
---|
ProxyDestructor(NativeHandle nativeHandle,
java.lang.Class<?> proxyClass,
java.util.function.LongConsumer destructorFunction)
Creates a new destructor of a native proxy.
|
Modifier and Type | Method and Description |
---|---|
void |
clean()
Closes the native handle, so that it can no longer be accessed, and performs a clean action,
passing the native handle value.
|
static ProxyDestructor |
newRegistered(Cleaner cleaner,
NativeHandle nativeHandle,
java.lang.Class<?> proxyClass,
java.util.function.LongConsumer destructorFunction)
Creates a new destructor of a native proxy, registered in the given cleaner.
|
java.util.Optional<java.lang.Class<?>> |
resourceType()
Returns the description of the type of resource this action corresponds to.
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
from
public ProxyDestructor(NativeHandle nativeHandle, java.lang.Class<?> proxyClass, java.util.function.LongConsumer destructorFunction)
nativeHandle
- a handle to the native objectproxyClass
- a class of the proxydestructorFunction
- a clean function to perform@CanIgnoreReturnValue public static ProxyDestructor newRegistered(Cleaner cleaner, NativeHandle nativeHandle, java.lang.Class<?> proxyClass, java.util.function.LongConsumer destructorFunction)
cleaner
- a cleaner to register the destructor innativeHandle
- a handle to the native objectproxyClass
- a class of proxydestructorFunction
- a clean function to performpublic void clean()
If native handle is not valid, does nothing.
This method is idempotent.
clean
in interface CleanAction<java.lang.Class<?>>
public java.util.Optional<java.lang.Class<?>> resourceType()
CleanAction
resourceType
in interface CleanAction<java.lang.Class<?>>
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2018 Exonum. All rights reserved.