Add ListMarshaller and SetMarshaller factory methods

This commit is contained in:
leventov
2016-01-11 15:22:42 +03:00
parent c75965020e
commit b168612d90
4 changed files with 25 additions and 9 deletions
@@ -59,6 +59,16 @@ import static net.openhft.chronicle.hash.serialization.StatefulCopyable.copyIfNe
public final class ListMarshaller<T>
implements BytesReader<List<T>>, BytesWriter<List<T>>, StatefulCopyable<ListMarshaller<T>> {
public static <T> ListMarshaller<T> of(
BytesReader<T> elementReader, BytesWriter<? super T> elementWriter) {
return new ListMarshaller<>(elementReader, elementWriter);
}
public static <T, M extends BytesReader<T> & BytesWriter<? super T>> ListMarshaller<T> of(
M elementMarshaller) {
return of(elementMarshaller, elementMarshaller);
}
// Config fields
private BytesReader<T> elementReader;
private BytesWriter<? super T> elementWriter;
@@ -60,6 +60,16 @@ import static net.openhft.chronicle.hash.serialization.StatefulCopyable.copyIfNe
public final class SetMarshaller<T>
implements BytesReader<Set<T>>, BytesWriter<Set<T>>, StatefulCopyable<SetMarshaller<T>> {
public static <T> SetMarshaller<T> of(
BytesReader<T> elementReader, BytesWriter<? super T> elementWriter) {
return new SetMarshaller<>(elementReader, elementWriter);
}
public static <T, M extends BytesReader<T> & BytesWriter<? super T>> SetMarshaller<T> of(
M elementMarshaller) {
return of(elementMarshaller, elementMarshaller);
}
// Config fields
private BytesReader<T> elementReader;
private BytesWriter<? super T> elementWriter;