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

main.io.github.moonlightsuite.moonlight.online.signal.TimeSegment Maven / Gradle / Ivy

Go to download

MoonLight is a light-weight Java-tool for monitoring temporal, spatial and spatio-temporal properties of distributed complex systems, such as Cyber-Physical Systems and Collective Adaptive Systems.

The newest version!
package io.github.moonlightsuite.moonlight.online.signal;

import io.github.moonlightsuite.moonlight.core.signal.Sample;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

/**
 * Immutable concrete implementation of {@link Sample}.
 * Note that for space efficiency reasons the segment does not have an ending,
 * as this would be a replication of data with the contiguous segment.
 *
 * Conversely, chains of segments, or {@link TimeChain}, might have an ending.
 *
 * @param  The time-domain of the Segment
 * @param  The value-domain of the Segment
 *
 * @see Sample
 * @see TimeChain
 */
public class TimeSegment
        , V>
        implements Sample
{
    private final T start;
    private final V value;

    public TimeSegment(@NotNull T start, @NotNull V value) {
        this.start = start;
        this.value = value;
    }

    @Override
    public V getValue() {
        return value;
    }

    @Override
    public T getStart() {
        return start;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof TimeSegment)) return false;
        TimeSegment that = (TimeSegment) o;
        return Objects.equals(start, that.start) && Objects.equals(value, that.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(start, value);
    }

    @Override
    public String toString() {
        return "Segment(" + "start=" + start + ", value=" + value + ')';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy