Example usage for java.util Collections unmodifiableMap

List of usage examples for java.util Collections unmodifiableMap

Introduction

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

Prototype

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

Source Link

Document

Returns an unmodifiable view of the specified map.

Usage

From source file:com.alta189.cyborg.api.util.config.AbstractConfigurationNodeSource.java

@Override
public Map<String, ConfigurationNode> getChildren() {
    return Collections.unmodifiableMap(children);
}

From source file:cc.kave.commons.pointsto.evaluation.ProjectTrainValidateEvaluation.java

public Map<ICoReTypeName, List<EvaluationResult>> getResults() {
    return Collections.unmodifiableMap(results);
}

From source file:ee.ria.xroad.signer.model.Token.java

/**
 * Converts this object to value object.
 * @return the value object// ww  w.java  2 s.co m
 */
public TokenInfo toDTO() {
    return new TokenInfo(type, friendlyName, id, readOnly, available, active, serialNumber, label, slotIndex,
            status, Collections.unmodifiableList(getKeysAsDTOs()), Collections.unmodifiableMap(tokenInfo));
}

From source file:com.addthis.codec.plugins.PluginRegistry.java

public PluginRegistry(@Nonnull Config config) {
    this.config = config;
    Config defaultPluginMapSettings = config.getConfig(PLUGIN_DEFAULTS_PATH);
    String pluginPath = config.getString(PLUGINS_PATH_PATH);
    Config pluginConfigs = config.getConfig(pluginPath);

    Set<String> categories = pluginConfigs.root().keySet();
    Map<String, PluginMap> mapsFromConfig = new HashMap<>(categories.size());
    BiMap<Class<?>, PluginMap> mapsFromConfigByClass = HashBiMap.create(categories.size());
    // Throwaway ObjectMapper to facilitate AnnotatedClass construction below
    ObjectMapper temp = new ObjectMapper();
    for (String category : categories) {
        Config pluginConfig = pluginConfigs.getConfig(category).withFallback(defaultPluginMapSettings);
        PluginMap pluginMap = new PluginMap(category, pluginConfig);
        mapsFromConfig.put(category, pluginMap);
        Class<?> baseClass = pluginMap.baseClass();
        if (baseClass != null) {
            // if two categories define _class, then ensure the annotated one (if any) is the canonical one
            if (mapsFromConfigByClass.containsKey(baseClass)) {
                AnnotatedClass annotatedClass = AnnotatedClass.construct(temp.constructType(baseClass),
                        temp.getDeserializationConfig());
                String existingCategory = mapsFromConfigByClass.get(baseClass).category();
                if (!annotatedClass.hasAnnotation(Pluggable.class)
                        || !annotatedClass.getAnnotation(Pluggable.class).value().equals(existingCategory)) {
                    mapsFromConfigByClass.put(pluginMap.baseClass(), pluginMap);
                }//from w  w w .  ja  va  2s. c o  m
            } else {
                mapsFromConfigByClass.put(pluginMap.baseClass(), pluginMap);
            }
        }
    }
    pluginMapsByCategory = Collections.unmodifiableMap(mapsFromConfig);
    pluginMapsByClass = Maps.unmodifiableBiMap(mapsFromConfigByClass);
}

From source file:com.microsoft.azure.keyvault.authentication.KeyVaultCredentials.java

@Override
public Header authenticate(ServiceRequestContext request, BearerAuthentication authentication) {

    // This method is called when the server answers with a 401 -
    // Unauthorized and a challenge.
    // This method must return a token header that answers the challenge.
    // This header is added in a retry.

    // Let's cache the challenge for the current authority, avoiding future
    // 401 answers.
    Map<String, String> challenge = authentication.getParameters();
    challenge = new HashMap<String, String>(challenge); // Defensive copy.
    challenge = Collections.unmodifiableMap(challenge);
    String authority = getAuthority(request);
    addCachedChallenge(authority, challenge);

    // Asks the callback to perform authentication.
    return doAuthenticate(request, challenge);
}

From source file:com.trenako.results.SearchRange.java

/**
 * Returns the current {@code SearchRange} as a {@code Map}.
 * <p>// w  w  w  . j av  a  2s  .c  om
 * The returned maps contain only not default values.
 * </p>
 *
 * @return the values {@code Map}
 */
public Map<String, Object> asMap() {
    Map<String, Object> params = new TreeMap<String, Object>();

    if (getSince() != null) {
        params.put(RangeRequest.SINCE_NAME, getSince());
    }

    if (getMax() != null) {
        params.put(RangeRequest.MAX_NAME, getMax());
    }

    if (getSort() != null && !isDefaultSort()) {
        params.put(RangeRequest.SORT_NAME, getFirstOrder().getProperty());
        params.put(RangeRequest.ORDER_NAME, getFirstOrder().getDirection());
    }

    if (!isDefaultPageSize()) {
        params.put(RangeRequest.SIZE_NAME, getPageSize());
    }

    return Collections.unmodifiableMap(params);
}

From source file:net.systran.platform.geographic.client.ApiClient.java

public ApiClient() {
    // Use ISO 8601 format for date and datetime.
    // See https://en.wikipedia.org/wiki/ISO_8601
    this.dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");

    // Use UTC as the default time zone.
    this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

    // Set default User-Agent.
    setUserAgent("Java-Systran");

    // Setup authentications (key: authentication name, value: authentication).
    authentications = new HashMap<String, Authentication>();
    authentications.put("apiKey", new ApiKeyAuth("query", "key"));
    authentications.put("accessToken", new ApiKeyAuth("header", "Authorization"));
    // Prevent the authentications from being modified.
    authentications = Collections.unmodifiableMap(authentications);
}

From source file:de.xwic.appkit.core.remote.server.ParameterProvider.java

/**
 * @param map/*from www  .java2s .  c  o m*/
 * @return
 */
private static <K, V> Map<K, V> unmodifiable(final Map<K, V> map) {
    if (map == null) {
        return EMPTY_MAP;
    }
    return Collections.unmodifiableMap(map);
}

From source file:com.vangent.hieos.services.xds.bridge.mapper.ContentParserConfig.java

/**
 * Method description//  w w  w  . j av  a 2s .  c  om
 *
 *
 * @return
 */
public Map<String, String> getNamespaces() {
    return Collections.unmodifiableMap(this.namespaces);
}