public class PermutationGroups
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
PermutationGroups.PermutationGroup
A single permutation group, which contains a collection of argument permutations which all lead to the same result.
|
Constructor and Description |
---|
PermutationGroups() |
Modifier and Type | Method and Description |
---|---|
void |
addFinalizeListener(Executor listener)
Adds a new listener to be notified when the
finalize() method is called. |
void |
addNewGroupListener(java.util.function.Consumer<PermutationGroups.PermutationGroup> listener)
Adds a new listener to be notified when new permutation groups are added.
|
void |
addStartListener(Executor listener)
Adds a new listener to be notified when the
start() method is called. |
void |
finalize()
Mark that there are no more results to be submitted.
|
PermutationGroups.PermutationGroup |
getPermutationGroup(JavaResult result,
java.util.List<?> input,
TestAllPermutations.JavaResultComparer comparer)
Gets the permutation group for the given result and comparer.
|
java.util.Collection<PermutationGroups.PermutationGroup> |
getPermutationGroups()
Gets the current view of the existing permutation groups.
|
boolean |
isFinalized()
Check whether finalize() has been called.
|
boolean |
isStarted()
Returns whether calculation should have already started.
|
boolean |
isStopped()
Returns whether calculation should be stopped.
|
void |
removeFinalizeListener(Executor listener)
Removes a listener to be notified when the finalize method is called.
|
void |
removeNewGroupListener(java.util.function.Consumer<PermutationGroups.PermutationGroup> listener)
Removes a listener to be notified when new permutation groups are added.
|
void |
removeStartListener(Executor listener)
Removes a listener to be notified when the start method is called.
|
void |
start()
Allow to start the actual calculation.
|
void |
stop()
Allow to stop the actual calculation.
|
public void start()
isStarted()
is true, before any work is performed. The startListeners will be notified the first time this method is called.public boolean isStarted()
public void stop()
public boolean isStopped()
public PermutationGroups.PermutationGroup getPermutationGroup(JavaResult result, java.util.List<?> input, TestAllPermutations.JavaResultComparer comparer)
result
- The execution result.input
- The execution input.comparer
- The result comparer.java.lang.IllegalStateException
- If the result has been finalized.public java.util.Collection<PermutationGroups.PermutationGroup> getPermutationGroups()
finalize()
method has been called correctly previous to this method, then no permutation groups may be added afterwards.public void finalize()
finalize
in class java.lang.Object
java.lang.IllegalStateException
- If a thread is still in the critical section of getting a group.public boolean isFinalized()
public void addNewGroupListener(java.util.function.Consumer<PermutationGroups.PermutationGroup> listener)
listener
- The listener which is notified about the permutation groups which were added.public void addFinalizeListener(Executor listener)
finalize()
method is called. The listener will be called
at most once per PermutationGroups instance. After this listener is called, it is guaranteed that no new permutation groups may be added.
This method is not thread-safe.executor
- The listener which is notified about the finalize method being called.public void addStartListener(Executor listener)
start()
method is called. The listener will be called
at most once per PermutationGroups
instance.
This method is not thread-safe.listener
- The listener which is notified about the start method being called.public void removeNewGroupListener(java.util.function.Consumer<PermutationGroups.PermutationGroup> listener)
listener
- The listener to be removed.public void removeFinalizeListener(Executor listener)
listener
- The listener to be removed.public void removeStartListener(Executor listener)
listener
- The listener to be removed.