|
|
|
@ -2,19 +2,18 @@ package com.fr.plugin.present.fun;
|
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseFormula; |
|
|
|
|
import com.fr.base.present.AbstractPresent; |
|
|
|
|
import com.fr.general.GeneralUtils; |
|
|
|
|
import com.fanruan.api.util.GeneralKit; |
|
|
|
|
import com.fr.intelli.record.Focus; |
|
|
|
|
import com.fr.intelli.record.Original; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fanruan.api.log.LogKit; |
|
|
|
|
import com.fr.record.analyzer.EnableMetrics; |
|
|
|
|
import com.fr.script.Calculator; |
|
|
|
|
import com.fr.stable.AssistUtils; |
|
|
|
|
import com.fanruan.api.util.AssistKit; |
|
|
|
|
import com.fr.stable.ColumnRow; |
|
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.stable.UtilEvalError; |
|
|
|
|
import com.fanruan.api.util.StringKit; |
|
|
|
|
import com.fr.stable.xml.XMLPrintWriter; |
|
|
|
|
import com.fr.stable.xml.XMLableReader; |
|
|
|
|
import com.fanruan.api.cal.FormulaKit; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author richie |
|
|
|
@ -38,16 +37,16 @@ public class StarPresent extends AbstractPresent {
|
|
|
|
|
@Focus(id = "com.fr.plugin.present.star", text = "", source = Original.PLUGIN) |
|
|
|
|
public Object present(Object value, Calculator calculator, ColumnRow cr) { |
|
|
|
|
Object result = null; |
|
|
|
|
if (StableUtils.canBeFormula(condition)) { |
|
|
|
|
if (FormulaKit.canBeFormula(condition)) { |
|
|
|
|
try { |
|
|
|
|
result = calculator.evalValue(BaseFormula.createFormulaBuilder().build(condition)); |
|
|
|
|
} catch (UtilEvalError e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LogKit.error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
result = condition; |
|
|
|
|
} |
|
|
|
|
Number num = GeneralUtils.objectToNumber(result, true); |
|
|
|
|
Number num = GeneralKit.objectToNumber(result, true); |
|
|
|
|
if (num == null) { |
|
|
|
|
return value; |
|
|
|
|
} |
|
|
|
@ -66,7 +65,7 @@ public class StarPresent extends AbstractPresent {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void writeXML(XMLPrintWriter writer) { |
|
|
|
|
if (StringUtils.isNotEmpty(condition)) { |
|
|
|
|
if (StringKit.isNotEmpty(condition)) { |
|
|
|
|
writer.startTAG("Condition").textNode(condition).end(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -80,11 +79,11 @@ public class StarPresent extends AbstractPresent {
|
|
|
|
|
public boolean equals(Object o) { |
|
|
|
|
return o instanceof StarPresent |
|
|
|
|
&& super.equals(o) |
|
|
|
|
&& AssistUtils.equals(((StarPresent) o).condition, condition); |
|
|
|
|
&& AssistKit.equals(((StarPresent) o).condition, condition); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int hashCode() { |
|
|
|
|
return AssistUtils.hashCode(condition); |
|
|
|
|
return AssistKit.hashCode(condition); |
|
|
|
|
} |
|
|
|
|
} |