Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
fix: update ProtoWrapper definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Novosad Frantisek committed Mar 23, 2022
1 parent 648de1e commit e7b653e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import com.iamceph.resulter.core.DataResultable;
import com.iamceph.resulter.core.Resultable;
import com.iamceph.resulter.core.model.ResultableData;

import lombok.experimental.UtilityClass;
import lombok.val;
import lombok.var;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -50,8 +52,14 @@ public ResultableData pack(@NotNull DataResultable<?> input) {
if (data instanceof ProtoWrapper) {
final var wrapped = (ProtoWrapper<?>) data;
final var message = wrapped.asProto();
if (!(message instanceof ProtoWrapper)) {
val errorResult = DataResultable.fail("Cannot convert data - " + data.getClass().getSimpleName());
return ResultableData.newBuilder()
.setResult(errorResult.asProto())
.build();
}

return buildMessage(input, message);
return buildMessage(input, (Message) message);
}

val errorResult = DataResultable.fail("Cannot convert data - " + data.getClass().getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.iamceph.resulter.core.pack;

import com.google.protobuf.Message;

/**
* A wrapper for .proto conversions.
*
* @param <T> .proto type of this class
* @param <T> result of the asProto
*/
public interface ProtoWrapper<T extends Message> {
public interface ProtoWrapper<T> {
/**
* Wraps current wrapper into a .proto class
*
Expand Down

0 comments on commit e7b653e

Please sign in to comment.