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:org.n52.io.geojson.GeoJSONObject.java

public Map<String, Object> getMembers() {
    return Collections.unmodifiableMap(members);
}

From source file:com.threecrickets.prudence.internal.lazy.LazyInitializationFile.java

@Override
protected void initialize() {
    if ((request.getMethod().equals(Method.POST) || request.getMethod().equals(Method.PUT))
            && request.isEntityAvailable()
            && request.getEntity().getMediaType().includes(MediaType.MULTIPART_FORM_DATA)) {
        try {/*from   ww  w. j av  a2 s. c  om*/
            for (FileItem fileItem : fileUpload.parseRequest(request)) {
                if (fileItem.isFormField())
                    formFields.put(fileItem.getFieldName(), fileItem.getString());
                else
                    map.put(fileItem.getFieldName(), Collections.unmodifiableMap(createFileItemMap(fileItem)));
            }
        } catch (FileUploadException x) {
            x.printStackTrace();
        }
    }
}

From source file:org.jasig.portlet.announcements.controller.UserAgentViewNameSelector.java

public void setUserAgentMappings(Map<String, String> userAgentMappings) {
    this.userAgentMappings = Collections.unmodifiableMap(userAgentMappings);
}

From source file:com.cronutils.model.Cron.java

/**
 * Retrieve all cron field values as map
 * @return unmodifiable Map with key CronFieldName and values CronField, never null
 *///w  w w  .j ava2s .  co  m
public Map<CronFieldName, CronField> retrieveFieldsAsMap() {
    return Collections.unmodifiableMap(fields);
}

From source file:com.sap.prd.mobile.ios.ota.webapp.BaseServlet.java

/**
 * Returns an unmodifiable map containing all init parameters. 
 * @return//  ww w .jav  a  2  s.c  o m
 */
protected Map<String, String> getInitParameters() {
    HashMap<String, String> map = new HashMap<String, String>();
    try {
        Enumeration<String> initParameterNames = this.getServletContext().getInitParameterNames();
        while (initParameterNames.hasMoreElements()) {
            String name = initParameterNames.nextElement();
            map.put(name, this.getServletContext().getInitParameter(name));
        }
    } catch (IllegalStateException e) {
        if (!e.getMessage().equals("ServletConfig has not been initialized"))
            throw e;
    }
    return Collections.unmodifiableMap(map);
}

From source file:com.cprassoc.solr.auth.security.Sha256AuthenticationProvider.java

public void init(Map<String, Object> pluginConfig) {
    if (pluginConfig.get("realm") != null)
        this.realm = (String) pluginConfig.get("realm");
    else/*www. j av  a  2 s . co  m*/
        this.realm = "solr";

    promptHeader = Collections
            .unmodifiableMap(Collections.singletonMap("WWW-Authenticate", "Basic realm=\"" + realm + "\""));
    credentials = new LinkedHashMap<>();
    Map<String, String> users = (Map<String, String>) pluginConfig.get("credentials");
    if (users == null) {
        log.debug("No users configured yet");
        return;
    }
    for (Map.Entry<String, String> e : users.entrySet()) {
        String v = e.getValue();
        if (v == null) {
            log.warn("user has no password " + e.getKey());
            continue;
        }
        credentials.put(e.getKey(), v);
    }

}

From source file:com.cloudera.flume.core.EventBaseImpl.java

/**
 * Instead of package private, I make this method return an unmodifiable map.
 * I don't want external methods to modify the internal map
 *//*from  w ww.jav a  2 s  .c  om*/
public Map<String, byte[]> getAttrs() {
    return Collections.unmodifiableMap(fields);
}

From source file:com.hortonworks.registries.schemaregistry.state.SchemaVersionLifecycleStateMachine.java

private SchemaVersionLifecycleStateMachine(Map<Byte, SchemaVersionLifecycleState> states,
        Map<SchemaVersionLifecycleStateTransition, SchemaVersionLifecycleStateAction> transitions,
        Map<SchemaVersionLifecycleStateTransition, ConcurrentLinkedQueue<SchemaVersionLifecycleStateTransitionListener>> listeners) {
    this.states = Collections.unmodifiableMap(states);
    this.transitions = Collections.unmodifiableMap(transitions);
    this.listeners = Collections.unmodifiableMap(listeners).entrySet().stream().collect(Collectors.toMap(
            Map.Entry::getKey,//  ww w.  ja  va 2 s  .  co m
            transitionWithListener -> Lists.newArrayList(transitionWithListener.getValue().iterator())));
}

From source file:com.google.code.activetemplates.impl.handlers.BuiltinHandlerSPI.java

public Map<QName, ElementHandler> getElementHandlers() {
    return Collections.unmodifiableMap(elements);
}