frostfs-sdk-java/models/src/main/java/info/frostfs/sdk/mappers/SignatureMapper.java
Bruk Ori f415b3063a [#XX] provide naming conventions
Signed-off-by: Ori Bruk <o.bruk@yadro.com>
2024-07-23 22:24:17 +03:00

25 lines
820 B
Java

package info.frostfs.sdk.mappers;
import com.google.protobuf.ByteString;
import frostfs.refs.Types;
import info.frostfs.sdk.dto.Signature;
import static java.util.Objects.isNull;
public class SignatureMapper {
public static Types.Signature ToGrpcMessage(Signature signature) {
var scheme = Types.SignatureScheme.forNumber(signature.getScheme().value);
if (isNull(scheme)) {
throw new IllegalArgumentException(
String.format("Unknown SignatureScheme. Value: %s.", signature.getScheme().name())
);
}
return Types.Signature.newBuilder()
.setKey(ByteString.copyFrom(signature.getKey()))
.setSign(ByteString.copyFrom(signature.getSign()))
.setScheme(scheme)
.build();
}
}