Skip to content
Snippets Groups Projects
Commit 6263354b authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Handle BigDecimals (e.g., for the WCET annotation) in the creation of random values.

refs 2361
parent c9d571fe
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.annotation.valueprovider;
import java.math.BigDecimal;
import java.util.Random;
import java.util.function.BiConsumer;
import java.util.stream.DoubleStream;
......@@ -89,12 +90,18 @@ public interface DefaultAnnotationContextActions<T extends IAnnotatedSpecificati
Random rand = new Random();
DoubleStream doubleStream = rand.doubles(value - bound, value + bound);
double randVal = doubleStream.findAny().getAsDouble();
Object randVal = doubleStream.findAny().getAsDouble();
try {
if(spec.getInstanceKey() == null || spec.getInstanceKey().equals("")) {
if(getAnnotationValue(annotation) instanceof BigDecimal) {
randVal = BigDecimal.valueOf(((Double)randVal).doubleValue());
}
setAnnotationValue(randVal, annotation);
} else {
if(getAnnotationValue(annotation) instanceof BigDecimal) {
randVal = BigDecimal.valueOf(((Double)randVal).doubleValue());
}
setAnnotationValue(randVal, annotation, spec.getInstanceKey());
}
} catch(Exception e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment