All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.axway.apim.lib.error.ErrorCodeMapper Maven / Gradle / Ivy

package com.axway.apim.lib.error;

import java.util.HashMap;
import java.util.Map;

public class ErrorCodeMapper {

    private final Map myMap = new HashMap<>();


    public ErrorCodeMapper() {
        super();
    }

    public void setMapConfiguration(String mapConfiguration) {
        if (mapConfiguration == null) return;
        String[] codeMaps = mapConfiguration.split(",");
        Map allErrorCodes = new HashMap<>();
        if (codeMaps.length > 0) {
            for (ErrorCode code : ErrorCode.values()) {
                allErrorCodes.put(code.getCode(), code);
            }
        }
        for (String map : codeMaps) {
            String[] config = map.split(":");
            int inputCode = Integer.parseInt(config[0].trim());
            int outputCode = Integer.parseInt(config[1].trim());
            myMap.put(allErrorCodes.get(inputCode), allErrorCodes.get(outputCode));
        }
    }

    public ErrorCode getMapedErrorCode(ErrorCode code) {
        return myMap.getOrDefault(code, code);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy