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:de.jackwhite20.japs.client.cache.impl.PubSubCacheImpl.java

public PubSubCacheImpl(String host, int port) {

    this(Collections.singletonList(new ClusterServer(host, port)));
}

From source file:org.openlmis.fulfillment.repository.ShipmentRepositoryIntegrationTest.java

@Override
Shipment generateInstance() {
    return new ShipmentDataBuilder().withoutId().withOrder(order)
            .withLineItems(Collections.singletonList(shipmentLineItem)).build();
}

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

@Override
public List<String> getUsageInstructions() {
    return Collections.singletonList(
            ".google *<search terms>*  **OR** .wiki *<search terms>* **OR** .urban *<search terms>*\n");
}

From source file:co.mafiagame.engine.command.MafiaKillsCommand.java

@Override
public ResultMessage execute(MafiaKillsCommandContext context) {
    validateGameNotNull(context);// w ww  .  j a va2 s .  co m
    Game game = context.getGame();
    game.update();
    Player voter = game.playerByUsername(context.getMafiaVoter());
    validate(context);
    vote(voter, Collections.singletonList(context.getUserVoted()), game);
    voter.setVoted(true);
    if (game.checkMafiaElectionIsOver())
        commandExecutor.run(context.getInterfaceContext(), Constants.CMD.Internal.MAFIA_ELECTION_FINISHED,
                new EmptyContext(context.getInterfaceContext(), game));
    List<Message> messages = new ArrayList<>();
    if (Constants.NO_BODY.equals(context.getUserVoted()))
        game.mafias().forEach(m -> messages.add(createResultMessage(context, "user.vote.nobody", m)));
    else
        game.mafias().forEach(m -> messages.add(createResultMessage(context, "user.vote.another", m)));

    return new ResultMessage(messages, context.getInterfaceContext().getSenderType(),
            context.getInterfaceContext());
}

From source file:io.gravitee.definition.jackson.datatype.services.healthcheck.deser.ExpectationDeserializer.java

@Override
public Expectation deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonNode node = jp.getCodec().readTree(jp);

    Expectation expectation = new Expectation();

    final JsonNode assertionsNode = node.get("assertions");
    if (assertionsNode != null) {
        List<String> assertions = new ArrayList<>();
        assertionsNode.elements().forEachRemaining(assertionNode -> assertions.add(assertionNode.asText()));
        expectation.setAssertions(assertions);
    }/*  w  ww. jav  a  2  s  .c o  m*/

    if (expectation.getAssertions().isEmpty()) {
        // Add default assertion
        expectation.setAssertions(Collections.singletonList(Expectation.DEFAULT_ASSERTION));
    }

    return expectation;
}

From source file:ch.cyberduck.core.i18n.BundleLocale.java

@Override
public void setDefault(final String language) {
    final Preferences preferences = PreferencesFactory.get();
    if (null == language) {
        // Revert to system default language
        preferences.deleteProperty("AppleLanguages");
    } else {//from w w w .j  a v a 2  s .  c  om
        preferences.setProperty("AppleLanguages", Collections.singletonList(language));
    }
    cache.clear();
}

From source file:jp.classmethod.aws.infrastructure.BookDynamoDbRepository.java

/**
 * Create instance.//from   w w w .ja  va 2 s.c  o  m
 *
 * @param amazonDynamoDB the dynamodb client
 * @param objectMapper the object mapper to use
 * @since #version#
 */
@Autowired
public BookDynamoDbRepository(ProvisionedThroughput throughput, AmazonDynamoDB amazonDynamoDB,
        ObjectMapper objectMapper) {
    super(null /*prefix*/, TABLE_NAME, amazonDynamoDB, ImmutableMap.of(TABLE_NAME, throughput), objectMapper,
            Book.class, ATTRIBUTE_TYPE_MAP, Collections.singletonList(Book.BOOK_ID), null /*gsi list*/,
            Book.VERSION);
}

From source file:com.linkedin.pinot.core.predicate.NoDictionaryEqualsPredicateEvaluatorsTest.java

@Test
public void testIntPredicateEvaluators() {
    int intValue = _random.nextInt();
    EqPredicate eqPredicate = new EqPredicate(COLUMN_NAME,
            Collections.singletonList(Integer.toString(intValue)));
    PredicateEvaluator eqPredicateEvaluator = EqualsPredicateEvaluatorFactory
            .newNoDictionaryBasedEvaluator(eqPredicate, FieldSpec.DataType.INT);

    NEqPredicate neqPredicate = new NEqPredicate(COLUMN_NAME,
            Collections.singletonList(Integer.toString(intValue)));
    PredicateEvaluator neqPredicateEvaluator = NotEqualsPredicateEvaluatorFactory
            .newNoDictionaryBasedEvaluator(neqPredicate, FieldSpec.DataType.INT);

    Assert.assertTrue(eqPredicateEvaluator.apply(intValue));
    Assert.assertFalse(neqPredicateEvaluator.apply(intValue));

    int[] randomInts = new int[NUM_MULTI_VALUES];
    PredicateEvaluatorTestUtils.fillRandom(randomInts);
    randomInts[_random.nextInt(randomInts.length)] = intValue;

    Assert.assertTrue(eqPredicateEvaluator.apply(randomInts));
    Assert.assertFalse(neqPredicateEvaluator.apply(randomInts));

    for (int i = 0; i < 100; i++) {
        int random = _random.nextInt();
        Assert.assertEquals(eqPredicateEvaluator.apply(random), (random == intValue));
        Assert.assertEquals(neqPredicateEvaluator.apply(random), (random != intValue));

        PredicateEvaluatorTestUtils.fillRandom(randomInts);
        Assert.assertEquals(eqPredicateEvaluator.apply(randomInts), ArrayUtils.contains(randomInts, intValue));
        Assert.assertEquals(neqPredicateEvaluator.apply(randomInts),
                !ArrayUtils.contains(randomInts, intValue));
    }//from w w  w.j  av  a  2s  . co m
}

From source file:hudson.cli.GetJobCommandTest.java

@Issue("JENKINS-20236")
@Test/*from ww  w.  ja va2s .  c o  m*/
public void withFolders() throws Exception {
    MockFolder d = j.createFolder("d");
    FreeStyleProject p = d.createProject(FreeStyleProject.class, "p");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    PrintStream outS = new PrintStream(out);
    int result = new GetJobCommand().main(Collections.singletonList("d/p"), Locale.ENGLISH,
            new NullInputStream(0), outS, outS);
    outS.flush();
    String output = out.toString();
    assertEquals(output, 0, result);
    assertEquals(p.getConfigFile().asString(), output);
    out = new ByteArrayOutputStream();
    outS = new PrintStream(out);
    result = new GetJobCommand().main(Collections.singletonList("d"), Locale.ENGLISH, new NullInputStream(0),
            outS, outS);
    outS.flush();
    output = out.toString();
    assertEquals(output, 0, result);
    assertEquals(d.getConfigFile().asString(), output);
}

From source file:de.hybris.telcotrail.storefront.controllers.pages.AbstractLoginPageController.java

protected String getDefaultLoginPage(final boolean loginError, final HttpSession session, final Model model)
        throws CMSItemNotFoundException {
    final LoginForm loginForm = new LoginForm();
    model.addAttribute(loginForm);//from   w ww  .jav a2  s.com
    model.addAttribute(new RegisterForm());

    final String username = getUsernameTryingToLogin(session);
    if (username != null) {
        session.removeAttribute(SPRING_SECURITY_LAST_USERNAME);
    }

    loginForm.setJ_username(username);
    storeCmsPageInModel(model, getCmsPage());
    setUpMetaDataForContentPage(model, (ContentPageModel) getCmsPage());
    model.addAttribute("metaRobots", "index,no-follow");

    final Breadcrumb loginBreadcrumbEntry = new Breadcrumb("#",
            getMessageSource().getMessage("header.link.login", null, getI18nService().getCurrentLocale()),
            null);
    model.addAttribute("breadcrumbs", Collections.singletonList(loginBreadcrumbEntry));

    if (loginError) {
        GlobalMessages.addErrorMessage(model, "login.error.account.not.found.title");
    }
    return getView();
}