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.exxonmobile.ace.hybris.storefront.controllers.util.GlobalMessages.java

public static void addFlashMessage(final RedirectAttributes model, final String messageHolder,
        final String messageKey, final Object[] attributes) {
    final GlobalMessage message = new GlobalMessage();
    message.setCode(messageKey);/*from   w ww. ja va  2 s  .  c  o m*/
    message.setAttributes(attributes != null ? Arrays.asList(attributes) : Collections.emptyList());

    final Map<String, ?> flashModelMap = model.getFlashAttributes();
    if (flashModelMap.containsKey(messageHolder)) {
        final List<GlobalMessage> messages = new ArrayList<GlobalMessage>(
                (List<GlobalMessage>) flashModelMap.get(messageHolder));
        messages.add(message);
        model.addFlashAttribute(messageHolder, messages);
    } else {
        model.addFlashAttribute(messageHolder, Collections.singletonList(message));
    }
}

From source file:net.dv8tion.discord.commands.HelpCommand.java

@Override
public List<String> getUsageInstructions() {
    return Collections.singletonList(".help   **OR**  .help *<command>*\n"
            + ".help - returns the list of commands along with a simple description of each.\n"
            + ".help <command> - returns the name, description, aliases and usage information of a command.\n"
            + "   - This can use the aliases of a command as input as well.\n" + "__Example:__ .help ann");
}

From source file:ca.uhn.fhir.rest.method.ElementsParameter.java

@SuppressWarnings("unchecked")
@Override/*from  www.  jav a2s  .c  o m*/
public void translateClientArgumentIntoQueryArgument(FhirContext theContext, Object theSourceClientArgument,
        Map<String, List<String>> theTargetQueryArguments, IBaseResource theTargetResource)
        throws InternalErrorException {
    if (theSourceClientArgument instanceof Collection) {
        StringBuilder values = new StringBuilder();
        for (String next : (Collection<String>) theSourceClientArgument) {
            if (isNotBlank(next)) {
                if (values.length() > 0) {
                    values.append(',');
                }
                values.append(next);
            }
        }
        theTargetQueryArguments.put(Constants.PARAM_ELEMENTS, Collections.singletonList(values.toString()));
    } else {
        String elements = (String) theSourceClientArgument;
        if (elements != null) {
            theTargetQueryArguments.put(Constants.PARAM_ELEMENTS, Collections.singletonList(elements));
        }
    }
}

From source file:de.egore911.versioning.deployer.performer.PerformRelacementTest.java

@Test
public void testPerformValid() throws IOException {
    String tmpdir = System.getProperty("java.io.tmpdir");
    File propertiesFile = new File(UrlUtil.concatenateUrlWithSlashes(tmpdir, "myfile.properties"));
    FileUtils.write(propertiesFile, "Test = ${versioning:testvariable}");
    PerformReplacement.perform(new File(tmpdir), Collections.singletonList("*.properties"),
            Collections.singletonList(new ReplacementPair("testvariable", "testvalue")), emptyList);
    Assert.assertEquals("Test = testvalue", FileUtils.readFileToString(propertiesFile));
}

From source file:io.cloudslang.lang.runtime.bindings.ArgumentsBindingTest.java

@Test
public void testDefaultValueExpression() {
    List<Argument> arguments = Collections.singletonList(new Argument("argument1", "${ 'value' }"));
    Map<String, Serializable> result = bindArguments(arguments);
    Assert.assertFalse(result.isEmpty());
    Assert.assertTrue(result.containsKey("argument1"));
    Assert.assertEquals("value", result.get("argument1"));
}

From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.features.SpellCheckingFeature.java

@Override
protected List<Feature> extractFeaturesFromArgument(JCas jCas, Paragraph paragraph, String prefix) {
    List<Token> tokens = JCasUtil.selectCovered(jCas, Token.class, paragraph);

    int oovWords = 0;

    for (Token token : tokens) {
        if (!vocabulary.contains(token.getCoveredText())) {
            oovWords++;//from w  w w  .  j a va2 s. c  o  m
        }
    }

    return Collections.singletonList(new Feature(prefix + "oovWordsCount", oovWords));
}

From source file:ch.rasc.wampspring.config.WampSubProtocolHandler.java

@Override
public List<String> getSupportedProtocols() {
    return Collections.singletonList("wamp");
}

From source file:io.kodokojo.model.Entity.java

public Entity(String name, User admin) {
    this(null, name, false, new ArrayList<>(), Collections.singletonList(admin),
            Collections.singletonList(admin));
}

From source file:gov.nih.nci.caintegrator.application.registration.RegistrationServiceImpl.java

private void sendRegistrationConfirmation(RegistrationRequest registrationRequest) throws MessagingException {
    String emailFrom = configurationHelper.getString(ConfigurationParameter.REGISTRATION_EMAIL_FROM);
    EmailUtil.sendMail(Collections.singletonList(registrationRequest.getEmail()), emailFrom,
            CONFIRM_EMAIL_SUBJECT, CONFIRM_EMAIL_CONTENT);
}

From source file:org.talend.dataprep.api.service.command.folder.RemoveFolder.java

private ResponseEntity<String> getResponseEntity(HttpStatus status, HttpResponse response) {

    final MultiValueMap<String, String> headers = new HttpHeaders();
    for (Header header : response.getAllHeaders()) {
        headers.put(header.getName(), Collections.singletonList(header.getValue()));
    }/*from  w  w  w . j a  v a2  s  . c  om*/
    try {
        return new ResponseEntity<>(IOUtils.toString(response.getEntity().getContent()), headers, status);
    } catch (IOException e) {
        throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e);
    }
}