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.netdimensions.client.Commands.java

public static Command<List<EnrollmentRequest>> getEnrollmentRequests(final boolean inbox, final Date since,
        final String filter, final String onBehalfOf) {
    return new Command<List<EnrollmentRequest>>("enrollment-requests", false,
            com.netdimensions.util.Collections.concatenatedList(
                    inbox ? Collections.singletonList(new BasicNameValuePair("inbox", Boolean.toString(true)))
                            : Collections.<NameValuePair>emptyList(),
                    Arrays.asList(new BasicNameValuePair("since", Dates.html5String(since)),
                            new BasicNameValuePair("filter", nullToEmpty(filter)),
                            new BasicNameValuePair("on-behalf-of", nullToEmpty(onBehalfOf)),
                            new BasicNameValuePair("format", "xml"))),
            EnrollmentRequest.PARSER);//from   ww  w.j  a v a2s . c  o  m
}

From source file:io.mapzone.controller.api.ApiContentProvider.java

@Override
public List<? extends IContentNode> getChildren(IPath path) {
    // ProjectsFolder
    if (path.segmentCount() == 0) {
        return Collections.singletonList(new ProjectsFolder(path));
    }//  ww w . j  a  v  a2 s  .  co  m
    IContentFolder parent = getSite().getFolder(path);

    // OrganizationFolder
    if (parent.getClass().equals(ProjectsFolder.class)) {
        SecurityContext sc = SecurityContext.instance();
        UserPrincipal sessionUser = (UserPrincipal) sc.getUser();

        ProjectUnitOfWork uow = ProjectRepository.session();
        Organization org = uow.findOrganization(sessionUser.getName()).get();
        return Collections.singletonList(new OrganizationFolder(org, path));
    }

    // ProjectFolder
    else if (parent.getClass().equals(OrganizationFolder.class)) {
        return ((OrganizationFolder) parent).getSource().projects.stream()
                .map(project -> new ProjectFolder(project, path)).collect(Collectors.toList());
    }
    return null;
}

From source file:org.openmrs.module.kenyaemr.reporting.library.shared.hiv.PwpCohortLibrary.java

/**
 * Patients who were provided condoms between ${onOrAfter} and ${onOrBefore}
 * @return the cohort definition/*  w  ww . ja  v a2 s.c  o m*/
 */
public CohortDefinition condomsProvided() {
    Concept condomsProvided = Dictionary.getConcept(Dictionary.CONDOMS_PROVIDED_DURING_VISIT);
    Concept yes = Dictionary.getConcept(Dictionary.YES);

    CodedObsCohortDefinition cd = new CodedObsCohortDefinition();
    cd.setName("condoms provided");
    cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class));
    cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class));
    cd.setTimeModifier(PatientSetService.TimeModifier.ANY);
    cd.setQuestion(condomsProvided);
    cd.setValueList(Collections.singletonList(yes));
    cd.setOperator(SetComparator.IN);
    return cd;
}

From source file:io.undertow.server.security.DigestAuthenticationAuthTestCase.java

static AuthenticationMechanism getTestMechanism() {
    return new DigestAuthenticationMechanism(Collections.singletonList(DigestAlgorithm.MD5),
            Collections.singletonList(DigestQop.AUTH), REALM_NAME, "/", new SimpleNonceManager());
}

From source file:HCNIOEngine.java

@Override
public ResponseEntity<String> submit(JCurlRequestOptions requestOptions) throws Exception {
    ResponseEntity<String> stringResponseEntity = null;
    try (CloseableHttpAsyncClient hc = createCloseableHttpAsyncClient()) {
        for (int i = 0; i < requestOptions.getCount(); i++) {
            final HttpHeaders headers = new HttpHeaders();
            for (Map.Entry<String, String> e : requestOptions.getHeaderMap().entrySet()) {
                headers.put(e.getKey(), Collections.singletonList(e.getValue()));
            }/*from  w w w.  jav a  2s  .c  o  m*/

            final HttpEntity<Void> requestEntity = new HttpEntity<>(headers);

            AsyncRestTemplate template = new AsyncRestTemplate(
                    new HttpComponentsAsyncClientHttpRequestFactory(hc));
            final ListenableFuture<ResponseEntity<String>> exchange = template.exchange(requestOptions.getUrl(),
                    HttpMethod.GET, requestEntity, String.class);
            stringResponseEntity = exchange.get();
            System.out.println(stringResponseEntity.getBody());

        }
        return stringResponseEntity;
    }
}

From source file:fi.helsinki.opintoni.config.LeikiConfiguration.java

@Bean
public RestTemplate leikiRestTemplate() {
    final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
    converter.setObjectMapper(objectMapper);
    RestTemplate restTemplate = new RestTemplate(Collections.singletonList(converter));
    restTemplate.setInterceptors(Lists.newArrayList(new LoggingInterceptor()));
    return restTemplate;
}

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

@Test
public void testDefaultValue() {
    List<Input> inputs = Collections.singletonList(new Input.InputBuilder("input1", "value").build());
    Map<String, Serializable> result = bindInputs(inputs);
    Assert.assertFalse(result.isEmpty());
    Assert.assertTrue(result.containsKey("input1"));
    Assert.assertEquals("value", result.get("input1"));
}

From source file:org.openmrs.module.kenyaemr.reporting.library.cohort.PwpCohortLibrary.java

/**
 * Patients who were provided condoms between ${onOrAfter} and ${onOrBefore}
 * @return the cohort definition//www.ja  va  2 s  .  c  o  m
 */
public CohortDefinition condomsProvided() {
    Concept condomsProvided = Dictionary.getConcept(Dictionary.CONDOMS_PROVIDED_DURING_VISIT);
    Concept yes = Dictionary.getConcept(Dictionary.YES);

    CodedObsCohortDefinition cd = new CodedObsCohortDefinition();
    cd.setName("condoms provided between dates");
    cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class));
    cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class));
    cd.setTimeModifier(PatientSetService.TimeModifier.ANY);
    cd.setQuestion(condomsProvided);
    cd.setValueList(Collections.singletonList(yes));
    cd.setOperator(SetComparator.IN);
    return cd;
}

From source file:net.sourceforge.fenixedu.domain.candidacy.workflow.form.ResidenceApplianceInquiryForm.java

@Override
public List<LabelFormatter> validate() {
    if (!StringUtils.isEmpty(this.notesAboutApplianceForResidence) && !isToApplyForResidence) {
        return Collections.singletonList(new LabelFormatter().appendLabel(
                "error.candidacy.workflow.ResidenceApplianceInquiryForm.notes.can.only.be.filled.in.case.of.appliance",
                "application"));
    }//from  w w  w  .  j a  v a  2s.c  o  m

    return Collections.emptyList();
}

From source file:org.lable.rfc3881.auditlogger.serialization.RFC3881ModuleTest.java

@Test
public void moduleTest() throws JsonProcessingException {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new RFC3881Module());
    objectMapper.registerModule(new JodaModule());
    objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

    LogEntry logEntry = new LogEntry(
            new Event(new CodeReference("events", "logon", "log-on"), EventAction.EXECUTE,
                    EventOutcome.SUCCESS),
            new Principal("bob", null, "Bob Jones", new CodeReference("roles", "user", "authenticated user")),
            null, null, NetworkAccessPoint.byIPAddress("127.0.0.1"),
            Collections.singletonList(
                    new AuditSource("servercluster1", "tomcat1", AuditSourceType.WEB_SERVER_PROCESS)),
            Collections.singletonList(new ParticipantObject("bob", ParticipantObjectType.PERSON,
                    ParticipantObjectIDType.USER_IDENTIFIER, ParticipantObjectTypeRole.USER,
                    DataLifeCycle.ACCESS_OR_USE, new CodeReference("sensitivity", "TOPSECRET", "Quite secret"),
                    "Bob Jones", "TEST".getBytes(),
                    new ParticipantObject.Detail(new CodeReference("detail", "DT1", "Detail 1"), new byte[0]))),
            new CodeReference("version", "1", "1"));

    System.out.println(objectMapper.writeValueAsString(logEntry));
}