Search in sources :

Example 76 with EnumMap

use of java.util.EnumMap in project UVMS-ActivityModule-APP by UnionVMS.

the class FACatchSummaryPresentationHelper method populateTotalFishSizeMap.

@Override
public void populateTotalFishSizeMap(SummaryTableDTO summaryTableWithTotals, SummaryTableDTO summaryTable) {
    Map<FishSizeClassEnum, Object> fishSizeClassEnumMap = summaryTable.getSummaryFishSize();
    if (MapUtils.isEmpty(fishSizeClassEnumMap)) {
        return;
    }
    Map<FishSizeClassEnum, Object> totalFishSizeSpeciesMap = summaryTableWithTotals.getSummaryFishSize();
    if (MapUtils.isEmpty(totalFishSizeSpeciesMap)) {
        totalFishSizeSpeciesMap = new EnumMap<>(FishSizeClassEnum.class);
        summaryTableWithTotals.setSummaryFishSize(totalFishSizeSpeciesMap);
    }
    // Go through all the Fish classes  and calculate total for each fishclass
    for (Map.Entry<FishSizeClassEnum, Object> entry : fishSizeClassEnumMap.entrySet()) {
        // key fishSize
        FishSizeClassEnum fishSize = entry.getKey();
        Object value = entry.getValue();
        // Value will be Double if species are not present as grouping criteria Else it will be map of Species and its count
        if (value instanceof Map) {
            // check if already present
            Map<String, Map<String, Double>> fishSizeMap = (Map<String, Map<String, Double>>) totalFishSizeSpeciesMap.get(fishSize);
            fishSizeMap = populateSpeciesPresentationMapWithTotal((Map<String, Map<String, Double>>) value, fishSizeMap);
            totalFishSizeSpeciesMap.put(fishSize, fishSizeMap);
        }
    }
}
Also used : FishSizeClassEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishSizeClassEnum) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 77 with EnumMap

use of java.util.EnumMap in project UVMS-ActivityModule-APP by UnionVMS.

the class FACatchSummaryReportHelper method populateTotalFaCatchMap.

/**
 * This method processes data to calculate weights for different Catch types
 * @param summaryTableWithTotals  Add the calculation to this final class
 * @param summaryTable process this object to calculate totals
 */
@Override
public void populateTotalFaCatchMap(SummaryTableDTO summaryTableWithTotals, SummaryTableDTO summaryTable) {
    Map<FaCatchTypeEnum, Object> catchTypeEnumMapMap = summaryTable.getSummaryFaCatchType();
    if (MapUtils.isNotEmpty(catchTypeEnumMapMap)) {
        Map<FaCatchTypeEnum, Object> totalCatchTypeMap = summaryTableWithTotals.getSummaryFaCatchType();
        if (MapUtils.isEmpty(totalCatchTypeMap)) {
            totalCatchTypeMap = new EnumMap<>(FaCatchTypeEnum.class);
            summaryTableWithTotals.setSummaryFaCatchType(totalCatchTypeMap);
        }
        // Go through all the catch types and calculate total for each type
        for (Map.Entry<FaCatchTypeEnum, Object> entry : catchTypeEnumMapMap.entrySet()) {
            // key fishSize
            FaCatchTypeEnum catchType = entry.getKey();
            Object value = entry.getValue();
            if (value instanceof Map) {
                // check if already present
                Map<String, Double> resultTotalSpeciesMap = (Map<String, Double>) totalCatchTypeMap.get(catchType);
                resultTotalSpeciesMap = extractSpeciesCountMap((Map<String, Double>) value, resultTotalSpeciesMap);
                totalCatchTypeMap.put(catchType, resultTotalSpeciesMap);
            } else if (value instanceof Double) {
                totalCatchTypeMap.put(catchType, calculateTotalValue((Double) value, (Double) totalCatchTypeMap.get(catchType)));
            }
        }
    }
}
Also used : FaCatchTypeEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum) EnumMap(java.util.EnumMap) Map(java.util.Map)

Example 78 with EnumMap

use of java.util.EnumMap in project UVMS-ActivityModule-APP by UnionVMS.

the class FACatchSummaryReportHelper method populateTotalFishSizeMap.

/**
 * This method will calculate totals for FishSize section
 * @param summaryTableWithTotals Add the calculation to this final class
 * @param summaryTable           process this object to calculate totals
 */
@Override
public void populateTotalFishSizeMap(SummaryTableDTO summaryTableWithTotals, SummaryTableDTO summaryTable) {
    Map<FishSizeClassEnum, Object> fishSizeClassEnumMap = summaryTable.getSummaryFishSize();
    if (MapUtils.isEmpty(fishSizeClassEnumMap)) {
        return;
    }
    Map<FishSizeClassEnum, Object> totalFishSizeSpeciesMap = summaryTableWithTotals.getSummaryFishSize();
    if (MapUtils.isEmpty(totalFishSizeSpeciesMap)) {
        totalFishSizeSpeciesMap = new EnumMap<>(FishSizeClassEnum.class);
        summaryTableWithTotals.setSummaryFishSize(totalFishSizeSpeciesMap);
    }
    // Go through all the Fish classes  and calculate total for each fishclass
    for (Map.Entry<FishSizeClassEnum, Object> entry : fishSizeClassEnumMap.entrySet()) {
        // key fishSize
        FishSizeClassEnum fishSize = entry.getKey();
        Object value = entry.getValue();
        // Value will be Double if species are not present as grouping criteria Else it will be map of Species and its count
        if (value instanceof Map) {
            // check if already present
            Map<String, Double> totalSpeciesMap = (Map<String, Double>) totalFishSizeSpeciesMap.get(fishSize);
            totalSpeciesMap = extractSpeciesCountMap((Map<String, Double>) value, totalSpeciesMap);
            totalFishSizeSpeciesMap.put(fishSize, totalSpeciesMap);
        } else if (value instanceof Double) {
            totalFishSizeSpeciesMap.put(fishSize, calculateTotalValue((Double) value, (Double) totalFishSizeSpeciesMap.get(fishSize)));
        }
    }
}
Also used : FishSizeClassEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishSizeClassEnum) EnumMap(java.util.EnumMap) Map(java.util.Map)

Example 79 with EnumMap

use of java.util.EnumMap in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityRequestMapper method extractFiltersAsMap.

/**
 * Some search Filters expect only single value. Others support multiple values for search.
 * This method sorts Filter list and separates filters with single values and return the map with its value.
 * @param filterTypes
 * @return Map<SearchFilter,String> Map of SearchFilter and its value
 * @throws ServiceException
 */
private static Map<SearchFilter, String> extractFiltersAsMap(List<SingleValueTypeFilter> filterTypes) throws ServiceException {
    Set<SearchFilter> filtersWithMultipleValues = FilterMap.getFiltersWhichSupportMultipleValues();
    Map<SearchFilter, String> searchMap = new EnumMap<>(SearchFilter.class);
    for (SingleValueTypeFilter filterType : filterTypes) {
        SearchFilter filter = filterType.getKey();
        if (filtersWithMultipleValues.contains(filter)) {
            throw new ServiceException("Filter provided with Single Value. Application Expects values as List for the Filter :" + filter);
        }
        searchMap.put(filterType.getKey(), filterType.getValue());
    }
    return searchMap;
}
Also used : SingleValueTypeFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SingleValueTypeFilter) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) EnumMap(java.util.EnumMap)

Example 80 with EnumMap

use of java.util.EnumMap in project EnderIO by SleepyTrousers.

the class ReservoirBlockRenderMapper method mapOverlayLayer.

@Override
@SideOnly(Side.CLIENT)
public EnumMap<EnumFacing, EnumIOMode> mapOverlayLayer(@Nonnull IBlockStateWrapper state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, boolean isPainted) {
    TileEntity tileEntity = state.getTileEntity();
    if ((tileEntity instanceof TileReservoir) && ((TileReservoir) tileEntity).isAutoEject()) {
        EnumMap<EnumFacing, EnumIOMode> result = new EnumMap<EnumFacing, EnumIOMode>(EnumFacing.class);
        for (NNIterator<EnumFacing> itr = NNList.FACING.fastIterator(); itr.hasNext(); ) {
            EnumFacing face = itr.next();
            IBlockState neighborState = world.getBlockState(pos.offset(face));
            if (!isSameKind(state, neighborState)) {
                result.put(face, EnumIOMode.RESERVOIR);
            }
        }
        return result.isEmpty() ? null : result;
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) EnumIOMode(crazypants.enderio.base.render.property.IOMode.EnumIOMode) EnumMap(java.util.EnumMap) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

EnumMap (java.util.EnumMap)389 Map (java.util.Map)73 ArrayList (java.util.ArrayList)70 List (java.util.List)61 HashMap (java.util.HashMap)60 Test (org.junit.Test)46 IOException (java.io.IOException)38 Collection (java.util.Collection)35 DecodeHintType (com.google.zxing.DecodeHintType)30 HashSet (java.util.HashSet)26 Set (java.util.Set)26 EncodeHintType (com.google.zxing.EncodeHintType)17 File (java.io.File)17 BitMatrix (com.google.zxing.common.BitMatrix)15 BookID (biblemulticonverter.data.BookID)14 Iterator (java.util.Iterator)14 URL (java.net.URL)12 TreeMap (java.util.TreeMap)12 Header (com.jsql.model.bean.util.Header)10 Request (com.jsql.model.bean.util.Request)10