Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/com/toddfast/mutagen/Mutation.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Represents a single change that can be made to a subject, identified
* unambiguously by a state.
*
*
* @author Todd Fast
*/
public interface Mutation<I extends Comparable<I>> {
Expand Down Expand Up @@ -33,20 +33,20 @@ public void mutate(Context context)
* Context provided to an executing mutation
*
*/
public static interface Context {
public static interface Context<I extends Comparable<I>> {

/**
*
*
*/
public Subject<?> getSubject();
public Subject<I> getSubject();


/**
*
*
*/
public Coordinator<?> getCoordinator();
public Coordinator<I> getCoordinator();


/**
Expand Down
22 changes: 6 additions & 16 deletions src/main/java/com/toddfast/mutagen/Plan.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import java.util.List;

import com.toddfast.mutagen.Mutation.Context;

/**
* A prepared plan for mutating the target subject through a sequence of states
*
*
* @author Todd Fast
*/
public interface Plan<I extends Comparable<I>> {
Expand All @@ -15,34 +17,27 @@ public interface Plan<I extends Comparable<I>> {
*/
public Subject<I> getSubject();


/**
*
*
*/
public Coordinator<I> getCoordinator();


/**
*
*
*/
public List<Mutation<I>> getMutations();


/**
*
*
*/
public Result<I> execute()
throws MutagenException;


public Result<I> execute(Context<I> context) throws MutagenException;


////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////

/**
*
Expand All @@ -56,35 +51,30 @@ public static interface Result<I extends Comparable<I>> {
*/
public Plan<I> getPlan();


/**
*
*
*/
public boolean isMutationComplete();


/**
*
*
*/
public <I extends Comparable<I>> State<I> getLastState();


/**
*
*
*/
public List<Mutation<I>> getCompletedMutations();


/**
*
*
*/
public List<Mutation<I>> getRemainingMutations();


/**
*
*
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/toddfast/mutagen/Planner.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.toddfast.mutagen;

import com.toddfast.mutagen.Mutation.Context;

/**
* Produces plans that can be executed to mutate the target subject to a given
* state, using the coordinator to accept or reject mutations.
*
*
* @author Todd Fast
*/
public interface Planner<I extends Comparable<I>> {
Expand All @@ -12,5 +14,5 @@ public interface Planner<I extends Comparable<I>> {
*
*
*/
public Plan<I> getPlan(Subject<I> subject, Coordinator<I> coordinator);
public Plan<I> getPlan(Context<I> context);
}
14 changes: 7 additions & 7 deletions src/main/java/com/toddfast/mutagen/basic/BasicContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
/**
* Implements the basic contract of {@link Mutation.Context}. Logs to
* {@link System.out} and {@link System.err}.
*
*
* @author Todd Fast
*/
public class BasicContext implements Mutation.Context {
public class BasicContext<I extends Comparable<I>> implements Mutation.Context<I> {

/**
*
*
*/
public BasicContext(Subject<?> subject, Coordinator<?> coordinator) {
public BasicContext(Subject<I> subject, Coordinator<I> coordinator) {
super();
this.subject=subject;
this.coordinator=coordinator;
Expand All @@ -28,7 +28,7 @@ public BasicContext(Subject<?> subject, Coordinator<?> coordinator) {
*
*/
@Override
public Subject<?> getSubject() {
public Subject<I> getSubject() {
return subject;
}

Expand All @@ -38,7 +38,7 @@ public Subject<?> getSubject() {
*
*/
@Override
public Coordinator<?> getCoordinator() {
public Coordinator<I> getCoordinator() {
return coordinator;
}

Expand Down Expand Up @@ -79,6 +79,6 @@ public void error(String message, Object... parameters) {
// Fields
////////////////////////////////////////////////////////////////////////////

private Subject<?> subject;
private Coordinator<?> coordinator;
private Subject<I> subject;
private Coordinator<I> coordinator;
}
Loading