Search in sources :

Example 1 with AddressResolutionEntryBuilder

use of io.nem.symbol.catapult.builders.AddressResolutionEntryBuilder in project nem2-sdk-java by nemtech.

the class ResolutionEntry method serialize.

/**
 * Serialize receipt and returns receipt bytes
 *
 * @return receipt bytes
 */
public byte[] serialize() {
    ReceiptSourceBuilder receiptSourceBuilder = ReceiptSourceBuilder.create((int) getReceiptSource().getPrimaryId(), (int) getReceiptSource().getSecondaryId());
    Class<?> resolutionClass = this.resolved.getClass();
    if (Address.class.isAssignableFrom(resolutionClass)) {
        AddressDto addressBuilder = new AddressDto(SerializationUtils.fromAddressToByteBuffer((Address) getResolved()));
        AddressResolutionEntryBuilder builder = AddressResolutionEntryBuilder.create(receiptSourceBuilder, addressBuilder);
        return builder.serialize();
    } else {
        MosaicIdDto mosaicIdDto = SerializationUtils.toMosaicIdDto((MosaicId) getResolved());
        MosaicResolutionEntryBuilder builder = MosaicResolutionEntryBuilder.create(receiptSourceBuilder, mosaicIdDto);
        return builder.serialize();
    }
}
Also used : AddressResolutionEntryBuilder(io.nem.symbol.catapult.builders.AddressResolutionEntryBuilder) Address(io.nem.symbol.sdk.model.account.Address) MosaicIdDto(io.nem.symbol.catapult.builders.MosaicIdDto) MosaicResolutionEntryBuilder(io.nem.symbol.catapult.builders.MosaicResolutionEntryBuilder) AddressDto(io.nem.symbol.catapult.builders.AddressDto) ReceiptSourceBuilder(io.nem.symbol.catapult.builders.ReceiptSourceBuilder)

Aggregations

AddressDto (io.nem.symbol.catapult.builders.AddressDto)1 AddressResolutionEntryBuilder (io.nem.symbol.catapult.builders.AddressResolutionEntryBuilder)1 MosaicIdDto (io.nem.symbol.catapult.builders.MosaicIdDto)1 MosaicResolutionEntryBuilder (io.nem.symbol.catapult.builders.MosaicResolutionEntryBuilder)1 ReceiptSourceBuilder (io.nem.symbol.catapult.builders.ReceiptSourceBuilder)1 Address (io.nem.symbol.sdk.model.account.Address)1