AccountAddress implements Identity, Adaptor { @SuppressWarnings("unchecked") @Override public <T> T adapt(final Class<T> adaptor) { if (adaptor.isAssignableFrom(AccountAddress.class)) { return (T) this; } else if (adaptor.isAssignableFrom(ContractAddress.class)) { return (T) ContractAddress.of(getBytesValue()); } return null; } AccountAddress(final String encoded);  AccountAddress(final BytesValue bytesValue); protected  AccountAddress(); static AccountAddress of(final String encoded); static AccountAddress of(final BytesValue bytesValue); @Override String toString(); String getEncoded(); @Override String getValue(); @SuppressWarnings("unchecked") @Override T adapt(final Class<T> adaptor); static final int ADDRESS_BYTE_LENGTH; static final byte ADDRESS_PREFIX; static final AccountAddress EMPTY; }
@Test public void testAdapt() { final AccountAddress accountAddress = AccountAddress.of(encodedAddress); final AccountAddress accountActual = accountAddress.adapt(AccountAddress.class); final ContractAddress contractActual = accountAddress.adapt(ContractAddress.class); final AccountAddress accountExpected = AccountAddress.of(encodedAddress); final ContractAddress contractExpected = ContractAddress.of(encodedAddress); assertEquals(accountExpected, accountActual); assertEquals(contractExpected, contractActual); }