com.github.ibole.infrastructure.common.protobuf.ProtocolBufDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infrastructure-all Show documentation
Show all versions of infrastructure-all Show documentation
The all in one project of ibole infrastructure
The newest version!
package com.github.ibole.infrastructure.common.protobuf;
import com.google.protobuf.Message;
import java.util.concurrent.ConcurrentHashMap;
/**
* ProtocolBuf Decoder.
*/
public class ProtocolBufDecoder {
private static ConcurrentHashMap messages =
new ConcurrentHashMap();
public static void addMessage(String className, Message message) {
messages.putIfAbsent(className, message);
}
public Object decode(String className, byte[] bytes) throws Exception {
Message message = messages.get(className);
return message.newBuilderForType().mergeFrom(bytes).build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy