Package org.kiwiproject.io
Record Class KiwiIO.CloseableResource
java.lang.Object
java.lang.Record
org.kiwiproject.io.KiwiIO.CloseableResource
- Record Components:
object- the resource that can be closedcloseMethodNames- a non-null, non-empty list of close method names
- Enclosing class:
- KiwiIO
public static record KiwiIO.CloseableResource(@Nullable Object object, List<String> closeMethodNames)
extends Record
Represents a resource that can be closed using a "close" method.
Allows multiple close method names to be specified, which can be useful
in situations where you want to close several resources that have
different "close" methods. For example, any AutoCloseable
contains a "close" method while any ExecutorService
has both "shutdown" and "shutdownNow" methods.
If you only need a single clsoe method name, or the default close method names, you can use one of the secondary constructors.
-
Constructor Summary
ConstructorsConstructorDescriptionCloseableResource(@Nullable Object object) Create a new instance with a default set of close method names.CloseableResource(@Nullable Object object, String closeMethodName) Create a new instance with a single close method name.CloseableResource(@Nullable Object object, List<String> closeMethodNames) Creates an instance of aCloseableResourcerecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecloseMethodNamesrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@Nullable Objectobject()Returns the value of theobjectrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
CloseableResource
Creates an instance of aCloseableResourcerecord class.- Parameters:
object- the value for theobjectrecord componentcloseMethodNames- the value for thecloseMethodNamesrecord component
-
CloseableResource
Create a new instance with a default set of close method names.- Parameters:
object- the resource that can be closed- See Also:
-
CloseableResource
Create a new instance with a single close method name.- Parameters:
object- the resource that can be closedcloseMethodName- the single close method name
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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. All components in this record class are compared withObjects::equals(Object,Object). -
object
Returns the value of theobjectrecord component.- Returns:
- the value of the
objectrecord component
-
closeMethodNames
Returns the value of thecloseMethodNamesrecord component.- Returns:
- the value of the
closeMethodNamesrecord component
-