ConstantRecombiningBinomialTree extends RecombiningBinomialTree<T> { @Override public T getNode(final int step, final int node) { if (node > getMaxNodesForStep(step)) { throw new IllegalArgumentException("Maximum number of nodes for step " + step + " is " + getMaxNodesForStep(step)); } return _value; } ConstantRecombiningBinomialTree(final T value); @Override T getNode(final int step, final int node);  }
@Test public void test() { final double x = 3; final double y = 5; final RecombiningBinomialTree<Double> tree = new ConstantRecombiningBinomialTree<>(x); RecombiningBinomialTree<Double> other = new ConstantRecombiningBinomialTree<>(x); assertEquals(tree, other); assertEquals(tree.hashCode(), other.hashCode()); other = new ConstantRecombiningBinomialTree<>(y); assertFalse(tree.equals(other)); assertArrayEquals(tree.getNodes(), new Double[][] {new Double[] {x}}); for (int i = 0; i < 100; i++) { for (int j = 0; j < i + 1; j++) { assertEquals(tree.getNode(i, j), x, 0); } try { tree.getNode(i, i + 100); Assert.fail(); } catch (final IllegalArgumentException e) { } } }