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

com.addthis.codec.CodableStatistics Maven / Gradle / Ivy

There is a newer version: 3.8.2
Show newest version
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.addthis.codec;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public final class CodableStatistics {

    /**
     * Contains the data as it is collected.
     */
    private final Map data;

    /**
     * Contains data regarding fields that are maps.
     */
    private final Map> mapData;

    private long totalSize;

    /**
     * Immutable maps for export.
     */
    private Map statistics;
    private Map> mapStatistics;


    CodableStatistics() {
        this.data = new HashMap();
        this.mapData = new HashMap>();
    }

    void export() {
        this.statistics = Collections.unmodifiableMap(data);

        Map> exportMapStatistics = new HashMap>();

        for (Map.Entry> entry : mapData.entrySet()) {
            exportMapStatistics.put(entry.getKey(), Collections.unmodifiableMap(entry.getValue()));
        }

        this.mapStatistics = Collections.unmodifiableMap(exportMapStatistics);
    }

    Map getData() {
        return data;
    }

    Map> getMapData() {
        return mapData;
    }

    void setTotalSize(long size) {
        totalSize = size;
    }

    public Map getStatistics() {
        return statistics;
    }

    public Map> getMapStatistics() {
        return mapStatistics;
    }

    public long getTotalSize() {
        return totalSize;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy