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

com.powsybl.afs.storage.buffer.AbstractTimeSeriesChunksAddition Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2017, RTE (http://www.rte-france.com)
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package com.powsybl.afs.storage.buffer;

import com.powsybl.timeseries.AbstractPoint;
import com.powsybl.timeseries.DataChunk;
import com.powsybl.timeseries.TimeSeriesVersions;

import java.util.List;
import java.util.Objects;

/**
 * @author Geoffroy Jamgotchian {@literal }
 */
public abstract class AbstractTimeSeriesChunksAddition

> extends AbstractStorageChange { protected int version; protected String timeSeriesName; protected List chunks; protected AbstractTimeSeriesChunksAddition(String nodeId, int version, String timeSeriesName, List chunks) { super(nodeId); this.version = TimeSeriesVersions.check(version); this.timeSeriesName = Objects.requireNonNull(timeSeriesName); this.chunks = checkChunks(chunks); } @Override public long getEstimatedSize() { return chunks.stream().mapToLong(DataChunk::getEstimatedSize).sum(); } private List checkChunks(List chunks) { Objects.requireNonNull(chunks); if (chunks.isEmpty()) { throw new IllegalArgumentException("Empty chunk list"); } return chunks; } public int getVersion() { return version; } public String getTimeSeriesName() { return timeSeriesName; } public List getChunks() { return chunks; } @Override public int hashCode() { return Objects.hash(nodeId, version, timeSeriesName, chunks); } @Override public boolean equals(Object obj) { if (obj instanceof AbstractTimeSeriesChunksAddition other) { return nodeId.equals(other.nodeId) && version == other.version && timeSeriesName.equals(other.timeSeriesName) && chunks.equals(other.chunks); } return false; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy