@Test public void testEqualsAndHashCode() { final Operation op1 = new UpdatePriorityOperation("boo", 1337); final Operation op2 = new UpdatePriorityOperation("boo", 1337); Assert.assertEquals(op1, op2); Assert.assertEquals((long) op1.hashCode(), (long) op2.hashCode()); Assert.assertEquals(op1.toString(), op2.toString()); }
public String toString(boolean verbose) { StringBuilder sb = new StringBuilder(); if (verbose) { sb.append(String.format("Task [#%d]\n----------------------\n", this.id)); for (Operation op : this.getOperations()) { sb.append(String.format("-\t%s\n", op.toString())); } } else { sb.append( String.format("Task #[%d] - %d operation(s)", this.id, this.getOperations().size())); } return sb.toString(); }
public String toString() { if (operation == null) return ""; StringBuffer res = new StringBuffer("("); res.append(operation.toString()).append(","); if (Operand1 != null) res.append(Operand1.toString()); res.append(","); if (Operand2 != null) res.append(Operand2.toString()); res.append(","); if (Operand3 != null) res.append(Operand3.toString()); res.append(")"); return res.toString(); }
private static List<URIish> getURIs(final RemoteConfig cfg, final Operation op) { switch (op) { case FETCH: return cfg.getURIs(); case PUSH: { List<URIish> uris = cfg.getPushURIs(); if (uris.isEmpty()) uris = cfg.getURIs(); return uris; } default: throw new IllegalArgumentException(op.toString()); } }
public static OperationNode createNode(Operation type, Seed s) { switch (type) { case RGB: return new RGB_Space(s); // arithmetic case ABSOLUTE: return new Absolute(s); case ADD: return new Add(s); case DIVIDE: return new Divide(s); case EXPONENTIATE: return new Exponentiate(s); case INVERT: return new Invert(s); case MODULUS: return new Modulus(s); case MULTIPLY: return new Multiply(s); // trig case SINC: return new Sinc(s); case SINE: return new Sine(s); case SPIRAL: return new Spiral(s); case SQUIRCLE: return new Squircle(s); // LEAF case CONST: return new Const(s); case FLOWER: return new Flower(s); case GRADIENT_LINEAR: return new LinearGradient(s); case GRADIENT_RADIAL: return new RadialGradient(s); case POLAR_THETA: return new PolarTheta(s); } throw new IllegalArgumentException("Unknown operation type: " + type.toString()); }
public final Optional<DataType> traverse( StepType tree, Operation op, Iterator<String> keys, DataType data) { if (tree == null) { return Optional.empty(); } if (getStepType().isAssignableFrom(tree.getClass())) { String key = keys.next(); if (child == null) { // End of the Traversal so do the set or get switch (op) { case GET: return this.get(tree, key); case SET: return (Optional<DataType>) traversr.handleFinalSet(this, tree, key, data); case REMOVE: return this.remove(tree, key); default: throw new IllegalStateException("Invalid op:" + op.toString()); } } else { // We just an intermediate step, so traverse and then hand over control to our child Optional<Object> optSub = traversr.handleIntermediateGet(this, tree, key, op); if (optSub.isPresent()) { return child.traverse(optSub.get(), op, keys, data); } } } return Optional.empty(); }