private class EngineDiscoveryRequestResolution.DefaultContext extends java.lang.Object implements SelectorResolver.Context
| Modifier and Type | Field and Description |
|---|---|
private TestDescriptor |
parent |
| Constructor and Description |
|---|
DefaultContext(TestDescriptor parent) |
| Modifier and Type | Method and Description |
|---|---|
<T extends TestDescriptor> |
addToParent(java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)
Add a
TestDescriptor to an unspecified parent, usually the
engine descriptor, by applying the supplied Function to the
new parent. |
<T extends TestDescriptor> |
addToParent(java.util.function.Supplier<DiscoverySelector> parentSelectorSupplier,
java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)
Add a
TestDescriptor to a parent, specified by the DiscoverySelector returned by the supplied Supplier, by
applying the supplied Function to the new parent. |
private <T extends TestDescriptor> |
createAndAdd(TestDescriptor parent,
java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator) |
java.util.Optional<TestDescriptor> |
resolve(DiscoverySelector selector)
Resolve the supplied
TestDescriptor, if possible. |
private final TestDescriptor parent
DefaultContext(TestDescriptor parent)
public <T extends TestDescriptor> java.util.Optional<T> addToParent(java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)
SelectorResolver.ContextTestDescriptor to an unspecified parent, usually the
engine descriptor, by applying the supplied Function to the
new parent.
The parent will be the engine descriptor unless another parent has
already been determined, i.e. if the selector that is being resolved
is the result of expanding a SelectorResolver.Match.
If the result of applying the Function is present, it will be added as a child of the
parent TestDescriptor unless a descriptor with the same
unique ID was added
earlier.
addToParent in interface SelectorResolver.ContextT - the type of the new TestDescriptorcreator - Function that will be called with the new
parent to determine the new TestDescriptor to be added; must
not return nullTestDescriptor or the previously existing one
with the same unique ID; never null but potentially emptypublic <T extends TestDescriptor> java.util.Optional<T> addToParent(java.util.function.Supplier<DiscoverySelector> parentSelectorSupplier, java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)
SelectorResolver.ContextTestDescriptor to a parent, specified by the DiscoverySelector returned by the supplied Supplier, by
applying the supplied Function to the new parent.
Unless another parent has already been determined, i.e. if the
selector that is being resolved is the result of expanding a SelectorResolver.Match, the DiscoverySelector returned by the supplied Supplier will
be used to determine the parent. If no parent is found, the supplied
Function will not be called. If there are multiple potential
parents, an exception will be thrown. Otherwise, the resolved
TestDescriptor will be used as the parent and passed to the
supplied Function.
If the result of applying the Function is present, it will be added as a child of the
parent TestDescriptor unless a descriptor with the same
unique ID was added
earlier.
addToParent in interface SelectorResolver.ContextT - the type of the new TestDescriptorcreator - Function that will be called with the new
parent to determine the new TestDescriptor to be added; must
not return nullTestDescriptor or the previously existing one
with the same unique ID; never null but potentially emptypublic java.util.Optional<TestDescriptor> resolve(DiscoverySelector selector)
SelectorResolver.ContextTestDescriptor, if possible.
Calling this method has the same effect as returning a partial match from a SelectorResolver: the children of the resulting TestDescriptor will only be resolved if a subsequent resolution
finds an exact match that contains a TestDescriptor with the
same unique ID.
resolve in interface SelectorResolver.Contextselector - the selector to resolveTestDescriptor; never null but
potentially emptyprivate <T extends TestDescriptor> java.util.Optional<T> createAndAdd(TestDescriptor parent, java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)