package org.goko.core.gcode.rs274ngcv3.instruction;
import org.goko.core.common.exception.GkException;
import org.goko.core.gcode.rs274ngcv3.context.EnumUnit;
import org.goko.core.gcode.rs274ngcv3.context.GCodeContext;
import org.goko.core.gcode.rs274ngcv3.element.InstructionType;
public class UserLengthUnitsInstruction extends AbstractInstruction {
/** The specified unit */
private EnumUnit unit;
/** Constructor */
public UserLengthUnitsInstruction(EnumUnit unit) {
super(InstructionType.USER_LENGTH_UNITS);
this.unit = unit;
}
/** (inheritDoc)
* @see org.goko.core.gcode.element.IInstruction#apply(org.goko.core.gcode.rs274ngcv3.context.GCodeContext)
*/
@Override
public void apply(GCodeContext context) throws GkException {
context.setUnit(unit);
}
/**
* @return the unit
*/
public EnumUnit getUnit() {
return unit;
}
/** (inheritDoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((unit == null) ? 0 : unit.hashCode());
return result;
}
/** (inheritDoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
UserLengthUnitsInstruction other = (UserLengthUnitsInstruction) obj;
if (unit != other.unit)
return false;
return true;
}
}