public Operation IT_InsertInsert(Operation op1, Operation op2) { if (op1.getPosition() < op2.getPosition()) return op1; else if (op1.getPosition() == op2.getPosition() && op1.getId().compareTo(op2.getId()) < 0) { return op1; } else { op1.setPosition(op1.getPosition() + op2.getObj().getLength()); return op1; } }
public static Operation fromId(int id) { // Linear scan is very fast for small N for (Operation op : values()) { if (op.getId() == id) { return op; } } throw new IllegalArgumentException("Corrupt operation ID " + id + " detected."); }
public void setOperation(@Nonnull Operation operation) { Preconditions.checkNotNull(operation, "operation cannot be NULL."); data.setInt("Operation", operation.getId()); }