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

org.diirt.datasource.graphene.ReadFunctionArgument Maven / Gradle / Ivy

There is a newer version: 3.1.7
Show newest version
/**
 * 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;
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy