package ca.corefacility.bioinformatics.irida.service.analysis.workspace.galaxy;

import java.nio.file.Path;

import ca.corefacility.bioinformatics.irida.model.irida.IridaSequenceFile;
import ca.corefacility.bioinformatics.irida.model.workflow.execution.InputFileType;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Class linking together a sequence file path and the Galaxy file type.
 *
 */
public class SequenceFilePathType {
	private InputFileType fileType;
	private Path path;

	/**
	 * Creates a new {@link SequenceFilePathType}.
	 * 
	 * @param sequenceFile The specific sequence file.
	 */
	public SequenceFilePathType(IridaSequenceFile sequenceFile) {
		checkNotNull(sequenceFile, "sequenceFile is null");
		
		this.path = sequenceFile.getFile();
		this.fileType = sequenceFile.isGzipped() ? InputFileType.FASTQ_SANGER_GZ : InputFileType.FASTQ_SANGER;
	}

	public InputFileType getFileType() {
		return fileType;
	}

	public Path getPath() {
		return path;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((fileType == null) ? 0 : fileType.hashCode());
		result = prime * result + ((path == null) ? 0 : path.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SequenceFilePathType other = (SequenceFilePathType) obj;
		if (fileType != other.fileType)
			return false;
		if (path == null) {
			if (other.path != null)
				return false;
		} else if (!path.equals(other.path))
			return false;
		return true;
	}
}

@@ -100,16 +100,42 @@
 le.Path;
+%0Aimport java.util.Objects;
 %0A%0Aimport
@@ -760,18 +760,16 @@
 null%22);%0A
-%09%09
 %0A%09%09this.
@@ -1055,385 +1055,143 @@
 %7B%0A%09%09
-final int prime = 31;%0A%09%09int result = 1;%0A%09%09result = prime * result + ((fileType == null) ? 0 : fileType.hashCode());%0A%09%09result = prime * result + ((path == null) ? 0 : path.hashCode());%0A%09%09return result;%0A%09%7D%0A%0A%09@Override%0A%09public boolean equals(Object obj) %7B%0A%09%09if (this == obj)%0A%09%09%09return true;%0A%09%09if (obj == null)%0A%09%09%09return false;%0A%09%09if (getClass() != obj.getClass())%0A%09%09%09return false;%0A
+return Objects.hash(fileType, path);%0A%09%7D%0A%0A%09@Override%0A%09public boolean equals(Object obj) %7B%0A%09%09if (obj instanceof SequenceFilePathType) %7B%0A%09
 %09%09Se
@@ -1245,21 +1245,41 @@
 e) obj;%0A
+%0A
 %09%09
-if 
+%09return Objects.equals
 (fileTyp
@@ -1279,19 +1279,17 @@
 fileType
- !=
+,
  other.f
@@ -1300,161 +1300,64 @@
 ype)
-%0A%09%09%09return false;%0A%09%09if (path == null) %7B%0A%09%09%09if (other.path != null)%0A%09%09%09%09return false;%0A%09%09%7D else if (!path.equals(other.path))%0A%09%09%09return false;%0A%09%09return tru
+ && Objects.equals(path, other.path);%0A%09%09%7D%0A%0A%09%09return fals
 e;%0A%09

Simplify hashCode and equals