Record Class ClosePolicyWrapper<T>
java.lang.Object
java.lang.Record
org.aksw.vshell.registry.ClosePolicyWrapper<T>
- Type Parameters:
T-
- All Implemented Interfaces:
AutoCloseable
public record ClosePolicyWrapper<T>(T entity, AutoCloseable closeAction, boolean doClose)
extends Record
implements AutoCloseable
Helper class for wrapping entities with a close action for use with try-with-resources blocks.
Usage example:
try (ClosePolicyWrapper<T> wrapper = ClosePolicyWrapper.dontClose(entity)) { // Or use .doClose
// ...
}
-
Constructor Summary
ConstructorsConstructorDescriptionClosePolicyWrapper(T entity, AutoCloseable closeAction, boolean doClose) Creates an instance of aClosePolicyWrapperrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Returns the value of thecloseActionrecord component.booleandoClose()Returns the value of thedoCloserecord component.static <T extends AutoCloseable>
ClosePolicyWrapper<T> doClose(T entity) static <T extends AutoCloseable>
ClosePolicyWrapper<T> dontClose(T entity) entity()Returns the value of theentityrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ClosePolicyWrapper
Creates an instance of aClosePolicyWrapperrecord class.- Parameters:
entity- the value for theentityrecord componentcloseAction- the value for thecloseActionrecord componentdoClose- the value for thedoCloserecord component
-
-
Method Details
-
doClose
-
dontClose
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
entity
Returns the value of theentityrecord component.- Returns:
- the value of the
entityrecord component
-
closeAction
Returns the value of thecloseActionrecord component.- Returns:
- the value of the
closeActionrecord component
-
doClose
public boolean doClose()Returns the value of thedoCloserecord component.- Returns:
- the value of the
doCloserecord component
-