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:eu.esdihumboldt.hale.ui.function.generic.AbstractGenericFunctionWizard.java

/**
 * Create parameter pages./*from   w  ww. j a va  2 s.c o  m*/
 * 
 * @param initialValues the initial parameter values, may be
 *            <code>null</code>
 * @return the list of parameter pages
 */
protected List<ParameterPage> createParameterPages(
        @Nullable ListMultimap<String, ParameterValue> initialValues) {
    LinkedList<ParameterPage> parameterPages = new LinkedList<ParameterPage>();

    // create copy of function parameter set
    Set<FunctionParameterDefinition> functionParameters = new LinkedHashSet<>();
    for (FunctionParameterDefinition param : getFunction().getDefinedParameters())
        functionParameters.add(param);

    if (initialValues != null)
        initialValues = Multimaps.unmodifiableListMultimap(initialValues);
    // get available parameter pages
    List<ParameterPageFactory> paramPageFactories = ParameterPageExtension.getInstance()
            .getFactories(new FactoryFilter<ParameterPage, ParameterPageFactory>() {

                @Override
                public boolean acceptFactory(ParameterPageFactory factory) {
                    return factory.getFunctionId().equals(getFunctionId());
                }

                @Override
                public boolean acceptCollection(
                        ExtensionObjectFactoryCollection<ParameterPage, ParameterPageFactory> collection) {
                    return true;
                }
            });
    // use available parameter pages (first come first serve)
    for (ParameterPageFactory paramPageFactory : paramPageFactories) {
        Set<FunctionParameterDefinition> pageFunctionParameters = new HashSet<>();
        for (FunctionParameterDefinition fp : paramPageFactory.getAssociatedParameters())
            if (functionParameters.contains(fp))
                pageFunctionParameters.add(fp);
        if (!pageFunctionParameters.isEmpty()) {
            ParameterPage paramPage;
            try {
                paramPage = paramPageFactory.createExtensionObject();
            } catch (Exception e) {
                log.error("Could not creating parameter page " + paramPageFactory.getIdentifier(), e);
                continue;
            }
            functionParameters.removeAll(pageFunctionParameters);
            parameterPages.add(paramPage);
            paramPage.setParameter(pageFunctionParameters, initialValues);
        }
    }
    // use generic parameter page for remaining parameters
    if (!functionParameters.isEmpty()) {
        ParameterPage generic = new GenericParameterPage();
        generic.setParameter(functionParameters, initialValues);
        parameterPages.add(generic);
    }

    return parameterPages;
}

From source file:com.tinspx.util.net.Response.java

/**
 * Creates a new {@code Response}./*from  ww w.ja v  a2s. c  o m*/
 * 
 * @param request the Request that initiated this response
 * @param uri  the URI of this Response
 * @param queryParams the query parameters of {@code uri} if already
 * computed; if null, the params will be extracted from uri.
 * @param code the response code, if available
 * @param message the response message, if available. null will be
 * converted to the empty String.
 * @param redirects the list of redirects that have led up to this Response.
 * if null, {@link #redirects()} will return an empty List. A defensive copy
 * of this List is created, so the caller may continue to use and edit this
 * List after the constructor is called.
 */
Response(Request request, URI uri, @Nullable ListMultimap<String, String> queryParams, int code,
        @Nullable String message, @Nullable Iterable<Response> redirects) {
    this.request = checkNotNull(request);
    this.uri = checkNotNull(uri);
    if (queryParams != null) {
        this.queryParams = ImmutableListMultimap.copyOf(queryParams);
    } else {
        this.queryParams = Multimaps.unmodifiableListMultimap(UriUtil.parseQuery(uri));
    }
    this.code = code;
    this.message = Strings.nullToEmpty(message);
    this.redirects = redirects != null ? ImmutableList.copyOf(redirects) : ImmutableList.<Response>of();
    checkArgument(CollectUtils.allNonNull(this.redirects));
}

From source file:org.eclipse.xtext.xbase.typesystem.override.RawResolvedFeatures.java

protected ListMultimap<String, JvmFeature> computeAllFeatures() {
    JvmType rawType = getRawType();//from  w  w w  .j a va2  s.com
    if (!(rawType instanceof JvmDeclaredType)) {
        return ArrayListMultimap.create();
    }
    ListMultimap<String, JvmFeature> result = ArrayListMultimap.create();
    Multimap<String, AbstractResolvedOperation> processed = HashMultimap.create();
    Set<String> processedFields = Sets.newHashSetWithExpectedSize(5);
    computeAllFeatures((JvmDeclaredType) rawType, processed, processedFields, result, featureIndex.keySet());
    return Multimaps.unmodifiableListMultimap(result);
}

From source file:eu.esdihumboldt.cst.ConceptualSchemaTransformer.java

/**
 * Execute a type transformation based on single type cell
 * //from  w  w  w.  j  a v  a 2  s.c  o m
 * @param transformation the transformation to use
 * @param typeCell the type cell
 * @param target the target instance sink
 * @param source the source instances
 * @param alignment the alignment
 * @param engines the engine manager
 * @param transformer the property transformer
 * @param context the transformation execution context
 * @param reporter the reporter
 * @param progressIndicator the progress indicator
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void doTypeTransformation(TypeTransformationFactory transformation, Cell typeCell,
        InstanceCollection source, InstanceSink target, Alignment alignment, EngineManager engines,
        PropertyTransformer transformer, TransformationContext context, TransformationReporter reporter,
        ProgressIndicator progressIndicator) {
    TransformationLog cellLog = new CellLog(reporter, typeCell);

    TypeTransformation<?> function;
    try {
        function = transformation.createExtensionObject();
    } catch (Exception e) {
        reporter.error(new TransformationMessageImpl(typeCell, "Error creating transformation function.", e));
        return;
    }

    TransformationEngine engine = engines.get(transformation.getEngineId(), cellLog);

    if (engine == null) {
        // TODO instead try another transformation
        cellLog.error(cellLog
                .createMessage("Skipping type transformation: No matching transformation engine found", null));
        return;
    }

    // prepare transformation configuration
    ListMultimap<String, Type> targetTypes = ArrayListMultimap.create();
    for (Entry<String, ? extends Entity> entry : typeCell.getTarget().entries()) {
        targetTypes.put(entry.getKey(), (Type) entry.getValue());
    }
    ListMultimap<String, ParameterValue> parameters = typeCell.getTransformationParameters();
    if (parameters != null) {
        parameters = Multimaps.unmodifiableListMultimap(parameters);
    }
    Map<String, String> executionParameters = transformation.getExecutionParameters();

    // break on cancel
    if (progressIndicator.isCanceled()) {
        return;
    }

    ResourceIterator<FamilyInstance> iterator;
    if (typeCell.getSource() == null || typeCell.getSource().isEmpty()) {
        // type cell w/o source
        // -> execute exactly once w/ null source
        source = null;
        iterator = new GenericResourceIteratorAdapter<Object, FamilyInstance>(
                Collections.singleton(null).iterator()) {

            @Override
            protected FamilyInstance convert(Object next) {
                return null;
            }
        };
    } else {
        // Step 1: selection
        // Select only instances that are relevant for the transformation.
        source = source.select(new TypeCellFilter(typeCell));

        // Step 2: partition
        // use InstanceHandler if available - for example merge or join
        function.setExecutionContext(context.getCellContext(typeCell));
        InstanceHandler instanceHandler = function.getInstanceHandler();
        if (instanceHandler != null) {
            injectTransformationContext(instanceHandler, context);
            progressIndicator.setCurrentTask("Perform instance partitioning");
            try {
                iterator = instanceHandler.partitionInstances(source, transformation.getFunctionId(), engine,
                        parameters, executionParameters, cellLog);
            } catch (TransformationException e) {
                cellLog.error(cellLog.createMessage("Type transformation: partitioning failed", e));
                return;
            }
        } else {
            // else just use every instance as is
            iterator = new GenericResourceIteratorAdapter<Instance, FamilyInstance>(source.iterator()) {

                @Override
                protected FamilyInstance convert(Instance next) {
                    return new FamilyInstanceImpl(next);
                }
            };
        }
    }

    progressIndicator.setCurrentTask("Execute type transformations");

    try {
        while (iterator.hasNext()) {
            // break on cancel
            if (progressIndicator.isCanceled()) {
                return;
            }

            function.setSource(iterator.next());
            function.setPropertyTransformer(transformer);
            function.setParameters(parameters);
            function.setTarget(targetTypes);
            function.setExecutionContext(context.getCellContext(typeCell));

            try {
                ((TypeTransformation) function).execute(transformation.getFunctionId(), engine,
                        executionParameters, cellLog, typeCell);
            } catch (TransformationException e) {
                cellLog.error(cellLog.createMessage("Type transformation failed, skipping instance.", e));
            }
        }
    } finally {
        iterator.close();
    }
}

From source file:com.google.gitiles.GitilesView.java

private GitilesView(Type type, String hostName, String servletPath, String repositoryName, Revision revision,
        Revision oldRevision, String path, ListMultimap<String, String> params, String anchor) {
    this.type = type;
    this.hostName = hostName;
    this.servletPath = servletPath;
    this.repositoryName = repositoryName;
    this.revision = Objects.firstNonNull(revision, Revision.NULL);
    this.oldRevision = Objects.firstNonNull(oldRevision, Revision.NULL);
    this.path = path;
    this.params = Multimaps.unmodifiableListMultimap(params);
    this.anchor = anchor;
}

From source file:fr.ens.biologie.genomique.eoulsan.util.ServiceNameLoader.java

/**
 * Return the list of the available services.
 * @return a MultiMap with the available services
 *//* w  w  w .  j  a v  a 2s . c  o  m*/
public ListMultimap<String, String> getServiceClasses() {

    if (this.notYetLoaded) {
        reload();
    }

    return Multimaps.unmodifiableListMultimap(this.classNames);
}

From source file:com.rhythm.louie.server.ServiceManager.java

public static ListMultimap<String, Exception> getErrors() {
    return Multimaps.unmodifiableListMultimap(errors);
}

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

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