package ie.dcu.auto;
import java.io.File;
/**
* Immutable class encapsulating an input for the automation.
*
* @author Kevin McGuinness
*/
public class AutomationInput {
/**
* The input image file.
*/
public final File imageFile;
/**
* The input ground-truth mask file.
*/
public final File groundTruthFile;
/**
* Create an automation input with the given image and ground
* truth file.
*
* @param imageFile
* The image file (cannot be null).
* @param groundTruthFile
* The ground-truth mask file (cannot be null).
*/
public AutomationInput(File imageFile, File groundTruthFile) {
if (imageFile == null) {
throw new IllegalArgumentException("imageFile == null");
}
if (groundTruthFile == null) {
throw new IllegalArgumentException("groundTruthFile == null");
}
this.imageFile = imageFile;
this.groundTruthFile = groundTruthFile;
}
/**
* Returns true if both the image and ground truth files exist.
*/
public boolean filesExist() {
return imageFile.isFile() && groundTruthFile.isFile();
}
/**
* Returns the image file.
*/
public File getImageFile() {
return imageFile;
}
/**
* Returns the ground-truth file.
*/
public File getGroundTruthFile() {
return groundTruthFile;
}
/**
* Returns a deep copy of the object.
*/
@Override
protected AutomationInput clone() {
return new AutomationInput(imageFile, groundTruthFile);
}
/**
* Compare for equality.
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof AutomationInput) {
AutomationInput x = (AutomationInput) obj;
return x.imageFile.equals(imageFile) &&
x.groundTruthFile.equals(groundTruthFile);
}
return false;
}
/**
* Hash code override.
*/
@Override
public int hashCode() {
return imageFile.hashCode() + groundTruthFile.hashCode();
}
/**
* Returns a string representation
*/
@Override
public String toString() {
return imageFile.getName() + "," + groundTruthFile.getName();
}
}