public AbstractReductionFunctionEntity toPersistenceFunction(ReductionFunction reductionFunction) { AbstractReductionFunctionEntity functionEntity = reductionFunction.accept(serviceToPersistenceMapping); if (functionEntity == null) { throw new IllegalArgumentException("No mapping found"); } return functionEntity; } }
private static String getReduceFunctionDescription(final ReductionFunction reductionFunction) { return reductionFunction.accept(new ReduceFunctionVisitor<String>() { @Override public String visit(HighestSeverity function) { return function.getClass().getSimpleName(); } @Override public String visit(HighestSeverityAbove function) { return String.format("%s (%s)", function.getClass().getSimpleName(), function.getThreshold().getLabel()); } @Override public String visit(Threshold function) { return String.format("%s (%s)", function.getClass().getSimpleName(), Float.toString(function.getThreshold())); } @Override public String visit(ExponentialPropagation function) { return String.format("%s (%s)", function.getClass().getSimpleName(), Double.toString(function.getBase())); } }); }
private ReductionFunction getReduceFunction() { try { final ReductionFunction reductionFunction = ((Class<? extends ReductionFunction>) m_reduceFunctionNativeSelect.getValue()).newInstance(); reductionFunction.accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) { return null; } @Override public Void visit(HighestSeverityAbove highestSeverityAbove) { highestSeverityAbove.setThreshold((Status) m_thresholdStatusSelect.getValue()); return null; } @Override public Void visit(Threshold threshold) { threshold.setThreshold(Float.parseFloat(m_thresholdTextField.getValue())); return null; } @Override public Void visit(ExponentialPropagation exponentialPropagation) { exponentialPropagation.setBase(Double.parseDouble(m_exponentialPropagationBaseTextField.getValue())); return null; } }); return reductionFunction; } catch (final InstantiationException | IllegalAccessException e) { throw Throwables.propagate(e); } } }));
private ReductionFunction getReduceFunction() { try { final ReductionFunction reductionFunction = ((Class<? extends ReductionFunction>) m_reduceFunctionNativeSelect.getValue()).newInstance(); reductionFunction.accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) { return null; } @Override public Void visit(HighestSeverityAbove highestSeverityAbove) { highestSeverityAbove.setThreshold((Status) m_thresholdStatusSelect.getValue()); return null; } @Override public Void visit(Threshold threshold) { threshold.setThreshold(Float.parseFloat(m_thresholdTextField.getValue())); return null; } @Override public Void visit(ExponentialPropagation exponentialPropagation) { exponentialPropagation.setBase(Double.parseDouble(m_exponentialPropagationBaseTextField.getValue())); return null; } }); return reductionFunction; } catch (final InstantiationException | IllegalAccessException e) { throw Throwables.propagate(e); } } }));
businessService.getReduceFunction().accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) {
m_reduceFunctionNativeSelect.setValue(businessService.getReduceFunction().getClass()); businessService.getReduceFunction().accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) {
m_reduceFunctionNativeSelect.setValue(businessService.getReduceFunction().getClass()); businessService.getReduceFunction().accept(new ReduceFunctionVisitor<Void>() { @Override public Void visit(HighestSeverity highestSeverity) {