Example usage for java.util Collections singleton

List of usage examples for java.util Collections singleton

Introduction

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

Prototype

public static <T> Set<T> singleton(T o) 

Source Link

Document

Returns an immutable set containing only the specified object.

Usage

From source file:cd.go.contrib.elasticagents.marathon.executors.MemoryMetadata.java

@Override
protected String doValidate(String input) {
    List<String> errors = new ArrayList<>();
    errors.add(super.doValidate(input));

    try {/*from w w w  .  j av a  2s  .  co m*/
        Size.parse(input);
    } catch (Exception e) {
        errors.add(e.getMessage());
    }

    errors.removeAll(Collections.singleton(null));

    if (errors.isEmpty()) {
        return null;
    }
    return StringUtils.join(errors, ". ");
}

From source file:org.fenixedu.bennu.spring.converters.LocalizedStringConverter.java

@Override
public Set<ConvertiblePair> getConvertibleTypes() {
    return Collections.singleton(new ConvertiblePair(String.class, LocalizedString.class));
}

From source file:org.alejandria.security.auth.RoleGranter.java

@Override
public Set<String> grant(Principal principal) {
    if (adminUsers.contains(principal.getName())) {
        return Collections.singleton("ADMIN");
    } else {/*from w ww  . ja  va  2  s  .  c  o  m*/
        return Collections.singleton("CUSTOMER");
    }
}

From source file:ch.cyberduck.cli.DeletePathFinder.java

@Override
public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote)
        throws AccessDeniedException {
    if (StringUtils.containsAny(remote.getName(), '*')) {
        // Treat asterisk as wildcard
        return Collections.singleton(new TransferItem(remote.getParent()));
    }/*from  w  ww  . ja va2  s .c  o  m*/
    return Collections.singleton(new TransferItem(remote));
}

From source file:com.graphaware.reco.neo4j.filter.ExcludeSelf.java

/**
 * {@inheritDoc}
 */
@Override
public Set<Node> buildBlacklist(Node input) {
    notNull(input);

    return Collections.singleton(input);
}

From source file:cd.go.contrib.elasticagents.dockerswarm.elasticagent.executors.MemoryMetadata.java

@Override
protected String doValidate(String input) {
    List<String> errors = new ArrayList<>(Arrays.asList(super.doValidate(input)));

    try {//from w  w w .ja  va 2s .  c o m
        Size.parse(input);
    } catch (Exception e) {
        errors.add(e.getMessage());
    }

    errors.removeAll(Collections.singleton(null));

    if (errors.isEmpty()) {
        return null;
    }
    return StringUtils.join(errors, ". ");
}

From source file:io.tchepannou.k.party.config.SwaggerConfiguration.java

@Bean
public Docket documentation() {
    return new Docket(DocumentationType.SWAGGER_2).useDefaultResponseMessages(false).select()
            .apis(RequestHandlerSelectors.any()).paths(or(regex("/party/v1/.*?"))).build().pathMapping("/")
            .protocols(Collections.singleton(protocol)).apiInfo(apiInfo())
            .securitySchemes(Arrays.asList(new ApiKey("api_key", "api_key", "header")));
}

From source file:me.ferrybig.javacoding.webmapper.test.session.DefaultDataStorageTest.java

@Test
public void getDataAsSupportsOneBackendSuperCastTypeTest() {
    Object o;/*from   w  ww  .  j  a  v  a  2 s .co  m*/
    data.setData(Collections.singleton(o = BigInteger.ZERO));
    assertEquals(o, extr(data.getDataAs(Object.class)));
}

From source file:ch.cyberduck.cli.DownloadTransferItemFinder.java

@Override
public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) {
    final Local local = LocalFactory.get(input.getOptionValues(action.name())[1]);
    if (StringUtils.containsAny(remote.getName(), '*')) {
        // Treat asterisk as wildcard
        return Collections.singleton(new TransferItem(remote.getParent(), local));
    }/*from   www .j  a  v a 2  s  .c  o m*/
    if (remote.isDirectory()) {
        // Remote path resolves to directory
        if (local.exists()) {
            return Collections.singleton(new TransferItem(remote, LocalFactory.get(local, remote.getName())));
        }
        return Collections.singleton(new TransferItem(remote, local));
    }
    // Remote path resolves to file
    if (local.isDirectory()) {
        // Append remote filename to local target
        return Collections.singleton(new TransferItem(remote, LocalFactory.get(local, remote.getName())));
    }
    // Keep from input
    return Collections.singleton(new TransferItem(remote, local));
}

From source file:com.linkedin.pinot.common.utils.ClientSSLContextGenerator.java

public static Set<String> getProtectedConfigKeys() {
    return Collections.singleton(CONFIG_OF_CLIENT_PKCS12_PASSWORD);
}