### Question:
Token extends Symbol { public Reduction asReduction() { return data instanceof Reduction ? (Reduction)data : null; } Token();  Token(Object data);  Token(Symbol symbol, Object data);  Token(Symbol symbol, Object data, Position position); void appendData(String moreData); Reduction asReduction(); String asString(); int getState(); Object getData(); Position getPosition(); void setState(int state); void setData(Object data); void setPosition(Position position); void setSymbol(Symbol symbol);  }### Answer:
@Test public void testAsReduction() { Reduction reduction = new Reduction(); Token token = new Token(); token.setData(reduction); assertEquals("should have returned reduction", reduction, token.asReduction()); token = new Token(); token.setData(null); assertNull("should return null", token.asReduction()); token.setData("Hello"); assertNull("should return null", token.asReduction()); token.setData(new Token()); assertNull("should return null", token.asReduction()); }