Java SQL Date getProtobufClass(Object value, Class protobufClass)

Here you can find the source of getProtobufClass(Object value, Class protobufClass)

Description

Retrieve the ProtobufClass based on the POJO value.

License

Open Source License

Parameter

Parameter Description
value - POJO object
protobufClass - the Protobuf class

Return

Class<? extends Object> - actual Protobuf class to use in setter

Declaration

public static final Class<? extends Object> getProtobufClass(Object value,
        Class<? extends Object> protobufClass) 

Method Source Code

//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&lt;? extends Object&gt; - 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;
    }
}

Related

  1. getNextDayStr(String curday)
  2. getNextDayStr(String curday)
  3. getNow()
  4. getNow()
  5. getNowHour()
  6. getTodayAndTomorrow()
  7. getWeekNumber()
  8. getWeekOfMonth(String year, String month, String day)
  9. getYearLater()