Example usage for java.util EnumMap EnumMap

List of usage examples for java.util EnumMap EnumMap

Introduction

In this page you can find the example usage for java.util EnumMap EnumMap.

Prototype

public EnumMap(Map<K, ? extends V> m) 

Source Link

Document

Creates an enum map initialized from the specified map.

Usage

From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.RulesActivityServiceBean.java

public Map<ActivityTableType, List<IdType>> getNonUniqueIdsList(Object requestMessage) {
    Map<ActivityTableType, List<IdType>> nonUniqueIdsMap = new EnumMap<>(ActivityTableType.class);
    GetNonUniqueIdsResponse getNonUniqueIdsResponse = null;
    FLUXFAReportMessage fluxFaRepMessage;
    if (requestMessage != null && requestMessage instanceof FLUXFAReportMessage) {
        fluxFaRepMessage = (FLUXFAReportMessage) requestMessage;
    } else {/*from w  w w  . jav a2 s. c o m*/
        log.error("Either FLUXFAReportMessage is null or is not of the right type!");
        return nonUniqueIdsMap;
    }
    try {
        String strReq = ActivityModuleRequestMapper
                .mapToGetNonUniqueIdRequest(collectAllIdsFromMessage(fluxFaRepMessage));
        if (StringUtils.isEmpty(strReq)) {
            log.warn(
                    "No IDs were found to issue request for in method RulesActivityServiceBean.getNonUniqueIdsList(..){...}. Empty list will be returned");
            return nonUniqueIdsMap;
        }
        String jmsCorrelationId = producer.sendDataSourceMessage(strReq, DataSourceQueue.ACTIVITY);
        TextMessage message = consumer.getMessage(jmsCorrelationId, TextMessage.class);
        getNonUniqueIdsResponse = ActivityModuleResponseMapper.mapToGetUniqueIdResponseFromResponse(message,
                jmsCorrelationId);
    } catch (MessageException | ActivityModelMapperException e) {
        log.error(
                "ERROR when sending/consuming message from ACTIVITY module. Service : RulesActivityServiceBean.getNonUniqueIdsList(Object requestMessage){...}",
                e);
    }

    if (getNonUniqueIdsResponse != null
            && CollectionUtils.isNotEmpty(getNonUniqueIdsResponse.getActivityUniquinessLists())) {
        mapGetUniqueIdResponseToIdsMap(nonUniqueIdsMap, getNonUniqueIdsResponse.getActivityUniquinessLists());
    }

    return nonUniqueIdsMap;
}

From source file:com.adobe.acs.commons.mcp.impl.processes.cfi.ContentFragmentImport.java

private synchronized EnumMap<ReportColumns, Object> trackActivity(String item, String action,
        String description) {//from  w ww .j  a  v a 2  s.  c om
    if (reportRows == null) {
        reportRows = Collections.synchronizedList(new ArrayList<>());
    }
    EnumMap<ReportColumns, Object> reportRow = new EnumMap<>(ReportColumns.class);
    reportRow.put(ReportColumns.ITEM, item);
    reportRow.put(ReportColumns.ACTION, action);
    reportRow.put(ReportColumns.DESCRIPTION, description);
    reportRow.put(ReportColumns.COUNT, 0L);
    reportRows.add(reportRow);
    return reportRow;
}

From source file:org.openecomp.sdc.be.externalapi.servlet.AssetsDataServlet.java

@GET
@Path("/{assetType}")
@Produces(MediaType.APPLICATION_JSON)//  ww  w  . ja  va2s . co  m
@ApiOperation(value = "Fetch list of assets", httpMethod = "GET", notes = "Returns list of assets", response = Response.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Assets Fetched"),
        @ApiResponse(code = 400, message = "Invalid content / Missing content"),
        @ApiResponse(code = 401, message = "Authorization required"),
        @ApiResponse(code = 403, message = "Restricted operation"),
        @ApiResponse(code = 404, message = "Asset not found") })
public Response getAssetList(@PathParam("assetType") final String assetType,
        @QueryParam("category") String category, @QueryParam("subCategory") String subCategory,
        @QueryParam("distributionStatus") String distributionStatus) {

    Response response = null;
    ResponseFormat responseFormat = null;
    String instanceIdHeader = request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER);
    String query = request.getQueryString();
    String requestURI = request.getRequestURI();
    String url = request.getMethod() + " " + requestURI;
    log.debug("Start handle request of {}", url);
    String serverBaseURL = request.getRequestURL().toString();

    AuditingActionEnum auditingActionEnum = query == null ? AuditingActionEnum.GET_ASSET_LIST
            : AuditingActionEnum.GET_FILTERED_ASSET_LIST;

    EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>(
            AuditingFieldsKeysEnum.class);
    additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_CONSUMER_ID, instanceIdHeader);
    additionalParam.put(AuditingFieldsKeysEnum.AUDIT_DISTRIBUTION_RESOURCE_URL,
            query == null ? requestURI : requestURI + "?" + query);

    // Mandatory
    if (instanceIdHeader == null || instanceIdHeader.isEmpty()) {
        log.debug("getAssetList: Missing X-ECOMP-InstanceID header");
        responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
        getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
        return buildErrorResponse(responseFormat);
    }

    try {
        ServletContext context = request.getSession().getServletContext();
        ElementBusinessLogic elementLogic = getElementBL(context);

        getAssetUtils(context);
        Map<FilterKeyEnum, String> filters = new HashMap<FilterKeyEnum, String>();

        if (category != null) {
            filters.put(FilterKeyEnum.CATEGORY, category);
        }
        if (subCategory != null) {
            filters.put(FilterKeyEnum.SUB_CATEGORY, subCategory);
        }
        if (distributionStatus != null) {
            filters.put(FilterKeyEnum.DISTRIBUTION_STATUS, distributionStatus);
        }

        Either<List<? extends Component>, ResponseFormat> assetTypeData = elementLogic
                .getFilteredCatalogComponents(assetType, filters, query);

        if (assetTypeData.isRight()) {
            log.debug("getAssetList: Asset Fetching Failed");
            responseFormat = assetTypeData.right().value();
            getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
            return buildErrorResponse(responseFormat);
        } else {
            log.debug("getAssetList: Asset Fetching Success");
            Either<List<? extends AssetMetadata>, ResponseFormat> resMetadata = assetMetadataUtils
                    .convertToAssetMetadata(assetTypeData.left().value(), serverBaseURL, false);
            if (resMetadata.isRight()) {
                log.debug("getAssetList: Asset conversion Failed");
                responseFormat = resMetadata.right().value();
                getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);
                return buildErrorResponse(responseFormat);
            }
            Object result = RepresentationUtils.toRepresentation(resMetadata.left().value());
            responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
            getComponentsUtils().auditExternalGetAsset(responseFormat, auditingActionEnum, additionalParam);

            response = buildOkResponse(responseFormat, result);
            return response;
        }
    } catch (Exception e) {
        BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Fetch filtered list of assets");
        log.debug("getAssetList: Fetch list of assets failed with exception", e);
        return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
    }
}

From source file:com.autentia.common.statemachine.StateMachine.java

private void checkConsistency() {
    Assert.state(!states.isEmpty(), "This state machine does not have states");

    // Todos los estados del enumerado estn contemplados en la mquina de estados
    final T[] enumConstants = enumClass.getEnumConstants();
    final Map<T, T> notVisitedStates = new EnumMap<T, T>(enumClass);
    for (T enumConstant : enumConstants) {
        checkState(enumConstant);/*from w  ww.  j  av  a 2s . c o  m*/
        notVisitedStates.put(enumConstant, enumConstant);
    }

    // Todos los estados son alcanzables
    // Se comprueba que cada estado est, al menos, en un 'to', a excepcin del estado inicial
    visitStates(initialState, notVisitedStates);
    if (!notVisitedStates.isEmpty()) {
        final StringBuilder errMsg = new StringBuilder("Some states are not reachable: ");
        for (Enum<?> enumConstant : notVisitedStates.values()) {
            errMsg.append(enumConstant).append(" ");
        }
        throw new IllegalStateException(errMsg.toString());
    }

    // Los estados finales no tienen transiciones de salida.
    for (T state : finalStates) {
        Assert.state(CollectionUtils.isEmpty(states.get(state).getRight()),
                "Final state " + state + " cannot have output transitions");
    }
}

From source file:dk.netarkivet.harvester.indexserver.distribute.IndexRequestServer.java

/**
 * Initialise index request server with no handlers, listening to the index JMS channel.
 *//*from w  w w  . j  ava  2 s  . c  o m*/
private IndexRequestServer() {
    maxConcurrentJobs = Settings.getLong(HarvesterSettings.INDEXSERVER_INDEXING_MAXCLIENTS);
    requestDir = Settings.getFile(HarvesterSettings.INDEXSERVER_INDEXING_REQUESTDIR);
    listeningInterval = Settings.getLong(HarvesterSettings.INDEXSERVER_INDEXING_LISTENING_INTERVAL);
    satisfactoryThresholdPercentage = Settings
            .getInt(HarvesterSettings.INDEXSERVER_INDEXING_SATISFACTORYTHRESHOLD_PERCENTAGE);

    currentJobs = new HashMap<String, IndexRequestMessage>();
    handlers = new EnumMap<RequestType, FileBasedCache<Set<Long>>>(RequestType.class);
    conn = JMSConnectionFactory.getInstance();
    checkIflisteningTimer = new Timer();
}

From source file:org.ligoj.app.plugin.vm.azure.VmAzurePluginResource.java

/**
 * Register a mapping Status+operation to operation.
 * //from   w  ww. j a v  a2 s .c  o  m
 * @param status
 *            The current status.
 * @param operation
 *            The requested operation
 * @param operationFailSafe
 *            The computed operation.
 */
private static void registerOperation(final VmStatus status, final VmOperation operation,
        final VmOperation operationFailSafe) {
    FAILSAFE_OPERATIONS.computeIfAbsent(status, s -> new EnumMap<>(VmOperation.class));
    FAILSAFE_OPERATIONS.get(status).put(operation, operationFailSafe);
}

From source file:com.adobe.acs.commons.mcp.impl.processes.DataImporter.java

protected synchronized EnumMap<ReportColumns, Object> trackActivity(String item, String action, Integer count) {
    if (reportRows == null) {
        reportRows = Collections.synchronizedList(new ArrayList<>());
    }/*www.j ava  2 s. c  o  m*/
    EnumMap<ReportColumns, Object> reportRow = new EnumMap<>(ReportColumns.class);
    reportRow.put(ReportColumns.item, item);
    reportRow.put(ReportColumns.action, action);
    reportRow.put(ReportColumns.count, count);
    reportRows.add(reportRow);
    return reportRow;
}

From source file:fr.ritaly.dungeonmaster.map.FloorSwitch.java

public void setActuator(TriggerType triggerType, Actuator actuator) {
    Validate.notNull(triggerType, "The given trigger type is null");
    Validate.notNull(actuator, "The given actuator is null");

    if (actuators == null) {
        // Crer la Map  la vole
        actuators = new EnumMap<TriggerType, Actuator>(TriggerType.class);
    }/*from w  ww. jav a2 s.  c o m*/

    actuators.put(triggerType, actuator);
}

From source file:edu.cornell.mannlib.vitro.webapp.modelaccess.impl.ContextModelAccessImpl.java

private Map<WhichService, RDFService> populateRdfServiceMap() {
    Map<WhichService, RDFService> map = new EnumMap<>(WhichService.class);
    map.put(CONTENT, factory.getRDFService(CONTENT));
    map.put(CONFIGURATION, factory.getRDFService(CONFIGURATION));
    log.debug("RdfServiceMap: " + map);
    return Collections.unmodifiableMap(map);
}

From source file:org.matsim.contrib.dvrp.util.chart.RouteChartUtils.java

private static Map<TaskStatus, CoordSource> createLinkSourceByStatus(Schedule<? extends Task> schedule) {
    Iterable<DriveTask> tasks = Schedules.createDriveTaskIter(schedule);

    // creating lists of DriveTasks
    Map<TaskStatus, List<DriveTask>> taskListByStatus = new EnumMap<>(TaskStatus.class);

    for (TaskStatus ts : TaskStatus.values()) {
        taskListByStatus.put(ts, new ArrayList<DriveTask>());
    }//from  ww  w .ja  va2  s .  c  om

    for (DriveTask t : tasks) {
        taskListByStatus.get(t.getStatus()).add(t);
    }

    // creating LinkSources
    Map<TaskStatus, CoordSource> linkSourceByStatus = new EnumMap<>(TaskStatus.class);

    for (TaskStatus ts : TaskStatus.values()) {
        linkSourceByStatus.put(ts, LinkSources.createFromDriveTasks(taskListByStatus.get(ts)));
    }

    return linkSourceByStatus;
}