Package org.lightview.business.methods.entity

Source Code of org.lightview.business.methods.entity.MethodsStatistics

package org.lightview.business.methods.entity;

import javax.json.JsonObject;
import javax.json.JsonValue;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* @author: adam-bien.com
*/
public class MethodsStatistics {

    private final JsonObject statistics;

    public MethodsStatistics(JsonObject statistics) {
            this.statistics = statistics;
    }

    public List<MethodStatistics> all(){
        List<MethodStatistics> statistics = new ArrayList<>();
        final Set<Map.Entry<String,JsonValue>> entries = this.statistics.entrySet();
        for (Map.Entry<String, JsonValue> entry : entries) {
            final String methodName = entry.getKey();
            final JsonValue value = entry.getValue();
            //this bean has no methods, the content is: {"-- no methods --":null}
            if(!(value instanceof JsonObject)){
                continue;
            }
            JsonObject methodStatistics = (JsonObject)value;
            statistics.add(new MethodStatistics(methodName,methodStatistics));
        }
        return statistics;
    }
}
TOP

Related Classes of org.lightview.business.methods.entity.MethodsStatistics

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.