Here you can find the source of getProtobufClass(Object value, Class extends Object> protobufClass)
Parameter | Description |
---|---|
value | - POJO object |
protobufClass | - the Protobuf class |
public static final Class<? extends Object> getProtobufClass(Object value, Class<? extends Object> protobufClass)
//package com.java2s; import java.sql.Date; import java.util.List; public class Main { /**// w w w. j a v a 2s . co m * Retrieve the ProtobufClass based on the POJO value. The returned value may get converted, * as the Protobuf builders/setters use primitives. For example, if user has declared <code>Integer</code>, * this get's converted to <code>int</code>. * * @param value - POJO object * @param protobufClass - the Protobuf class * @return Class<? extends Object> - actual Protobuf class to use in setter */ public static final Class<? extends Object> getProtobufClass(Object value, Class<? extends Object> protobufClass) { if (value instanceof Integer) { return Integer.TYPE; } if (value instanceof Boolean) { return Boolean.TYPE; } if (value instanceof Double) { return Double.TYPE; } if (value instanceof Long || value instanceof Date) { return Long.TYPE; } if (value instanceof List) { return Iterable.class; } return protobufClass; } }