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.future.spring.rest.BufferedImageHttpMessageConverter.java

@Override
public List<MediaType> getSupportedMediaTypes() {
    return Collections.singletonList(new MediaType("image", "jpeg"));

}

From source file:org.yamj.api.trakttv.model.SyncItems.java

public SyncItems episode(SyncEpisode episode) {
    this.episodes = Collections.singletonList(episode);
    return this;
}

From source file:com.employee.scheduler.nurserostering.solver.move.EmployeeChangeMove.java

public Collection<? extends Object> getPlanningValues() {
    return Collections.singletonList(toEmployee);
}

From source file:org.bozzo.ipplan.web.json.StreamSerializerTest.java

@Test(expected = UncheckedIOException.class)
public void serialize_io_exception_value_should_work() throws JsonProcessingException, IOException {
    JsonGenerator generator = Mockito.mock(JsonGenerator.class);
    SerializerProvider provider = Mockito.mock(SerializerProvider.class);
    Mockito.doThrow(IOException.class).when(generator).writeObject(Mockito.any());

    StreamSerializer serializer = new StreamSerializer();
    Stream<String> stream = Collections.singletonList("test").parallelStream();
    serializer.serialize(stream, generator, provider);
    Mockito.verify(generator).writeNull();
}

From source file:io.cloudslang.lang.compiler.modeller.transformers.WorkerGroupTransformer.java

@Override
public TransformModellingResult<WorkerGroupStatement> transform(String rawData,
        SensitivityLevel sensitivityLevel) {
    if (StringUtils.isBlank(rawData)) {
        return new BasicTransformModellingResult<>(null, Collections.emptyList());
    }/*from   w  ww .  j a  va 2  s .  co m*/

    WorkerGroupStatement workerGroupStatement;
    Accumulator dependencyAccumulator;
    String expression;
    try {
        dependencyAccumulator = extractFunctionData(rawData);
        expression = ExpressionUtils.extractExpression(rawData);
    } catch (IllegalStateException | IndexOutOfBoundsException e) {
        return new BasicTransformModellingResult<>(null, Collections.singletonList(e));
    }

    if (expression != null) {
        workerGroupStatement = new WorkerGroupStatement(expression,
                dependencyAccumulator.getFunctionDependencies(),
                dependencyAccumulator.getSystemPropertyDependencies());
    } else {
        workerGroupStatement = new WorkerGroupStatement(rawData, null, null);
    }

    return new BasicTransformModellingResult<>(workerGroupStatement, Collections.emptyList());
}

From source file:com.cloudbees.demo.beesshop.domain.ProductRepository.java

public List<String> suggestProductWords(String query) {
    return Collections.singletonList("#TODO#");
}

From source file:org.drugis.addis.security.Account.java

@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
    return Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER"));
}

From source file:be.fedict.eid.dss.client.DSSProxySelector.java

@Override
public List<Proxy> select(URI uri) {
    LOG.debug("select: " + uri);
    String hostname = uri.getHost();
    Proxy proxy = this.proxies.get(hostname);
    if (null != proxy) {
        LOG.debug("using proxy: " + proxy);
        return Collections.singletonList(proxy);
    }/*  ww w  . j a v a2s .  co m*/
    return this.defaultProxySelector.select(uri);
}

From source file:nl.surfnet.coin.selfservice.provisioner.SAMLProvisionerTest.java

@Test
public void test_provision_happy_flow() throws Exception {
    when(csa.getInstitutionIdentityProviders("https://surfguest.nl")).thenReturn(Collections
            .singletonList(new InstitutionIdentityProvider("https://surfguest.nl", "SURFguest", null)));
    final Assertion a = readAssertionFromFile("assertion.xml");

    CoinUser cu = (CoinUser) provisioner.provisionUser(a);

    assertEquals("urn:collab:person:surfguest.nl:gvanderploeg", cu.getUsername());
    assertEquals("https://surfguest.nl", cu.getIdp().getId());
    assertEquals("SURFguest", cu.getIdp().getName());
    assertEquals("surfguest.nl", cu.getSchacHomeOrganization());
    assertEquals("Geert van der Ploeg", cu.getDisplayName());
    assertEquals("gvanderploeg@iprofs.nl", cu.getEmail());
    assertEquals("urn:collab:person:surfguest.nl:gvanderploeg", cu.getUid());
}

From source file:in.mycp.workers.ImageWorker.java

@Async
public void createImage(final Infra infra, final ImageDescriptionP image) {
    String threadName = Thread.currentThread().getName();

    try {/*from w w w.  ja va2 s. c  o  m*/
        logger.debug("threadName " + threadName + " started.");

        Jec2 ec2 = getNewJce2(infra);
        String imageId = "";
        try {
            imageId = ec2.createImage(image.getInstanceIdForImgCreation(), image.getName(),
                    image.getDescription(), false);
        } catch (Exception e) {
            logger.error(e.getMessage());//e.printStackTrace();
        }

        ImageDescription imageFromEuca = ec2.describeImages(Collections.singletonList(imageId)).get(0);

        String imageState = imageFromEuca.getImageState();

        int START_SLEEP_TIME = 10000;
        while (!"available".equals(imageState)) {
            imageFromEuca = ec2.describeImages(Collections.singletonList(imageId)).get(0);
            imageState = imageFromEuca.getImageState();
            logger.info("Image  " + imageFromEuca.getImageId() + " still getting created; sleeping "
                    + START_SLEEP_TIME + "ms");
            Thread.sleep(START_SLEEP_TIME);

        }
        if ("available".equals(imageState)) {

            image.setImageId(imageFromEuca.getImageId());
            image.setImageLocation(imageFromEuca.getImageLocation());
            image.setImageOwnerId(imageFromEuca.getImageOwnerId());
            image.setImageState(imageFromEuca.getImageState());
            image.setIsPublic(imageFromEuca.isPublic());
            List<String> prodCodes = imageFromEuca.getProductCodes();
            String prodCodes_str = "";
            for (Iterator iterator = prodCodes.iterator(); iterator.hasNext();) {
                String prodCode = (String) iterator.next();
                prodCodes_str = prodCodes_str + prodCode + ",";
            }
            prodCodes_str = StringUtils.removeEnd(prodCodes_str, ",");
            image.setProductCodes(prodCodes_str);
            image.setArchitecture(imageFromEuca.getArchitecture());
            image.setImageType(imageFromEuca.getImageType());
            image.setKernelId(imageFromEuca.getKernelId());
            image.setRamdiskId(imageFromEuca.getRamdiskId());
            image.setPlatform(imageFromEuca.getPlatform());
            image.setReason(imageFromEuca.getReason());
            image.setImageOwnerAlias(imageFromEuca.getImageOwnerAlias());

            image.setName(imageFromEuca.getName());
            image.setDescription(imageFromEuca.getDescription());
            image.setRootDeviceType(imageFromEuca.getRootDeviceType());
            image.setRootDeviceName(imageFromEuca.getRootDeviceName());
            image.setVirtualizationType(imageFromEuca.getVirtualizationType());

            image.merge();
        }

    } catch (Exception e) {
        logger.error(e.getMessage());//e.printStackTrace();
    }
}