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

tech.ytsaurus.core.utils.ProtoUtils Maven / Gradle / Ivy

package tech.ytsaurus.core.utils;

import java.lang.reflect.InvocationTargetException;

import com.google.protobuf.Message;

public class ProtoUtils {
    private ProtoUtils() {
    }

    public static Message.Builder newBuilder(Class messageClass) {
        return invokeOnMessageClass(messageClass, "newBuilder");
    }

    @SuppressWarnings("unchecked")
    private static  T invokeOnMessageClass(Class messageClass, String methodName) {
        try {
            return (T) messageClass.getMethod(methodName).invoke(null);
        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
            throw new RuntimeException(ex);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy