package nl.nikhef.safaripark.extra;

import nl.nikhef.sfp.SFPDevice;

public class Module {

	public final SFPDevice dev;
	public final int bay;
	
	public Module(SFPDevice dev, int bay) {
		this.dev = dev;
		this.bay = bay;
	}
	
	public boolean isPresent()
	{
		return dev.isModulePresent(bay);
	}
	
	public String toString()
	{
		return dev.getModuleName(bay);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + bay;
		result = prime * result + ((dev == null) ? 0 : dev.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;
		Module other = (Module) obj;
		if (bay != other.bay)
			return false;
		if (dev == null) {
			if (other.dev != null)
				return false;
		} else if (!dev.equals(other.dev))
			return false;
		return true;
	}
	

	
	

}
