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

com.byteplus.util.ConvertUtils Maven / Gradle / Ivy

There is a newer version: 1.1.23
Show newest version
package com.byteplus.util;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class ConvertUtils {
    public static List convertToPair(Object obj) throws Exception {
        List urlValues = new ArrayList<>();
        Field[] fields = obj.getClass().getDeclaredFields();
        for (Field field: fields){
            field.setAccessible(true);
            if (field.get(obj) == null){
                continue;
            }
            urlValues.add(new BasicNameValuePair(field.getName(), field.get(obj).toString()));
        }
        return urlValues;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy