Example usage for org.apache.commons.collections4.map SingletonMap SingletonMap

List of usage examples for org.apache.commons.collections4.map SingletonMap SingletonMap

Introduction

In this page you can find the example usage for org.apache.commons.collections4.map SingletonMap SingletonMap.

Prototype

public SingletonMap(final K key, final V value) 

Source Link

Document

Constructor specifying the key and value.

Usage

From source file:de.tudarmstadt.ukp.dkpro.core.io.solr.util.SolrUtils.java

/**
 * Add a field and optionally perform a partial update if applicable on an existing document.
 *
 * @param document  the {@link SolrInputDocument} to add/update
 * @param fieldname the field name to add/update
 * @param value     the value to insert for the field.
 * @param update    if true, use Solr atomic update mechanism; otherwise overwrite document
 * @param modifier  The {@link Modifier} to use when performing an atomic update (i.e. iff {@code update}
 *                  is set to true).//w  w w .  jav  a 2  s .c om
 * @see #setField(SolrInputDocument, String, Object, boolean)
 */
public static void setField(SolrInputDocument document, String fieldname, Object value, boolean update,
        Modifier modifier) {
    if (update) {
        /* perform an atomic update on potentially existing document */
        document.setField(fieldname, new SingletonMap<>(modifier.name().toLowerCase(), value));
    } else {
        document.setField(fieldname, value);
    }
}