
org.diirt.datasource.formula.ReadOnlyWriteExpression Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datasource-formula Show documentation
Show all versions of datasource-formula Show documentation
An extensible formula language suitable for real-time calculation.
The newest version!
/**
* Copyright (C) 2010-18 diirt developers. See COPYRIGHT.TXT
* All rights reserved. Use is subject to license terms. See LICENSE.TXT
*/
package org.diirt.datasource.formula;
import org.diirt.datasource.PVWriterDirector;
import org.diirt.datasource.WriteFunction;
import org.diirt.datasource.WriteRecipeBuilder;
import org.diirt.datasource.expression.WriteExpressionImpl;
import org.diirt.datasource.expression.WriteExpressionListImpl;
/**
*
* @author carcassi
*/
class ReadOnlyWriteExpression extends WriteExpressionImpl {
private final String errorMessage;
public ReadOnlyWriteExpression(final String errorMessage, String defaultName) {
super(new WriteExpressionListImpl<>(), new WriteFunction() {
@Override
public void writeValue(T newValue) {
throw new RuntimeException(errorMessage);
}
}, defaultName);
this.errorMessage = errorMessage;
}
@Override
public void fillWriteRecipe(PVWriterDirector director, WriteRecipeBuilder builder) {
super.fillWriteRecipe(director, builder);
director.connectStatic(new RuntimeException(errorMessage), false, getName());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy