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.megacorp.commerce.Customer.java

public Map<String, String> getPreferences() {
    return Collections.unmodifiableMap(preferences);
}

From source file:edu.wisc.my.redirect.url.PortalUrlImpl.java

public Map<String, String[]> getParameters() {
    return Collections.unmodifiableMap(this.parameters);
}

From source file:com.amazonaws.mobileconnectors.s3.transferutility.TransferStatusUpdater.java

/**
 * Gets all active transfers.
 *
 * @return an unmodifiable map of transfers
 */
Map<Integer, TransferRecord> getTransfers() {
    return Collections.unmodifiableMap(transfers);
}

From source file:com.heliosdecompiler.helios.LoadedFile.java

public void reset() {
    readDataQuick();//from w w  w  .  j  a  v  a2  s  .c om
    if (files.size() > 0) {
        // Read all data of potential class files
        Helios.submitBackgroundTask(() -> {
            Map<String, ClassNode> emptyClasses = new HashMap<>();
            files.entrySet().stream().filter(ent -> ent.getKey().endsWith(".class")).forEach(ent -> {
                try {
                    ClassReader classReader = new ClassReader(new ByteArrayInputStream(ent.getValue()));
                    ClassNode classNode = new ClassNode();
                    classReader.accept(classNode,
                            ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);

                    // Store by ClassNode name
                    emptyClasses.put(classNode.name, classNode);
                    // Also store by path
                    emptyClasses.put(ent.getKey(), classNode);
                } catch (Exception ignored) { //Malformed class
                }
            });
            // Lock the map
            this.emptyClasses = Collections.unmodifiableMap(emptyClasses);
            if (!this.isPath) {
                // Read the code as well
                // fixme If path jars are guarenteed to not require code then maybe we can merge emptyClasses and classes
                // fixme this seems to hog cpu cycles or something
                Helios.submitBackgroundTask(() -> {
                    Map<String, ClassNode> classes = new HashMap<>();
                    files.entrySet().stream().filter(ent -> ent.getKey().endsWith(".class")).forEach(ent -> {
                        try {
                            ClassReader classReader = new ClassReader(new ByteArrayInputStream(ent.getValue()));
                            ClassNode classNode = new ClassNode();
                            classReader.accept(classNode, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);

                            // Store by ClassNode name
                            classes.put(classNode.name, classNode);
                            // Also store by path
                            classes.put(ent.getKey(), classNode);
                        } catch (Exception ignored) { //Malformed class
                        }
                    });
                    // Lock the map
                    this.classes = Collections.unmodifiableMap(classes);
                });
            } else {
                this.classes = Collections.synchronizedMap(new HashMap<>());
            }
        });
    }
}

From source file:org.ops4j.pax.web.itest.base.client.HttpComponentsWrapper.java

HttpComponentsWrapper(Map<String, String> httpHeaders, String user, String password, String keyStore)
        throws Exception {
    if (httpHeaders != null) {
        this.httpHeaders = Collections.unmodifiableMap(httpHeaders);
    } else {/*from   w ww .  j  a v  a2s. c om*/
        this.httpHeaders = Collections.unmodifiableMap(Collections.emptyMap());
    }
    this.user = user;
    this.password = password;

    if (keyStore.startsWith("${")) {
        int indexOfPlaceHolder = keyStore.indexOf("}");
        String placeHolder = keyStore.substring(0, indexOfPlaceHolder);
        placeHolder = placeHolder.substring(2, placeHolder.length());
        String property = System.getProperty(placeHolder);
        this.keyStore = property + keyStore.substring(indexOfPlaceHolder + 1);
    } else {
        this.keyStore = keyStore;
    }

    httpclient = createHttpClient();
    httpAsyncClient.start();
}

From source file:com.akamai.edgegrid.signer.Request.java

Map<String, String> getHeaders() {
    return Collections.unmodifiableMap(headers);
}

From source file:com.github.restdriver.clientdriver.HttpRealRequest.java

@Override
public final Map<String, Object> getHeaders() {
    return Collections.unmodifiableMap(headers);
}

From source file:com.opengamma.engine.view.compilation.CompiledViewDefinitionImpl.java

@Override
public Map<ValueRequirement, ValueSpecification> getMarketDataRequirements() {
    Map<ValueRequirement, ValueSpecification> allRequirements = new HashMap<ValueRequirement, ValueSpecification>();
    for (CompiledViewCalculationConfiguration compiledCalcConfig : getCompiledCalculationConfigurations()) {
        allRequirements.putAll(compiledCalcConfig.getMarketDataRequirements());
    }//from www.  j a v  a 2 s .  co m
    return Collections.unmodifiableMap(allRequirements);
}

From source file:com.mirth.connect.plugins.httpauth.RequestInfo.java

public Map<String, List<String>> getHeaders() {
    Map<String, List<String>> headers = new CaseInsensitiveMap<String, List<String>>();
    for (Entry<String, List<String>> entry : this.headers.entrySet()) {
        headers.put(entry.getKey(), Collections.unmodifiableList(entry.getValue()));
    }//from  w ww. jav a 2  s. c om
    return Collections.unmodifiableMap(headers);
}

From source file:libepg.epg.section.SectionLoader.java

public Map<Integer, List<Section>> load() throws FileNotFoundException {

    //??/*from   w w  w. j a  va2  s  . c  o  m*/
    if (!tsFile.isFile()) {
        throw new FileNotFoundException(
                "???? = " + tsFile.getAbsolutePath());
    }

    LOG.info("?? = " + tsFile.getAbsolutePath());
    final TsReader reader = new TsReader(tsFile, pids, readLimit);
    Map<Integer, List<TsPacketParcel>> pid_packets = reader.getPackets();

    Map<Integer, List<Section>> pids_sections_temp = new ConcurrentHashMap<>();
    for (Integer pidKey : pid_packets.keySet()) {
        LOG.info("?pid = " + Integer.toHexString(pidKey) + " pid = "
                + RESERVED_PROGRAM_ID.reverseLookUp(pidKey));
        SectionReconstructor sectionMaker = new SectionReconstructor(pid_packets.get(pidKey), pidKey);
        List<Section> sections = sectionMaker.getSections();
        if (sections != null) {
            LOG.info(" = " + sections.size());
            pids_sections_temp.put(pidKey, sections);
        }
    }
    return Collections.unmodifiableMap(pids_sections_temp);

}