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:alfio.model.TicketFieldConfigurationDescriptionAndValue.java

public List<TicketFieldValue> getFields() {
    if (count == 1) {
        return Collections.singletonList(new TicketFieldValue(0, 1, value));
    }//from   w w  w. j  a va  2s. c  o m
    List<String> values = StringUtils.isBlank(value) ? Collections.emptyList()
            : Json.fromJson(value, new TypeReference<List<String>>() {
            });
    return IntStream.range(0, count)
            .mapToObj(i -> new TicketFieldValue(i, i + 1, i < values.size() ? values.get(i) : ""))
            .collect(Collectors.toList());

}

From source file:com.acmemotors.gf.Main.java

@Bean
PoolFactoryBean poolFactoryBean(@Value("${gf.server.port}") int serverPort,
        @Value("${gf.server.host}") String host) throws Exception {
    PoolFactoryBean factoryBean = new PoolFactoryBean();
    factoryBean.setName("my-pool");
    factoryBean.setServers(Collections.singletonList(new InetSocketAddress(host, serverPort)));
    factoryBean.afterPropertiesSet();//from ww w.j a v a  2s.  c  om
    return factoryBean;
}

From source file:com.epam.reportportal.extension.bugtracking.jira.TicketDescriptionServiceTest.java

@Test
public void testNull() {
    PostTicketRQ postTicketRQ = new PostTicketRQ();
    postTicketRQ.setNumberOfLogs(0);//from ww  w.  j a  va  2  s  . com
    postTicketRQ.setIsIncludeScreenshots(false);
    HashMap<String, String> backLinks = new HashMap<>();
    backLinks.put("1234", "https://localhost:8443/reportportal-ws/");
    postTicketRQ.setBackLinks(backLinks);
    String result = descriptionService.getDescription(null, postTicketRQ);
    Assert.assertNotNull(result);
    Assert.assertEquals("", result);
    postTicketRQ.setIsIncludeLogs(false);
    String description = descriptionService.getDescription(Collections.singletonList("1234"), postTicketRQ);
    Assert.assertNotNull(description);
    //      Assert.assertEquals("h3.*Back link to Report Portal:*\n - [Link to defect|https://localhost:8443/reportportal-ws/]\r\n\n", description);
}

From source file:com.stratio.morphlines.commons.HeadersToBodyBuilder.java

public Collection<String> getNames() {
    return Collections.singletonList(COMMAND_NAME);
}

From source file:com.photon.phresco.service.admin.actions.components.ConfigTemplates.java

public String save() {
    S_LOGGER.debug("Entering Method ConfigTemplates.save()");
    try {/*w w  w  . j a  v  a  2 s.com*/
        if (validateForm()) {
            setErrorFound(true);
            return SUCCESS;
        }
        addActionMessage(getText(CONFIGTEMPLATE_ADDED, Collections.singletonList(name)));

    } catch (Exception e) {
        addActionError(getText(CONFIGTEMPLATE_NOT_ADDED, Collections.singletonList(name)));
    }
    return COMP_CONFIGTEMPLATE_LIST;

}

From source file:com.temenos.interaction.loader.detector.DirectoryChangeActionNotifierTest.java

@Test
public void test() throws IOException, InterruptedException {
    Assert.assertNotNull(action);//from   w  ww .  ja  va  2s .  c  om
    Assert.assertNotNull(notifier);
    Assert.assertTrue(!notifier.getListeners().isEmpty());

    File tempDir = createTempDirectory();
    notifier.setResources(Collections.singletonList(tempDir));

    Thread.currentThread().sleep(3000);

    File tempFile = new File(tempDir, "test.file");
    tempFile.createNewFile();
    Thread.currentThread().sleep(3000);
    Assert.assertTrue(action.getCallCount() > 0);
    System.out.println(action.getLastEvent().getResource());
    FileUtils.forceDelete(tempDir);
}

From source file:ch.cyberduck.core.onedrive.OneDriveMoveFeature.java

@Override
public Path move(final Path file, final Path renamed, final TransferStatus status,
        final Delete.Callback callback, final ConnectionCallback connectionCallback)
        throws BackgroundException {
    if (status.isExists()) {
        delete.delete(Collections.singletonList(renamed), connectionCallback, callback);
    }/*from w  ww  .j  a v  a 2  s.  c  om*/
    final OneDrivePatchOperation patchOperation = new OneDrivePatchOperation();
    if (!StringUtils.equals(file.getName(), renamed.getName())) {
        patchOperation.rename(renamed.getName());
    }
    if (!file.getParent().equals(renamed.getParent())) {
        patchOperation.move(session.toFolder(renamed.getParent()));
    }
    try {
        session.toFile(file).patch(patchOperation);
    } catch (OneDriveAPIException e) {
        throw new OneDriveExceptionMappingService().map("Cannot rename {0}", e, file);
    } catch (IOException e) {
        throw new DefaultIOExceptionMappingService().map("Cannot rename {0}", e, file);
    }
    return renamed;
}

From source file:org.lightadmin.core.config.bootstrap.JpaMetamodelMappingContextFactoryBean.java

@Override
protected JpaMetamodelMappingContext createInstance() throws Exception {
    Metamodel metamodel = entityManager.getMetamodel();

    Set<ManagedType<?>> managedTypes = metamodel.getManagedTypes();
    Set<Class<?>> entitySources = new HashSet<Class<?>>(managedTypes.size());

    for (ManagedType<?> type : managedTypes) {

        Class<?> javaType = type.getJavaType();

        if (javaType != null) {
            entitySources.add(javaType);
        }//www  .j av  a 2s .  co  m
    }

    Set<Metamodel> metaModelSet = new HashSet<>(Collections.singletonList(metamodel));
    JpaMetamodelMappingContext context = new JpaMetamodelMappingContext(metaModelSet);
    context.setInitialEntitySet(entitySources);
    context.initialize();

    return context;
}

From source file:com.orange.ngsi2.server.FakeNgsi2ControllerHelper.java

@Override
protected Paginated<Entity> listEntities(Set<String> id, Set<String> type, String idPattern, int limit,
        int offset, List<String> attrs, String query, GeoQuery geoquery, List<String> orderBy)
        throws Exception {
    if ((id != null) && id.contains("Bcn-Welt")) {
        return new Paginated<>(Collections.singletonList(createEntityBcnWelt()), 1, 1, 1);
    }//from   ww w .j a v a 2  s  . c  o  m
    return new Paginated<>(createListEntitiesConflictingReference(), 2, 2, 2);
}

From source file:br.com.thiaguten.persistence.demo.hbmcore.UserDAOImpl.java

@Override
public List<User> findByName(String name) {
    List<Criterion> criterions = Collections
            .singletonList(Restrictions.ilike("name", name, MatchMode.ANYWHERE));
    List<User> results = persistenceProvider.findByCriteria(getPersistenceClass(), criterions);
    if (results.isEmpty()) {
        return Collections.emptyList();
    } else {/*w  w w . j  av a  2 s  .c  om*/
        return Collections.unmodifiableList(results);
    }
}