Commits

Simon Denier  committed a2b502f

Cleanup / extract common to superclass

  • Participants
  • Parent commits 4fc6b0e

Comments (0)

Files changed (6)

File src/net/geco/control/ecardmodes/AbstractHandlerWithCourseDetector.java

+/**
+ * Copyright (c) 2012 Simon Denier
+ * Released under the MIT License (see LICENSE file)
+ */
+package net.geco.control.ecardmodes;
+
+import net.geco.control.Control;
+import net.geco.control.GecoControl;
+import net.geco.control.RunnerControl;
+
+/**
+ * @author Simon Denier
+ * @since Mar 25, 2012
+ *
+ */
+public abstract class AbstractHandlerWithCourseDetector extends Control {
+
+	protected RunnerControl runnerControl;
+
+	protected CourseDetector courseDetector;
+
+	public AbstractHandlerWithCourseDetector(GecoControl gecoControl, CourseDetector detector) {
+		super(gecoControl);
+		runnerControl = getService(RunnerControl.class);
+		courseDetector = detector;
+	}
+
+}

File src/net/geco/control/ecardmodes/AnonCreationHandler.java

  */
 package net.geco.control.ecardmodes;
 
-import net.geco.control.Control;
 import net.geco.control.GecoControl;
-import net.geco.control.RunnerControl;
 import net.geco.control.RunnerCreationException;
 import net.geco.model.Course;
 import net.geco.model.Runner;
  * @since Mar 21, 2012
  *
  */
-public class AnonCreationHandler extends Control implements ECardHandler {
-
-	protected RunnerControl runnerControl;
-	protected CourseDetector courseDetector;
+public class AnonCreationHandler extends AbstractHandlerWithCourseDetector implements ECardHandler {
 
 	public AnonCreationHandler(GecoControl gecoControl, CourseDetector detector) {
-		super(gecoControl);
-		runnerControl = getService(RunnerControl.class);
-		courseDetector = detector;		
+		super(gecoControl, detector);
 	}
 	
 	@Override
-	public String handleFinish(RunnerRaceData data) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+	public String handleFinish(RunnerRaceData data) {return null;}
 
 	@Override
 	public String handleDuplicate(RunnerRaceData data, Runner runner) {
 	}
 
 	@Override
-	public String handleUnregistered(RunnerRaceData data, String cardId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+	public String handleUnregistered(RunnerRaceData data, String cardId) {return null;}
 
 	@Override
 	public boolean foundInArchive() {

File src/net/geco/control/ecardmodes/ArchiveLookupHandler.java

 public class ArchiveLookupHandler extends AnonCreationHandler implements ECardHandler {
 
 	private ArchiveManager archiveManager;
+	
 	private Status customStatus;
+	
 	private boolean foundInArchive = false;
 
 	public ArchiveLookupHandler(GecoControl gecoControl, CourseDetector detector) {
 	}
 	
 	@Override
-	public String handleFinish(RunnerRaceData data) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+	public String handleFinish(RunnerRaceData data) {return null;}
 
 	@Override
-	public String handleDuplicate(RunnerRaceData data, Runner runner) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+	public String handleDuplicate(RunnerRaceData data, Runner runner) {return null;}
 
 	@Override
 	public String handleUnregistered(RunnerRaceData data, String cardId) {

File src/net/geco/control/ecardmodes/AutoCheckerHandler.java

  */
 package net.geco.control.ecardmodes;
 
-import net.geco.control.Control;
 import net.geco.control.GecoControl;
-import net.geco.control.RunnerControl;
 import net.geco.control.StageControl;
 import net.geco.model.Course;
 import net.geco.model.Runner;
  * @since Mar 21, 2012
  *
  */
-public class AutoCheckerHandler extends Control implements ECardHandler {
+public class AutoCheckerHandler extends AbstractHandlerWithCourseDetector implements ECardHandler {
 
 	private StageControl stageControl;
 
-	private RunnerControl runnerControl;
-
-	private CourseDetector courseDetector;
-
 	public AutoCheckerHandler(GecoControl gecoControl, CourseDetector detector) {
-		super(gecoControl);
+		super(gecoControl, detector);
 		this.stageControl = getService(StageControl.class);
-		this.runnerControl = getService(RunnerControl.class);
-		this.courseDetector = detector;
 	}
 
 	@Override
 	}
 
 	@Override
-	public String handleDuplicate(RunnerRaceData data, Runner runner) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+	public String handleDuplicate(RunnerRaceData data, Runner runner) {return null;}
 
 	@Override
-	public String handleUnregistered(RunnerRaceData data, String cardId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+	public String handleUnregistered(RunnerRaceData data, String cardId) {return null;}
 
 	@Override
 	public boolean foundInArchive() {

File src/net/geco/control/ecardmodes/CopyRunnerHandler.java

  */
 package net.geco.control.ecardmodes;
 
-import net.geco.control.Control;
 import net.geco.control.GecoControl;
-import net.geco.control.RunnerControl;
 import net.geco.model.Course;
 import net.geco.model.Runner;
 import net.geco.model.RunnerRaceData;
  * @since Mar 23, 2012
  *
  */
-public class CopyRunnerHandler extends Control implements ECardHandler {
-
-	private RunnerControl runnerControl;
-	private CourseDetector courseDetector;
+public class CopyRunnerHandler extends AbstractHandlerWithCourseDetector implements ECardHandler {
 
 	public CopyRunnerHandler(GecoControl gecoControl, CourseDetector detector) {
-		super(gecoControl);
-		runnerControl = getService(RunnerControl.class);
-		courseDetector = detector;		
+		super(gecoControl, detector);
 	}
 
 	@Override
-	public String handleFinish(RunnerRaceData data) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+	public String handleFinish(RunnerRaceData data) {return null;}
 
 	@Override
 	public String handleDuplicate(RunnerRaceData data, Runner runner) {
 	}
 
 	@Override
-	public String handleUnregistered(RunnerRaceData data, String cardId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+	public String handleUnregistered(RunnerRaceData data, String cardId) {return null;}
 
 	@Override
 	public boolean foundInArchive() {

File src/net/geco/control/ecardmodes/RegisterRunnerHandler.java

 	
 	private RunnerControl runnerControl;
 
-	private ArchiveManager archive;
+	private ArchiveManager archiveManager;
 
 	private RunnerBuilder builder;
 
 		super(gecoControl);
 		stageControl = getService(StageControl.class);
 		runnerControl = getService(RunnerControl.class);
-		archive = getService(ArchiveManager.class);
+		archiveManager = getService(ArchiveManager.class);
 		builder = new RunnerBuilder(factory());
 	}
 
 	@Override
-	public String handleFinish(RunnerRaceData data) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+	public String handleFinish(RunnerRaceData data) {return null;}
 
 	@Override
-	public String handleDuplicate(RunnerRaceData data, Runner runner) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+	public String handleDuplicate(RunnerRaceData data, Runner runner) {return null;}
 
 	@Override
-	public String handleUnregistered(RunnerRaceData d, String cardId) {
+	public String handleUnregistered(RunnerRaceData nullRunner, String cardId) {
 		Course autoCourse = stageControl.getAutoCourse();
-		Runner runner = archive.findAndCreateRunner(cardId, autoCourse);
+		Runner runner = archiveManager.findAndCreateRunner(cardId, autoCourse);
 		RunnerRaceData runnerData = builder.buildRunnerData();
 		runnerData.getResult().setStatus(Status.RUN);
 		if( runner == null ) {