org.diirt.datasource.graphene.ReadFunctionArgument Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datasource-graphene Show documentation
Show all versions of datasource-graphene Show documentation
Support for real-time graph rendering with graphene.
/**
* Copyright (C) 2010-14 diirt developers. See COPYRIGHT.TXT
* All rights reserved. Use is subject to license terms. See LICENSE.TXT
*/
package org.diirt.datasource.graphene;
import java.util.Objects;
import org.diirt.datasource.ReadFunction;
/**
*
* @author carcassi
*/
public class ReadFunctionArgument {
private T value;
private final ReadFunction function;
private boolean changed;
public ReadFunctionArgument(ReadFunction function) {
this.function = function;
}
public ReadFunctionArgument() {
this(null);
}
public boolean isDefined() {
return function != null;
}
public boolean isMissing() {
return isDefined() && getValue() == null;
}
public void readNext() {
if (function != null) {
T oldValue = value;
value = function.readValue();
changed = !Objects.equals(oldValue, value);
} else {
changed = false;
}
}
public boolean isChanged() {
return changed;
}
public T getValue() {
return value;
}
}