use of io.nem.symbol.catapult.builders.NamespaceAliasBuilder 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.NamespaceAliasBuilder 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();
}
Aggregations