Record Class Constant<I>
java.lang.Object
java.lang.Record
org.microbean.bean.Constant<I>
- Type Parameters:
I
- the type of the singleton- Record Components:
singleton
- the singleton
A
Factory
that returns its singleton from its create(Request)
method.- Author:
- Laird Nelson
- See Also:
-
Field Summary
Fields inherited from interface org.microbean.bean.Aggregate
EMPTY_ASSIGNMENTS, EMPTY_DEPENDENCIES
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal I
Invokes thesingleton()
method and returns its result.final Optional
<DynamicConstantDesc<I>> Returns anOptional
containing the nominal descriptor for this instance, if one can be constructed, or an emptyOptional
if one cannot be constructed.final void
Destroys the supplied contextual instance.final boolean
destroys()
Returnstrue
if and only if the return value of an invocation of thesingleton()
method isAutoCloseable
.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.Returns the value of thesingleton
record component.final String
toString()
Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.microbean.bean.Aggregate
assign, dependencies
-
Constructor Details
-
Constant
Creates a newConstant
.- Parameters:
singleton
- an object; must not benull
- Throws:
NullPointerException
- ifsingleton
isnull
-
-
Method Details
-
create
Invokes thesingleton()
method and returns its result.- Specified by:
create
in interfaceFactory<I>
- Parameters:
r
- aRequest
; may benull
; ignored- Returns:
- the result of invoking the
singleton()
method - See Also:
-
destroys
Returnstrue
if and only if the return value of an invocation of thesingleton()
method isAutoCloseable
.- Specified by:
destroys
in interfaceFactory<I>
- Returns:
true
if and only if the return value of an invocation of thesingleton()
method isAutoCloseable
- See Also:
-
destroy
Description copied from interface:Factory
Destroys the supplied contextual instance.- Specified by:
destroy
in interfaceFactory<I>
- Parameters:
i
- the contextual instance; may benull
if thisFactory
suports returningnull
from itsFactory.create(Request)
methodrequest
- theRequest
that was present at creation time; may benull
if it wasnull
at creation time
-
describeConstable
Description copied from interface:Factory
Returns anOptional
containing the nominal descriptor for this instance, if one can be constructed, or an emptyOptional
if one cannot be constructed.The default implementation of this method returns an
Optional
that contains a dynamic constant representing an invocation of the implementation's constructor that takes no arguments. The resolution of this dynamic constant is undefined if the implementation does not declare such a constructor.- Specified by:
describeConstable
in interfaceConstable
- Specified by:
describeConstable
in interfaceFactory<I>
- Returns:
- an
Optional
containing the nominal descriptor for this instance, if one can be constructed, or an emptyOptional
if one cannot be constructed
-
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. All components in this record class are compared withObjects::equals(Object,Object)
. -
singleton
-