-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 14255-reusable-gradle-config
- Loading branch information
Showing
12 changed files
with
366 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
pbj-core/pbj-runtime/src/test/java/com/hedera/pbj/runtime/CodecWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.hedera.pbj.runtime; | ||
|
||
import com.hedera.pbj.runtime.io.ReadableSequentialData; | ||
import com.hedera.pbj.runtime.io.WritableSequentialData; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import java.io.IOException; | ||
import java.util.function.ToIntFunction; | ||
|
||
/** | ||
* Now that we use Codecs in ProtoWriterTools and ProtoReaderTools, we need to wrap the old test lambdas ProtoWriter and | ||
* ToIntFunction into a codec class. Only the two methods are implemented and the rest are left as unsupported. | ||
* | ||
* @param <T> The type of the object to be encoded/decoded | ||
*/ | ||
class CodecWrapper<T> implements Codec<T> { | ||
private final ProtoWriter<T> writer; | ||
private final ToIntFunction<T> sizeOf; | ||
|
||
CodecWrapper(ProtoWriter<T> writer, ToIntFunction<T> sizeOf) { | ||
this.writer = writer; | ||
this.sizeOf = sizeOf; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public T parse(@NonNull ReadableSequentialData input, boolean strictMode, int maxDepth) | ||
throws ParseException { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public void write(@NonNull T item, @NonNull WritableSequentialData output) throws IOException { | ||
writer.write(item, output); | ||
} | ||
|
||
@Override | ||
public int measure(@NonNull ReadableSequentialData input) throws ParseException { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int measureRecord(T item) { | ||
return sizeOf.applyAsInt(item); | ||
} | ||
|
||
@Override | ||
public boolean fastEquals(@NonNull T item, @NonNull ReadableSequentialData input) throws ParseException { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
Oops, something went wrong.