DT - datatypeM - messageMB - message builderpublic class ProtoBufFileProcessor<DT,M extends com.google.protobuf.GeneratedMessage,MB extends com.google.protobuf.GeneratedMessage.Builder<MB>> extends Object implements FileProcessor<DT>
ProtoBufFileProcessor<UserConfig, UserConfig, UserConfig.Builder> processor = new ProtoBufFileProcessor<>(UserConfig.newBuilder());
processor.serialize(UserConfig.getDefaultInstance().newBuilderForType().setFirstName("Pink").build(), new File("/tmp/myuser.txt"));
System.out.println("Username: "+processor.deserialize(new File("/tmp/myuser.txt")).getFirstName());
| Modifier and Type | Class and Description |
|---|---|
static class |
ProtoBufFileProcessor.SimpleMessageTransformer<M extends com.google.protobuf.GeneratedMessage,MB extends com.google.protobuf.GeneratedMessage.Builder> |
static interface |
ProtoBufFileProcessor.TypeToMessageTransformer<T,M extends com.google.protobuf.GeneratedMessage,MB extends com.google.protobuf.Message.Builder> |
| Constructor and Description |
|---|
ProtoBufFileProcessor(MB messageBuilder)
Constructor to create a new
ProtoBufFileProcessor |
ProtoBufFileProcessor(ProtoBufFileProcessor.TypeToMessageTransformer<DT,M,MB> transformer) |
| Modifier and Type | Method and Description |
|---|---|
DT |
deserialize(File file) |
DT |
deserialize(File file,
DT data) |
File |
serialize(DT data,
File file) |
public ProtoBufFileProcessor(MB messageBuilder)
ProtoBufFileProcessormessageBuilder - a builder which can be used to build the message after deserialization.public ProtoBufFileProcessor(ProtoBufFileProcessor.TypeToMessageTransformer<DT,M,MB> transformer)
public DT deserialize(File file, DT data) throws CouldNotPerformException
deserialize in interface Processor<DT,File>CouldNotPerformExceptionpublic File serialize(DT data, File file) throws CouldNotPerformException
serialize in interface Processor<DT,File>CouldNotPerformExceptionpublic DT deserialize(File file) throws CouldNotPerformException
deserialize in interface FileProcessor<DT>CouldNotPerformExceptionCopyright © 2015–2017 openbase.org. All rights reserved.