All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.ibole.infrastructure.common.protobuf.ProtocolBufDecoder Maven / Gradle / Ivy

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