- All Superinterfaces:
org.refcodes.mixin.ValidAccessor
- All Known Implementing Classes:
Scope
public interface Coupler
extends org.refcodes.mixin.ValidAccessor
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceCoupler.Operation<SUBJECT,PARAM extends Coupler, RET> Definition of a method with single argument of typeCoupler.Nested classes/interfaces inherited from interface org.refcodes.mixin.ValidAccessor
org.refcodes.mixin.ValidAccessor.ValidBuilder<B extends org.refcodes.mixin.ValidAccessor.ValidBuilder<B>>, org.refcodes.mixin.ValidAccessor.ValidMutator, org.refcodes.mixin.ValidAccessor.ValidProperty -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasNext()default <RET> RETinvokeNext(Function<Coupler, RET> aOperation) default <SUBJECT,RET>
RETinvokeNext(SUBJECT aSuccessor, Coupler.Operation<SUBJECT, Coupler, RET> aOperation) default <RET> RETinvokeNextOr(Function<Coupler, RET> aSuccessor, RET aDefaultValue) default <SUBJECT,RET>
RETinvokeNextOr(SUBJECT aSuccessor, Coupler.Operation<SUBJECT, Coupler, RET> aOperation, RET aDefaultValue) booleanisValid()To be used by an element's method being invoked with aCouplerinstance as argument belonging to a chain of elements.next()Retrieves the succeedingCoupler.
-
Method Details
-
hasNext
boolean hasNext()Determines whether thisCouplerhas a succeedingCoupler. In case we have no followingCoupler, we reached the end of the chain.- Returns:
- True in case there is a succeeding
Coupler, false in case we reached the end of the chain.
-
next
Coupler next()Retrieves the succeedingCoupler. In case there is no succeedingCoupler, then an exception is thrown.- Returns:
- The succeeding
Coupler. - Throws:
IllegalStateException- thrown in case this is the lastCouplerin the chain and there is no succeeding coupler.
-
invokeNext
-
invokeNextOr
Invokes a given operation with the succeedingCoupler(as ofnext()) as parameter in case there is a succeedingCoupler(as ofhasNext()) and returns the operation's result or the default value in case there is no succeedingCoupler. The operation to be invoked must have a single argument being of typeCoupler.- Type Parameters:
RET- The return type of the operation to be invoked.- Parameters:
aSuccessor- The succeeding operation (having a single argument of typeCoupler) to be invoked.aDefaultValue- The default value to be returned in case there is no succeedingCoupler.- Returns:
- The according result of the invoked operation or the given
default value in case there is no succeeding
Coupler.
-
invokeNext
default <SUBJECT,RET> RET invokeNext(SUBJECT aSuccessor, Coupler.Operation<SUBJECT, Coupler, RET> aOperation) Invokes a given operation on the given successor with the succeedingCoupler(as ofnext()) as parameter in case there is a succeedingCoupler(as ofhasNext()) and returns the operation's result or null in case there is no succeedingCoupleror the successor is null. The operation to be invoked must have a single argument being of typeCoupler.- Type Parameters:
SUBJECT- The instance which is subject of operation.RET- The return type of the operation to be invoked.- Parameters:
aSuccessor- The instance on which to invoke the successor operation.aOperation- The successor operation (having a single argument of typeCoupler) to be invoked.- Returns:
- The according result of the invoked operation or the given
default value in case there is no successor or succeeding
Coupler.
-
invokeNextOr
default <SUBJECT,RET> RET invokeNextOr(SUBJECT aSuccessor, Coupler.Operation<SUBJECT, Coupler, RET> aOperation, RET aDefaultValue) Invokes a given operation on the given successor with the succeedingCoupler(as ofnext()) as parameter in case there is a succeedingCoupler(as ofhasNext()) and returns the operation's result or the default value in case there is no succeedingCoupleror the successor is null. The operation to be invoked must have a single argument being of typeCoupler.- Type Parameters:
SUBJECT- The instance which is subject of operation.RET- The return type of the operation to be invoked.- Parameters:
aSuccessor- The instance on which to invoke the successor operation.aOperation- The successor operation (having a single argument of typeCoupler) to be invoked.aDefaultValue- The default value to be returned in case there is no successor or succeedingCoupler.- Returns:
- The according result of the invoked operation or the given
default value in case there is no successor or succeeding
Coupler.
-
isValid
boolean isValid()To be used by an element's method being invoked with aCouplerinstance as argument belonging to a chain of elements. Returns true in case theCoupleris in a valid state for the operation to be executed. In caseisValid()returns false, then the operation should skip execution and pass the succeedingCoupleras ofnext()to its successor element in the chain.- Specified by:
isValidin interfaceorg.refcodes.mixin.ValidAccessor
-