4
4
import com .gradle .enterprise .model .TaskExecutionSummary ;
5
5
6
6
import java .math .BigDecimal ;
7
+ import java .math .RoundingMode ;
7
8
import java .time .Duration ;
8
9
import java .util .Arrays ;
9
10
import java .util .function .Function ;
@@ -34,7 +35,7 @@ public enum BuildScanDataFields {
34
35
EXECUTED_NOT_CACHEABLE ("Executed not cacheable" , d -> totalTasks (d , "executed_not_cacheable" )),
35
36
EXECUTED_NOT_CACHEABLE_DURATION ("Executed not cacheable duration" , d -> totalDuration (d , "executed_not_cacheable" )),
36
37
BUILD_TIME ("Build time" , d -> formatDuration (d .getBuildTime ())),
37
- SERIALIZATION_FACTOR ("Serialization factor" , d -> toStringSafely (d .getSerializationFactor ())),
38
+ SERIALIZATION_FACTOR ("Serialization factor" , d -> formatSerializationFactor (d .getSerializationFactor ())),
38
39
;
39
40
40
41
private static final String NO_VALUE = "" ;
@@ -55,10 +56,6 @@ private static String toStringSafely(Object object) {
55
56
return object == null ? NO_VALUE : object .toString ();
56
57
}
57
58
58
- private static String toStringSafely (BigDecimal value ) {
59
- return value == null ? NO_VALUE : value .toPlainString ();
60
- }
61
-
62
59
private static String totalTasks (BuildScanData data , String avoidanceOutcome ) {
63
60
return summaryTotal (data , avoidanceOutcome , t -> String .valueOf (t .totalTasks ()));
64
61
}
@@ -81,4 +78,8 @@ private static String summaryTotal(BuildScanData data, String avoidanceOutcome,
81
78
private static String formatDuration (Duration duration ) {
82
79
return duration == null ? NO_VALUE : format (duration );
83
80
}
81
+
82
+ private static String formatSerializationFactor (BigDecimal serializationFactor ) {
83
+ return serializationFactor == null ? NO_VALUE : serializationFactor .setScale (2 , RoundingMode .HALF_UP ).doubleValue () + "x" ;
84
+ }
84
85
}
0 commit comments