Example usage for com.google.common.collect Multimaps unmodifiableListMultimap

List of usage examples for com.google.common.collect Multimaps unmodifiableListMultimap

Introduction

In this page you can find the example usage for com.google.common.collect Multimaps unmodifiableListMultimap.

Prototype

@Deprecated
public static <K, V> ListMultimap<K, V> unmodifiableListMultimap(ImmutableListMultimap<K, V> delegate) 

Source Link

Document

Simply returns its argument.

Usage

From source file:org.eclipse.b3.build.engine.B3BuildEngineResource.java

public ListMultimap<String, IFunction> getFunctions() {
    return Multimaps.unmodifiableListMultimap(functionMap);
}

From source file:com.cloudera.flume.master.MemoryBackedConfigStore.java

@Override
public Multimap<String, String> getLogicalNodeMap() {
    return Multimaps.unmodifiableListMultimap(nodeMap);
}

From source file:org.fao.geonet.api.records.formatters.groovy.Handlers.java

/**
 * Executed once when transformer is created.  This locks down the handler configuration so that
 * it is not modifiable any more./*from  w w  w .j av  a 2 s.  c  om*/
 */
public void prepareForTransformer() {
    for (String id : this.handlers.keySet()) {
        Collections.sort(this.handlers.get(id));
    }
    this.handlers = Multimaps.unmodifiableListMultimap(this.handlers);
    for (String id : this.sorters.keySet()) {
        Collections.sort(this.sorters.get(id));
    }
    this.sorters = Multimaps.unmodifiableListMultimap(this.sorters);
    this.modes = Collections.unmodifiableMap(this.modes);
    this.roots = Collections.unmodifiableSet(this.roots);
}

From source file:com.foundationdb.server.types.service.ResolvablesRegistry.java

private static <R extends TOverload, V extends TValidatedOverload> ListMultimap<String, ScalarsGroup<V>> createScalars(
        InstanceFinder finder, TCastResolver castResolver, Class<R> plainClass, Function<R, V> validator) {
    Multimap<String, V> overloadsByName = ArrayListMultimap.create();

    int errors = 0;
    for (R scalar : finder.find(plainClass)) {
        try {/*from w w  w.  java 2 s .c  om*/
            V validated = validator.apply(scalar);

            String[] names = validated.registeredNames();
            for (int i = 0; i < names.length; ++i)
                names[i] = names[i].toLowerCase();

            for (String name : names)
                overloadsByName.put(name, validated);
        } catch (RuntimeException e) {
            rejectTOverload(scalar, e);
            ++errors;
        } catch (AssertionError e) {
            rejectTOverload(scalar, e);
            ++errors;
        }
    }

    if (errors > 0) {
        StringBuilder sb = new StringBuilder("Found ").append(errors).append(" error");
        if (errors != 1)
            sb.append('s');
        sb.append(" while collecting scalar functions. Check logs for details.");
        throw new AkibanInternalException(sb.toString());
    }

    ArrayListMultimap<String, ScalarsGroup<V>> results = ArrayListMultimap.create();
    for (Map.Entry<String, Collection<V>> entry : overloadsByName.asMap().entrySet()) {
        String overloadName = entry.getKey();
        Collection<V> allOverloads = entry.getValue();
        for (Collection<V> priorityGroup : scalarsByPriority(allOverloads)) {
            ScalarsGroup<V> scalarsGroup = new ScalarsGroupImpl<>(priorityGroup, castResolver);
            results.put(overloadName, scalarsGroup);
        }
    }
    results.trimToSize();
    return Multimaps.unmodifiableListMultimap(results);
}

From source file:eu.esdihumboldt.hale.common.align.model.impl.DefaultCell.java

/**
 * @see Cell#getSource()//from www  . j a v a  2s . c  o  m
 */
@Override
public ListMultimap<String, ? extends Entity> getSource() {
    if (source == null) {
        return null;
    }
    return Multimaps.unmodifiableListMultimap(source);
}

From source file:com.google.gdata.util.common.net.UriParameterMap.java

/**
 * Returns an unmodifiable view of the specified parameter map. This method
 * allows modules to provide users with "read-only" access to internal
 * parameter maps. Query operations on the returned map "read through" to the
 * specified map, and attempts to modify the returned map, whether direct or
 * via its iterator or collection views, result in an {@code
 * UnsupportedOperationException}.// w  ww. jav a  2  s  .c  o m
 *
 * @param map the parameter map for which to return an unmodifiable view
 * @return an unmodifiable view of the specified parameter map
 * @throws NullPointerException if {@code map} is null
 */
public static UriParameterMap unmodifiableMap(UriParameterMap map) {
    return new UriParameterMap(Multimaps.unmodifiableListMultimap(map.delegate()));
}

From source file:eu.esdihumboldt.hale.common.scripting.transformation.AbstractScriptedPropertyTransformation.java

@Override
protected final ListMultimap<String, Object> evaluate(String transformationIdentifier, E engine,
        ListMultimap<String, PropertyValue> variables,
        ListMultimap<String, PropertyEntityDefinition> resultNames, Map<String, String> executionParameters,
        TransformationLog log) throws TransformationException {
    ListMultimap<String, ParameterValue> originalParameters = getParameters();
    ListMultimap<String, Value> transformedParameters = ArrayListMultimap.create();

    if (originalParameters != null) {
        for (Map.Entry<String, ParameterValue> entry : originalParameters.entries()) {
            if (!entry.getValue().needsProcessing()) {
                Value value = entry.getValue().intern();
                if (!value.isRepresentedAsDOM()) {
                    value = Value.simple(getExecutionContext().getVariables()
                            .replaceVariables(value.getStringRepresentation()));
                }/*from  w  ww.j  av  a2 s.co  m*/
                transformedParameters.put(entry.getKey(), value);
            } else {
                // type is a script
                ScriptFactory factory = ScriptExtension.getInstance().getFactory(entry.getValue().getType());
                if (factory == null)
                    throw new TransformationException(
                            "Couldn't find factory for script id " + entry.getValue().getType());
                Script script;
                try {
                    script = factory.createExtensionObject();
                } catch (Exception e) {
                    throw new TransformationException("Couldn't create script from factory", e);
                }
                Object result;
                try {
                    String scriptStr = entry.getValue().as(String.class);
                    if (script.requiresReplacedTransformationVariables()) {
                        // replace transformation variables
                        scriptStr = getExecutionContext().getVariables().replaceVariables(scriptStr);
                    }
                    result = script.evaluate(scriptStr, variables.values(), getExecutionContext());
                } catch (ScriptException e) {
                    throw new TransformationException("Couldn't evaluate a transformation parameter", e);
                }
                // XXX use conversion service instead of valueOf?
                transformedParameters.put(entry.getKey(), Value.simple(result));
            }
        }
    }

    this.transformedParameters = Multimaps.unmodifiableListMultimap(transformedParameters);

    return evaluateImpl(transformationIdentifier, engine, variables, resultNames, executionParameters, log);
}

From source file:eu.esdihumboldt.hale.common.align.model.impl.DefaultCell.java

/**
 * @see Cell#getTarget()/*w w w.j  ava 2  s.com*/
 */
@Override
public ListMultimap<String, ? extends Entity> getTarget() {
    if (target == null) {
        return null;
    }
    return Multimaps.unmodifiableListMultimap(target);
}

From source file:eu.esdihumboldt.hale.common.align.model.impl.DefaultCell.java

/**
 * @see Cell#getTransformationParameters()
 *//*from  w  w w.  j av a 2 s.  c  o m*/
@Override
public ListMultimap<String, ParameterValue> getTransformationParameters() {
    if (parameters == null) {
        return null;
    }
    return Multimaps.unmodifiableListMultimap(parameters);
}

From source file:eu.esdihumboldt.hale.common.align.model.BaseAlignmentCell.java

/**
 * @see eu.esdihumboldt.hale.common.align.model.Cell#getDocumentation()
 *///w  w  w .ja  va 2 s  .co  m
@Override
public ListMultimap<String, String> getDocumentation() {
    // TODO allow editing of documentation?
    return Multimaps.unmodifiableListMultimap(base.getDocumentation());
}