use of io.nem.symbol.catapult.builders.NamespaceIdDto in project nem2-sdk-java by nemtech.
the class NamespaceInfo method toNamespaceAliasTypeDto.
private NamespacePathBuilder toNamespaceAliasTypeDto(NamespaceInfo namespaceInfo) {
List<NamespaceIdDto> path = namespaceInfo.getLevels().stream().skip(1).map(id -> new NamespaceIdDto(id.getIdAsLong())).collect(Collectors.toList());
NamespaceAliasBuilder alias = namespaceInfo.getAlias().createAliasBuilder();
return NamespacePathBuilder.create(path, alias);
}
use of io.nem.symbol.catapult.builders.NamespaceIdDto in project nem2-sdk-java by nemtech.
the class NamespaceInfo method serialize.
/**
* @return serializes the state of this object.
*/
public byte[] serialize(List<NamespaceInfo> fullPath) {
if (!this.isRoot()) {
throw new IllegalArgumentException("Namespace must be root in order to serialize!");
}
List<NamespaceInfo> children = sortList(fullPath, this.getId());
if (fullPath.size() != children.size()) {
throw new IllegalArgumentException("Some of the children do not belong to this root namespace");
}
NamespaceIdDto id = new NamespaceIdDto(getId().getIdAsLong());
AddressDto ownerAddress = SerializationUtils.toAddressDto(getOwnerAddress());
NamespaceLifetimeBuilder lifetime = NamespaceLifetimeBuilder.create(new HeightDto(getStartHeight().longValue()), new HeightDto(getEndHeight().longValue()));
NamespaceAliasBuilder rootAlias = getAlias().createAliasBuilder();
List<NamespacePathBuilder> paths = children.stream().map(this::toNamespaceAliasTypeDto).collect(Collectors.toList());
RootNamespaceHistoryBuilder builder = RootNamespaceHistoryBuilder.create((short) getVersion(), id, ownerAddress, lifetime, rootAlias, paths);
return builder.serialize();
}
use of io.nem.symbol.catapult.builders.NamespaceIdDto in project nem2-sdk-java by nemtech.
the class ArtifactExpiryReceipt method serialize.
/**
* Serialize receipt and returns receipt bytes
*
* @return receipt bytes
*/
public byte[] serialize() {
short version = (short) getVersion().getValue();
ReceiptTypeDto type = ReceiptTypeDto.rawValueOf((short) getType().getValue());
if (this.artifactId instanceof MosaicId) {
return MosaicExpiryReceiptBuilder.create(version, type, new MosaicIdDto(getArtifactIdValue().longValue())).serialize();
} else {
return NamespaceExpiryReceiptBuilder.create(version, type, new NamespaceIdDto(getArtifactIdValue().longValue())).serialize();
}
}
Aggregations