class PeriodOffsetUtils {

    public static ListMap<String, DimensionalItemObject> getPeriodTypePeriodMap( DataQueryParams params )
    {
        if ( params == null || params.getPeriods().isEmpty() )
        {
            return new ListMap<>();
        }

        ListMap<String, DimensionalItemObject> periodTypePeriodMap = PartitionUtils.getPeriodTypePeriodMap( params.getPeriods() );

        DimensionalObject dimension = params.getDimension( DATA_X_DIM_ID );

        if ( dimension == null )
        {
            return periodTypePeriodMap;
        }

        List<DimensionalItemObject> items = dimension.getItems();
        ListMap<String, DimensionalItemObject> shiftedMap = new ListMap<>();

        for ( DimensionalItemObject item : items )
        {
            if ( item.getPeriodOffset() != 0 )
            {
                shiftedMap.putAll( addPeriodOffset( periodTypePeriodMap, item.getPeriodOffset() ) );
            }
        }

        Set<DimensionalItemObject> dimensionalItemObjects = shiftedMap.uniqueValues();

        for ( DimensionalItemObject dimensionalItemObject : dimensionalItemObjects )
        {
            Period period = (Period) dimensionalItemObject;

            if ( !periodTypePeriodMap.containsValue( period.getPeriodType().getName(), dimensionalItemObject ) )
            {
                periodTypePeriodMap.putValue( period.getPeriodType().getName(), dimensionalItemObject );
            }
        }

        return periodTypePeriodMap;
    }

}