use of io.nem.symbol.catapult.builders.MosaicIdDto in project nem2-sdk-java by nemtech.
the class MosaicGlobalRestriction method serialize.
/**
* @return serializes the state of this object.
*/
public byte[] serialize() {
MosaicIdDto mosaicId = SerializationUtils.toMosaicIdDto(getMosaicId());
GlobalKeyValueSetBuilder restrictions = GlobalKeyValueSetBuilder.create(getRestrictions().entrySet().stream().sorted(Entry.comparingByKey()).map(this::toGlobalKeyValueSetBuilder).collect(Collectors.toList()));
MosaicGlobalRestrictionEntryBuilder entry = MosaicGlobalRestrictionEntryBuilder.create(mosaicId, restrictions);
return MosaicRestrictionEntryBuilder.createGlobal((short) getVersion(), entry).serialize();
}
use of io.nem.symbol.catapult.builders.MosaicIdDto 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();
}
}
use of io.nem.symbol.catapult.builders.MosaicIdDto in project nem2-sdk-java by nemtech.
the class MosaicAddressRestriction method serialize.
/**
* @return serializes the state of this object.
*/
public byte[] serialize() {
MosaicIdDto mosaicId = SerializationUtils.toMosaicIdDto(getMosaicId());
AddressDto targetAddress = SerializationUtils.toAddressDto(getTargetAddress());
AddressKeyValueSetBuilder restrictions = AddressKeyValueSetBuilder.create(getRestrictions().entrySet().stream().sorted(Entry.comparingByKey()).map(this::toAddressKeyValueBuilder).collect(Collectors.toList()));
MosaicAddressRestrictionEntryBuilder entry = MosaicAddressRestrictionEntryBuilder.create(mosaicId, targetAddress, restrictions);
return MosaicRestrictionEntryBuilder.createAddress((short) getVersion(), entry).serialize();
}
use of io.nem.symbol.catapult.builders.MosaicIdDto in project nem2-sdk-java by nemtech.
the class BalanceChangeReceipt method serialize.
/**
* Serialize receipt and returns receipt bytes
*
* @return receipt bytes
*/
@Override
public byte[] serialize() {
short version = (short) getVersion().getValue();
ReceiptTypeDto type = ReceiptTypeDto.rawValueOf((short) getType().getValue());
MosaicBuilder mosaic = MosaicBuilder.create(new MosaicIdDto(getMosaicId().getIdAsLong()), SerializationUtils.toAmount(getAmount()));
AddressDto targetAddress = SerializationUtils.toAddressDto(getTargetAddress());
return BalanceChangeReceiptBuilder.create(version, type, mosaic, targetAddress).serialize();
}
use of io.nem.symbol.catapult.builders.MosaicIdDto in project nem2-sdk-java by nemtech.
the class BalanceTransferReceipt method serialize.
/**
* Serialize receipt and returns receipt bytes
*
* @return receipt bytes
*/
@Override
public byte[] serialize() {
final short version = (short) getVersion().getValue();
final ReceiptTypeDto type = ReceiptTypeDto.rawValueOf((short) getType().getValue());
final MosaicBuilder mosaic = MosaicBuilder.create(new MosaicIdDto(getMosaicId().getIdAsLong()), SerializationUtils.toAmount(getAmount()));
final AddressDto senderAddress = SerializationUtils.toAddressDto(getSenderAddress());
final AddressDto recipientAddress = SerializationUtils.toAddressDto(getRecipientAddress());
return BalanceTransferReceiptBuilder.create(version, type, mosaic, senderAddress, recipientAddress).serialize();
}
Aggregations