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

io.github.linyimin0812.profiler.common.ui.MethodInvokeDetail Maven / Gradle / Ivy

There is a newer version: 3.1.4
Show newest version
package io.github.linyimin0812.profiler.common.ui;

import com.google.gson.Gson;
import io.github.linyimin0812.profiler.common.utils.GsonUtil;

/**
 * @author linyimin
 **/
public class MethodInvokeDetail {
    private final String methodQualifier;
    private final long startMillis;
    private long duration;

    private Object[] args;

    public MethodInvokeDetail(String methodQualifier, Object[] args) {
        this.methodQualifier = methodQualifier;
        this.startMillis = System.currentTimeMillis();

        if (args == null) {
            return;
        }

        Gson gson = GsonUtil.create();

        Object[] argStrList = new String[args.length];

        for (int i = 0; i < args.length; i++) {
            try {
                argStrList[i] = gson.toJson(args[i]);
            } catch (Throwable ignored) {
                argStrList[i] = args[i].toString();
            }
        }
        this.args = argStrList;
    }

    public MethodInvokeDetail(String methodQualifier, long startMillis, long duration) {
        this.methodQualifier = methodQualifier;
        this.startMillis = startMillis;
        this.duration = duration;
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }

    public String getMethodQualifier() {
        return methodQualifier;
    }

    public long getStartMillis() {
        return startMillis;
    }

    public long getDuration() {
        return duration;
    }

    public Object[] getArgs() {
        return args;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy