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:edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ObjectPropertyStatementTemplateModel.java

public ObjectPropertyStatementTemplateModel(String subjectUri, ObjectProperty property, String objectKey,
        Map<String, String> data, String templateName, VitroRequest vreq) {
    super(subjectUri, property, vreq);

    this.data = Collections.unmodifiableMap(new HashMap<String, String>(data));
    this.objectUri = data.get(objectKey);
    this.templateName = templateName;
    //to keep track of later
    this.objectKey = objectKey;

    // Do delete url first, since it is used in building edit url
    this.deleteUrl = makeDeleteUrl();
    this.editUrl = makeEditUrl();
}

From source file:com.evrythng.thng.resource.model.core.ResourceModel.java

@CsvTransient
public Map<String, Object> getCustomFields() {

    return customFields != null ? Collections.unmodifiableMap(customFields) : null;
}

From source file:com.github.pjungermann.config.specification.constraint.ConstraintRegistry.java

@Inject
public ConstraintRegistry(final List<ConstraintFactory> constraintFactoryList) {
    if (constraintFactoryList == null) {
        this.mapping = emptyMap();
        return;//  ww w .j  a va  2  s.c o  m
    }

    Map<String, ConstraintFactory> mapping = new HashMap<>();
    constraintFactoryList.stream()
            .forEach(constraintFactory -> mapping.put(constraintFactory.getName(), constraintFactory));

    this.mapping = Collections.unmodifiableMap(mapping);
}

From source file:org.apache.solr.common.util.Utils.java

public static Map getDeepCopy(Map map, int maxDepth, boolean mutable) {
    if (map == null)
        return null;
    if (maxDepth < 1)
        return map;
    Map copy = new LinkedHashMap();
    for (Object o : map.entrySet()) {
        Map.Entry e = (Map.Entry) o;
        Object v = e.getValue();//from w  ww.j a  v a  2s.com
        if (v instanceof Map)
            v = getDeepCopy((Map) v, maxDepth - 1, mutable);
        else if (v instanceof Collection)
            v = getDeepCopy((Collection) v, maxDepth - 1, mutable);
        copy.put(e.getKey(), v);
    }
    return mutable ? copy : Collections.unmodifiableMap(copy);
}

From source file:com.chiorichan.factory.StackFactory.java

public Map<String, ScriptingContext> getScriptTrace() {
    return Collections.unmodifiableMap(scriptStack);
}

From source file:com.github.lynxdb.server.core.Aggregators.java

@Autowired
public Aggregators(ApplicationContext _context) {
    Map<String, Aggregator> tmp = new HashMap<>();
    _context.getBeansOfType(Aggregator.class).forEach((String t, Aggregator u) -> {
        tmp.put(u.getName(), u);/*from  w ww .java  2 s. com*/
    });
    this.aggregators = Collections.unmodifiableMap(tmp);
}

From source file:com.vmware.identity.idm.IdentityStoreObjectMapping.java

private IdentityStoreObjectMapping(String objectId, String objectClass,
        Map<String, IdentityStoreAttributeMapping> attributesMapping) {
    this._objectId = objectId;
    this._objectClass = objectClass;
    this._storeAttributes = new HashMap<String, IdentityStoreAttributeMapping>();
    this._storeAttributes.putAll(attributesMapping);
    this._storeAttributes = Collections.unmodifiableMap(this._storeAttributes);
}

From source file:io.cloudslang.lang.runtime.env.Context.java

public Map<String, Value> getImmutableViewOfVariables() {
    return Collections.unmodifiableMap(variables);
}

From source file:com.acme.legacy.app.repository.JsonUserRepository.java

@PostConstruct
@SuppressWarnings("unchecked")
public void init() throws Exception {
    Resource resource = new ClassPathResource("users.json");
    ObjectMapper mapper = Jackson2ObjectMapperBuilder.json().build();
    List<User> userList = mapper.readValue(resource.getInputStream(), new TypeReference<List<User>>() {
    });//w  ww.j  av  a2  s .co m
    Map<String, User> userMap = new TreeMap<>();

    for (User user : userList)
        userMap.put(user.getEmail(), user);

    this.users = Collections.unmodifiableMap(userMap);
}

From source file:com.google.uzaygezen.core.MapNode.java

private MapNode(V value, Map<K, MapNode<K, V>> children) {
    this.value = Preconditions.checkNotNull(value, "value");
    // Lame attempt to detect cycles.
    Preconditions.checkArgument(!children.values().contains(this), "I can't be my own child.");
    this.children = Collections.unmodifiableMap(children);
}