Example usage for java.util Collections singletonList

List of usage examples for java.util Collections singletonList

Introduction

In this page you can find the example usage for java.util Collections singletonList.

Prototype

public static <T> List<T> singletonList(T o) 

Source Link

Document

Returns an immutable list containing only the specified object.

Usage

From source file:com.opengamma.financial.convention.ConventionSearchResult.java

/**
 * @param singleResult A single result
 */
public ConventionSearchResult(final ConventionDocument singleResult) {
    _results = Collections.singletonList(singleResult);
}

From source file:Main.java

/** Returns a list of available camera flash modes. If the Android API doesn't support getting flash modes (requires 2.0 or later),
 * returns a list with a single element of "off", corresponding to Camera.Parameters.FLASH_MODE_OFF.
 *///from  ww  w  .jav  a 2 s.  c  o  m
public static List<String> getFlashModes(Camera camera) {
    Camera.Parameters params = camera.getParameters();
    try {
        Method flashModesMethod = params.getClass().getMethod("getSupportedFlashModes");
        List<String> result = (List<String>) flashModesMethod.invoke(params);
        if (result != null)
            return result;
    } catch (Exception ignored) {
    }
    return Collections.singletonList("off");
}

From source file:org.guicerecipes.spring.SpringModule.java

/**
 * Returns a new Injector with support for <a href="http://code.google.com/p/guiceyfruit/wiki/Annotations">Spring annotations and lifecycle support</a> along with JSR 250 support included.
 *///from  www  . j  av  a 2s .  c  o  m
public static Injector createInjector(Module... modules) {
    Iterable<? extends Module> iterable = Iterables.concat(Collections.singletonList(new SpringModule()),
            Arrays.asList(modules));

    return Guice.createInjector(iterable);
}

From source file:Main.java

public static <E> Collection<List<E>> selectExactly(List<E> original, int nb) {
    if (nb < 0) {
        throw new IllegalArgumentException();
    }/* www  . ja  v  a 2s  . c o m*/
    if (nb == 0) {
        return Collections.emptyList();
    }
    if (nb == 1) {
        final List<List<E>> result = new ArrayList<List<E>>();
        for (E element : original) {
            result.add(Collections.singletonList(element));
        }
        return result;

    }
    if (nb > original.size()) {
        return Collections.emptyList();
    }
    if (nb == original.size()) {
        return Collections.singletonList(original);
    }
    final List<List<E>> result = new ArrayList<List<E>>();

    for (List<E> subList : selectExactly(original.subList(1, original.size()), nb - 1)) {
        final List<E> newList = new ArrayList<E>();
        newList.add(original.get(0));
        newList.addAll(subList);
        result.add(Collections.unmodifiableList(newList));
    }
    result.addAll(selectExactly(original.subList(1, original.size()), nb));

    return Collections.unmodifiableList(result);
}

From source file:XMLResourceBundleControl.java

  public List<String> getFormats(String baseName) {
  return Collections.singletonList(XML);
}

From source file:com.hp.autonomy.aci.content.fieldtext.MATCHALL.java

public MATCHALL(final String field, final String[] values) {
    this(Collections.singletonList(field), values);
}

From source file:com.hp.autonomy.aci.content.fieldtext.NOTMATCH.java

public NOTMATCH(final String field, final String[] values) {
    this(Collections.singletonList(field), values);
}

From source file:com.epam.cme.storefront.controllers.util.GlobalMessages.java

protected static void addMessage(final Model model, final String messageHolder, final String messageKey) {
    if (model.containsAttribute(messageHolder)) {
        final Map<String, Object> modelMap = model.asMap();
        final List<String> messageKeys = new ArrayList<String>((List<String>) modelMap.get(messageHolder));
        messageKeys.add(messageKey);//from  ww w .  ja va 2  s .co  m
        model.addAttribute(messageHolder, messageKeys);
    } else {
        model.addAttribute(messageHolder, Collections.singletonList(messageKey));
    }
}

From source file:com.hp.autonomy.aci.content.fieldtext.WILD.java

/**
 * Constructs a new single field WILD fieldtext
 * @param field The field name// w ww.  j a va 2 s .  c  om
 * @param value The first field value
 * @param values Any additional field values
 */
public WILD(final String field, final String value, final String... values) {
    this(Collections.singletonList(field), value, values);
}

From source file:com.hp.autonomy.aci.content.fieldtext.NOTWILD.java

/**
 * Constructs a new single field NOTWILD fieldtext
 * @param field The field name//from   www  . ja  v a 2s. c om
 * @param value The first field value
 * @param values Any additional field values
 */
public NOTWILD(final String field, final String value, final String... values) {
    this(Collections.singletonList(field), value, values);
}