AnalyticsUtils { public static Number getRoundedValue( DataQueryParams params, Integer decimals, Double value ) { if ( value == null ) { return value; } else if ( params.isSkipRounding() ) { return Precision.round( value, DECIMALS_NO_ROUNDING ); } else if ( decimals != null && decimals > 0 ) { return Precision.round( value, decimals ); } else if ( decimals != null && decimals == 0 ) { return Math.round( value ); } else { return MathUtils.getRounded( value ); } }  static String getDebugDataSql( DataQueryParams params ); static List<DimensionalItemObject> getByDataDimensionItemType( DataDimensionItemType itemType, List<DimensionalItemObject> dataDimensionOptions ); static Number getRoundedValue( DataQueryParams params, Integer decimals, Double value ); static Object getRoundedValueObject( DataQueryParams params, Object value ); static ColumnDataType getColumnType( ValueType valueType, boolean spatialSupport ); static Map<String, T> convertDxToOperand( Map<String, T> valueMap, TotalType totalType ); static Map<String, Double> getDoubleMap( Map<String, Object> map ); static Map<String, Object> getAggregatedDataValueMapping( Grid grid ); static DataValueSet getDataValueSetFromGrid( DataQueryParams params, Grid grid ); static void handleGridForDataValueSet( DataQueryParams params, Grid grid ); static Object getIntegerOrValue( Object value, DimensionalItemObject item ); static Map<String, DimensionalItemObject> getDimensionalItemObjectMap( DataQueryParams params ); static Map<String, String> getDimensionItemNameMap( DataQueryParams params ); static Map<String, MetadataItem> getDimensionMetadataItemMap( DataQueryParams params ); static Map<String, String> getCocNameMap( DataQueryParams params ); static Map<String, String> getUidDisplayPropertyMap( List<QueryItem> queryItems, DisplayProperty displayProperty ); static Map<String, String> getUidDisplayPropertyMap( List<DimensionalObject> dimensions, boolean hierarchyMeta, DisplayProperty displayProperty ); static boolean periodIsOutsideApprovalMaxYears( Integer year, Integer maxYears ); static int getLevelFromOrgUnitDimensionName( String dimensionName ); static boolean isTableLayout( List<String> columns, List<String> rows ); static Double calculateYearlyWeightedAverage( Double year1Value, Double year2Value, Double factor ); static Double getBaseMonth( PeriodType periodType ); static void throwIllegalQueryEx( ErrorCode errorCode, Object... args ); static boolean isPeriodInPeriods( String period, List<DimensionalItemObject> periods ); static List<DimensionalItemObject> findDimensionalItems( String dimensionIdentifier,
        List<DimensionalItemObject> items ); static boolean hasPeriod( List<Object> row, int periodIndex ); static final String ERR_MSG_TABLE_NOT_EXISTING; }
@Test public void testGetRoundedValueDouble() { DataQueryParams paramsA = DataQueryParams.newBuilder().build(); DataQueryParams paramsB = DataQueryParams.newBuilder().withSkipRounding( true ).build(); assertEquals( null, AnalyticsUtils.getRoundedValue( paramsA, null, null ) ); assertEquals( 3d, AnalyticsUtils.getRoundedValue( paramsA, null, 3d ).doubleValue(), 0.01 ); assertEquals( 3.1, AnalyticsUtils.getRoundedValue( paramsA, null, 3.123 ).doubleValue(), 0.01 ); assertEquals( 3.1, AnalyticsUtils.getRoundedValue( paramsA, 1, 3.123 ).doubleValue(), 0.01 ); assertEquals( 3.12, AnalyticsUtils.getRoundedValue( paramsA, 2, 3.123 ).doubleValue(), 0.01 ); assertEquals( 3.123, AnalyticsUtils.getRoundedValue( paramsB, 3, 3.123 ).doubleValue(), 0.01 ); assertEquals( 3l, AnalyticsUtils.getRoundedValue( paramsB, 0, 3.123 ).longValue() ); assertEquals( 12l, AnalyticsUtils.getRoundedValue( paramsB, 0, 12.34 ).longValue() ); assertEquals( 13l, AnalyticsUtils.getRoundedValue( paramsB, 0, 13.999 ).longValue() ); }