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

com.luues.util.datawrap.DataWrap Maven / Gradle / Ivy

There is a newer version: 1.3.0.5.RELEASE
Show newest version
package com.luues.util.datawrap;

import com.alibaba.fastjson.JSONObject;
import java.lang.reflect.Method;
import java.util.ArrayList;

public class DataWrap extends JSONObject{

    protected int resultCode = ResultCode.c_200;
    protected String resultMsg = "SUCCESS";

    public DataWrap(){
        this.put("resultCode", resultCode);
        this.put("resultMsg", resultMsg);
        //this.put("rows", new ArrayList<>());
    }

    protected Object getFieldValueByName(String fieldName, Object o) {
        try {
            String firstLetter = fieldName.substring(0, 1).toUpperCase();
            String getter = "get" + firstLetter + fieldName.substring(1);
            Method method = o.getClass().getMethod(getter, new Class[] {});
            Object value = method.invoke(o, new Object[] {});
            return value;
        } catch (Exception e) {
            return null;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy