BlockHash extends Hash implements Adaptor, Encodable { @SuppressWarnings("unchecked") @Override public <T> T adapt(Class<T> adaptor) { if (adaptor.isAssignableFrom(BlockHash.class)) { return (T) this; } else if (adaptor.isAssignableFrom(TxHash.class)) { return (T) TxHash.of(getBytesValue()); } else if (adaptor.isAssignableFrom(ContractTxHash.class)) { return (T) ContractTxHash.of(getBytesValue()); } return null; } BlockHash(final String encoded);  BlockHash(final BytesValue bytesValue); static BlockHash of(final String encoded); static BlockHash of(final BytesValue bytesValue); @SuppressWarnings("unchecked") @Override T adapt(Class<T> adaptor); static final BlockHash EMPTY; }
@Test public void testAdapt() { final BlockHash blockHash = BlockHash.of(encodedHash); assertEquals(BlockHash.of(encodedHash), blockHash.adapt(Hash.class)); assertEquals(BlockHash.of(encodedHash), blockHash.adapt(BlockHash.class)); assertEquals(TxHash.of(encodedHash), blockHash.adapt(TxHash.class)); assertEquals(ContractTxHash.of(encodedHash), blockHash.adapt(ContractTxHash.class)); }