Record Class Constant<I>
java.lang.Object
java.lang.Record
org.microbean.bean.Constant<I>
- Type Parameters:
I- the singleton type- 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.assign.Aggregate
EMPTY_ASSIGNMENTS, EMPTY_DEPENDENCIES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal IInvokes thesingleton()method and returns its result.final Optional<DynamicConstantDesc<I>> Returns anOptionalcontaining the nominal descriptor for this instance, if one can be constructed, or an emptyOptionalif one cannot be constructed.final voiddestroy(I i, Destruction creation) Destroys the supplied contextual instance.final booleandestroys()Returnstrueif and only if the return value of an invocation of thesingleton()method isAutoCloseable.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thesingletonrecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.microbean.assign.Aggregate
assign, dependencies
-
Constructor Details
-
Constant
Creates a newConstant.- Parameters:
singleton- an object; must not benull- Throws:
NullPointerException- ifsingletonisnull
-
-
Method Details
-
create
Invokes thesingleton()method and returns its result.- Specified by:
createin interfaceFactory<I>- Parameters:
creation- aCreation; may benull; ignored- Returns:
- the result of invoking the
singleton()method - See Also:
-
destroys
Returnstrueif and only if the return value of an invocation of thesingleton()method isAutoCloseable.- Specified by:
destroysin interfaceFactory<I>- Returns:
trueif and only if the return value of an invocation of thesingleton()method isAutoCloseable- See Also:
-
destroy
Description copied from interface:FactoryDestroys the supplied contextual instance.The default implementation of this method closes the supplied contextual instance if it is an instance of
AutoCloseable, and closes the suppliedDestructionif it is non-null.- Specified by:
destroyin interfaceFactory<I>- Parameters:
i- the contextual instance to destroy; may benullin which case no action must be takencreation- the object supplied to theFactory.create(Creation)method represented here as aDestruction; may benull; must have an idempotentclose()method- See Also:
-
describeConstable
Description copied from interface:FactoryReturns anOptionalcontaining the nominal descriptor for this instance, if one can be constructed, or an emptyOptionalif one cannot be constructed.The default implementation of this method returns an
Optionalthat 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:
describeConstablein interfaceConstable- Specified by:
describeConstablein interfaceFactory<I>- Returns:
- an
Optionalcontaining the nominal descriptor for this instance, if one can be constructed, or an emptyOptionalif 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
-