
net.intelie.liverig.plugin.widgets.AssetChannel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plugin-assets Show documentation
Show all versions of plugin-assets Show documentation
Asset framework for industries solutions
The newest version!
package net.intelie.liverig.plugin.widgets;
import com.google.common.base.Strings;
import net.intelie.live.LiveJson;
import net.intelie.pipes.types.Type;
public class AssetChannel {
private String qualifier;
private String name;
private Boolean thresholdEnabled;
private String thresholdMin;
private String thresholdMax;
private String axisMin;
private String axisMax;
private String color;
private Integer index;
private String chartType;
private Boolean lockChannel;
public AssetChannel(String qualifier) {
this.qualifier = qualifier;
}
public String getChartType() {
return chartType;
}
public void setChartType(String chartType) {
this.chartType = chartType;
}
public boolean shouldThrottle() {
String LABELS_CHART_TYPE = "labels";
String type = chartType == null ? "line" : chartType;
return type.equals(LABELS_CHART_TYPE);
}
public Boolean getLockChannel() {
return lockChannel;
}
public void setLockChannel(Boolean lockChannel) {
this.lockChannel = lockChannel;
}
public String getQualifier() {
return qualifier;
}
public void setQualifier(String qualifier) {
this.qualifier = qualifier;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Boolean getThresholdEnabled() {
return thresholdEnabled;
}
public void setThresholdEnabled(Boolean thresholdEnabled) {
this.thresholdEnabled = thresholdEnabled;
}
public UnitValueWrapper getThresholdMin() {
return new UnitValueWrapper(thresholdMin);
}
public void setThresholdMin(String thresholdMin) {
this.thresholdMin = thresholdMin;
}
public UnitValueWrapper getThresholdMax() {
return new UnitValueWrapper(thresholdMax);
}
public void setThresholdMax(String thresholdMax) {
this.thresholdMax = thresholdMax;
}
public UnitValueWrapper getAxisMin() {
return new UnitValueWrapper(axisMin);
}
public void setAxisMin(String axisMin) {
this.axisMin = axisMin;
}
public UnitValueWrapper getAxisMax() {
return new UnitValueWrapper(axisMax);
}
public void setAxisMax(String axisMax) {
this.axisMax = axisMax;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
public class UnitValueWrapper {
private final String value;
UnitValueWrapper(String value) {
this.value = Type.STRING.cast(value);
}
public Double getValue() {
if (Strings.isNullOrEmpty(value)) return null;
try {
return Double.parseDouble(value);
} catch (NumberFormatException e) {
UnitValue unitValue = LiveJson.fromJson(value, UnitValue.class);
if (unitValue == null) return null;
String value = unitValue.getValue();
if (Strings.isNullOrEmpty(value)) return null;
return Double.parseDouble(value);
}
}
public String getUnit() {
if (Strings.isNullOrEmpty(value)) return null;
try {
UnitValue unitValue = LiveJson.fromJson(value, UnitValue.class);
if (unitValue == null) return null;
return unitValue.getUnit();
} catch (Exception ignored) {
}
return null;
}
}
class UnitValue {
String value;
String unit;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy