org.sonar.api.measures.Metric m = findMetricOrFail(measure.metric().key());
org.sonar.api.measures.Measure measureToSave = new org.sonar.api.measures.Measure(m);
setValueAccordingToMetricType(newMeasure, m, measureToSave);
measureToSave.setFromCore(measure.isFromCore());
if (newMeasure.inputFile() != null) {
Formula formula = newMeasure.metric() instanceof org.sonar.api.measures.Metric ?
((org.sonar.api.measures.Metric) newMeasure.metric()).getFormula() : null;
if (formula instanceof SumChildDistributionFormula
&& !Scopes.isHigherThanOrEquals(Scopes.FILE, ((SumChildDistributionFormula) formula).getMinimumScopeToPersist())) {
measureToSave.setPersistenceMode(PersistenceMode.MEMORY);
}