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.jasig.portlet.newsreader.mvc.portlet.singlefeed.EditSingleFeedPreferencesController.java

@Override
public void afterPropertiesSet() throws Exception {

    Map<String, String> m = new HashMap<String, String>();
    m.put("flyout", "a list with flyouts");
    m.put("titleAndAbstract", "a list of titles with summaries");
    m.put("title", "a list of titles only");
    optionsViewTypes = Collections.unmodifiableMap(m);

    optionsMaxStories = Arrays.asList(new Integer[] { 5, 10, 15, 20 });

}

From source file:com.blackbear.flatworm.FileFormat.java

public Map<String, Record> getRecords() {
    return Collections.unmodifiableMap(records);
}

From source file:contrail.stages.GraphToFasta.java

/**
 * Get the parameters used by this stage.
 *///from  w ww  .  java2  s . co  m
protected Map<String, ParameterDefinition> createParameterDefinitions() {
    HashMap<String, ParameterDefinition> defs = new HashMap<String, ParameterDefinition>();

    defs.putAll(super.createParameterDefinitions());

    for (ParameterDefinition def : ContrailParameters.getInputOutputPathOptions()) {
        defs.put(def.getName(), def);
    }
    return Collections.unmodifiableMap(defs);
}

From source file:com.impetus.kundera.ejb.EntityManagerFactoryBuilder.java

/**
* Builds up EntityManagerFactory for a given persistenceUnitName and
* overriding properties.//from  ww  w .j  av  a2  s. com
* 
* @param persistenceUnitName
*            the persistence unit name
* @param override
*            the override
* @return the entity manager factory
*/
public EntityManagerFactory buildEntityManagerFactory(String persistenceUnitName,
        Map<Object, Object> override) {
    PersistenceMetadata metadata = getPersistenceMetadata(persistenceUnitName);

    Properties props = new Properties();
    // Override properties
    Properties metadataProperties = metadata.getProps();
    // Make sure, it's empty or Unmodifiable
    override = override == null ? Collections.EMPTY_MAP : Collections.unmodifiableMap(override);

    // Take all from Metadata and override with supplied map 
    for (Map.Entry<Object, Object> entry : metadataProperties.entrySet()) {
        Object key = entry.getKey();
        Object value = entry.getValue();

        if (override.containsKey(key)) {
            value = override.get(key);
        }
        props.put(key, value);
    }

    // Now take all the remaining ones from override
    for (Map.Entry<Object, Object> entry : override.entrySet()) {
        Object key = entry.getKey();
        Object value = entry.getValue();

        if (!props.containsKey(key)) {
            props.put(key, value);
        }
    }

    log.info("Building EntityManagerFactory for name: " + metadata.getName() + ", and Properties:" + props);
    return new EntityManagerFactoryImpl(metadata, props);
}

From source file:org.hawkular.bus.common.SimpleBasicMessage.java

/**
 * Optional additional details about this message. This could be null if there are no additional details associated
 * with this message./*from   w w w  . ja  va  2s. com*/
 *
 * @return the details of this message or null. This is an unmodifiable, read-only map of details.
 */
public Map<String, String> getDetails() {
    if (details == null) {
        return null;
    }
    return Collections.unmodifiableMap(details);
}

From source file:io.kazuki.v0.store.schema.model.Schema.java

@JsonCreator
public Schema(@JsonProperty("attributes") List<Attribute> attributes,
        @JsonProperty("indexes") @Nullable List<IndexDefinition> indexes) {
    Preconditions.checkNotNull(attributes, "attributes");

    this.attributes = Collections.unmodifiableList(attributes);

    Map<String, Attribute> newAttributes = new LinkedHashMap<String, Attribute>();
    for (Attribute attr : attributes) {
        newAttributes.put(attr.getName(), attr);
    }// w  ww  . ja  v a2 s .  c  o m

    this.attributeMap = Collections.unmodifiableMap(newAttributes);

    if (indexes == null || indexes.isEmpty()) {
        this.indexes = ImmutableList.of();
        this.indexMap = ImmutableMap.of();
    } else {
        this.indexes = Collections.unmodifiableList(indexes);

        Map<String, IndexDefinition> newIndexes = new LinkedHashMap<String, IndexDefinition>();
        for (IndexDefinition index : indexes) {
            String name = index.getName();

            if (newIndexes.containsKey(name)) {
                throw new IllegalArgumentException("duplicate index entry for '" + name + "'");
            }

            if (newIndexes.size() > 0 && index.isUnique()) {
                throw new IllegalArgumentException(
                        "at most one unique 'index' may be present per schema and must be the first index listed in order");
            }

            for (IndexAttribute attr : index.getIndexAttributes()) {
                String attrName = attr.getName();

                if (!attributeMap.containsKey(attrName)) {
                    throw new IllegalArgumentException(
                            "index '" + name + "' references unknown attribute '" + attrName);
                }
            }

            newIndexes.put(name, index);
        }

        this.indexMap = Collections.unmodifiableMap(newIndexes);
    }
}

From source file:ru.jts_dev.gameserver.service.GameSessionService.java

Map<String, GameSession> getSessions() {
    return Collections.unmodifiableMap(sessions);
}

From source file:de.dev.eth0.elasticsearch.aem.indexing.IndexEntry.java

/**
 *
 * @return unmodifiable map with the content
 */
public Map<String, Object> getContent() {
    return Collections.unmodifiableMap(content);
}

From source file:com.htmlhifive.pitalium.core.config.PtlTestConfig.java

/**
 * //from   w w w.j  a  v  a  2 s . c o m
 * 
 * @param startupArguments 
 */
@VisibleForTesting
PtlTestConfig(Map<String, String> startupArguments) {
    this.startupArguments = Collections.unmodifiableMap(startupArguments);
}