Search in sources :

Example 1 with MetadataTypeDto

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

the class Metadata method serialize.

/**
 * @return serializes the state of this object.
 */
public byte[] serialize() {
    AddressDto sourceAddress = SerializationUtils.toAddressDto(getSourceAddress());
    AddressDto targetAddress = SerializationUtils.toAddressDto(getTargetAddress());
    ScopedMetadataKeyDto scopedMetadataKey = new ScopedMetadataKeyDto(getScopedMetadataKey().longValue());
    long targetId = getTargetId().map(this::toTargetId).orElse(0L);
    MetadataTypeDto metadataType = MetadataTypeDto.rawValueOf((byte) getMetadataType().getValue());
    MetadataValueBuilder value = toMetadataValueBuilder(getValue());
    return MetadataEntryBuilder.create((short) getVersion(), sourceAddress, targetAddress, scopedMetadataKey, targetId, metadataType, value).serialize();
}
Also used : MetadataValueBuilder(io.nem.symbol.catapult.builders.MetadataValueBuilder) AddressDto(io.nem.symbol.catapult.builders.AddressDto) ScopedMetadataKeyDto(io.nem.symbol.catapult.builders.ScopedMetadataKeyDto) MetadataTypeDto(io.nem.symbol.catapult.builders.MetadataTypeDto)

Aggregations

AddressDto (io.nem.symbol.catapult.builders.AddressDto)1 MetadataTypeDto (io.nem.symbol.catapult.builders.MetadataTypeDto)1 MetadataValueBuilder (io.nem.symbol.catapult.builders.MetadataValueBuilder)1 ScopedMetadataKeyDto (io.nem.symbol.catapult.builders.ScopedMetadataKeyDto)1