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:me.ferrybig.javacoding.webmapper.test.session.DefaultDataStorageTest.java

@Test
public void getDataAsSupportsOneBackendDownCastTypeTest() {
    data.setData(Collections.singleton(new Object()));
    assertEquals(null, extr(data.getDataAs(BigInteger.class)));
}

From source file:net.sourceforge.fenixedu.presentationTier.util.CollectionFilter.java

public CollectionFilter(Predicate predicate) {
    this(Collections.singleton(predicate), null);
}

From source file:zipkin.autoconfigure.metrics.PrometheusMetricsAutoConfigurationTest.java

@Test
public void defaultsToGauge() throws Exception {

    PublicMetrics publicMetrics = () -> Collections.singleton(new Metric<Number>("mem.free", 1024));
    ResponseEntity<String> response = responseForMetrics(publicMetrics);

    String body = response.getBody();

    assertThat(body, equalTo("#TYPE mem_free gauge\n" + "#HELP mem_free mem_free\n" + "mem_free 1024.0\n"));
}

From source file:lux.index.field.ElementTextField.java

@Override
public Iterable<IndexableField> getFieldValues(XmlIndexer indexer) {
    XdmNode doc = indexer.getXdmNode();/*w w  w  . java2 s  . c  o m*/
    if (doc != null && doc.getUnderlyingNode() != null) {
        SaxonDocBuilder builder = indexer.getSaxonDocBuilder();
        Analyzer analyzer = getAnalyzer();
        TokenStream textTokens = null;
        try {
            textTokens = analyzer.tokenStream(getName(), new CharSequenceReader(""));
        } catch (IOException e) {
        }

        XmlTokenStreamBase tokens = new ElementTokenStream(getName(), analyzer, textTokens, doc,
                builder.getOffsets(), indexer.getProcessor());
        tokens.configureElementVisibility(indexer);
        return new FieldValues(this, Collections.singleton(new TextField(getName(), tokens)));
    }
    return Collections.emptySet();
}

From source file:org.openmrs.module.kenyaemr.page.controller.EditPatientHtmlFormPageController.java

public String controller(@RequestParam("patientId") Patient patient, @RequestParam("formUuid") String formUuid,
        @RequestParam("returnUrl") String returnUrl, PageModel model) {

    Form form = Context.getFormService().getFormByUuid(formUuid);
    if (form == null) {
        throw new IllegalArgumentException("Cannot find form with uuid = " + formUuid);
    }/*  ww  w.j a  va  2 s .c  o m*/

    StringBuilder sb = new StringBuilder("redirect:" + KenyaEmrConstants.MODULE_ID + "/");

    List<Encounter> encounters = Context.getEncounterService().getEncounters(patient, null, null, null,
            Collections.singleton(form), null, null, null, null, false);
    if (encounters.size() == 0) {
        sb.append("enterHtmlForm.page?formUuid=" + formUuid);
    } else {
        // in case there are more than one, we pick the last one
        Encounter encounter = encounters.get(encounters.size() - 1);
        sb.append("editHtmlForm.page?encounterId=" + encounter.getEncounterId());
    }

    sb.append("&patientId=" + patient.getId());
    sb.append("&returnUrl=" + java.net.URLEncoder.encode(returnUrl));
    return sb.toString();
}

From source file:org.openmrs.module.kenyaemr.page.controller.EditProgramHtmlFormPageController.java

public String controller(@RequestParam("patientId") Patient patient,
        @RequestParam("patientProgramId") PatientProgram enrollment, @RequestParam("formUuid") String formUuid,
        @RequestParam("returnUrl") String returnUrl, PageModel model) {
    Form form = Context.getFormService().getFormByUuid(formUuid);
    if (form == null) {
        throw new IllegalArgumentException("Cannot find form with uuid = " + formUuid);
    }/*from ww  w .  j  a va2 s .  com*/
    List<Encounter> encounters = Context.getEncounterService().getEncounters(patient, null,
            enrollment.getDateEnrolled(), enrollment.getDateCompleted(), Collections.singleton(form), null,
            null, null, null, false);
    if (encounters.size() == 0) {
        throw new RuntimeException("Cannot find the encounter for this registration");
    } else {
        // in case there are more than one, we pick the last one
        Encounter encounter = encounters.get(encounters.size() - 1);
        return "redirect:" + KenyaEmrConstants.MODULE_ID + "/editHtmlForm.page?patientId=" + patient.getId()
                + "&encounterId=" + encounter.getEncounterId() + "&returnUrl="
                + java.net.URLEncoder.encode(returnUrl);
    }
}

From source file:example.caching.RuntimeCacheResolver.java

@Override
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
    return Collections.singleton((String) context.getArgs()[1]);
}

From source file:org.mascherl.example.service.TestDataService.java

License:asdf

@PostConstruct
public void init() {
    loginService.createNewTestUser(new User("Jakob", "Korherr", "jakob.korherr@gmail.com"), "pwd");
    loginService.createNewTestUser(new User("Steffi", "Pollmann", "steffi.pollmann@gmail.com"), "pwd");

    User userJakobKorherr = loginService.login("jakob.korherr@gmail.com", "pwd");
    User userSteffiPollmann = loginService.login("steffi.pollmann@gmail.com", "pwd");

    sendMailService.sendMail(new Mail(new MailAddress("jakob.korherr@gmail.com"),
            Collections.singleton(new MailAddress("steffi.pollmann@gmail.com")),
            Collections.singleton(new MailAddress("some.other.address@asdf.com")), null, "Test subject",
            "This is a test mail!"), userJakobKorherr);
    sendMailService.sendMail(new Mail(new MailAddress("jakob.korherr@gmail.com"),
            Collections.singleton(new MailAddress("steffi.pollmann@gmail.com")), null, null, "Test subject 2",
            "This is another test mail!"), userJakobKorherr);
    sendMailService.sendMail(new Mail(new MailAddress("steffi.pollmann@gmail.com"),
            Collections.singleton(new MailAddress("jakob.korherr@gmail.com")), null, null, "RE: Test subject",
            "This is a test mail!"), userSteffiPollmann);
}

From source file:com.avanza.ymer.TestSpaceMirrorFactory.java

public SpaceDataSource createSpaceDataSource() {
    YmerFactory ymerFactory = new YmerFactory(mongoDbFactory, createMongoConverter(), getDefinitions());
    ymerFactory.setExportExceptionHandlerMBean(exportExceptionHandlerMBean);
    ymerFactory.setPlugins(Collections.singleton(new TestProcessor.TestPlugin()));
    return ymerFactory.createSpaceDataSource();
}

From source file:com.example.auth.ClientDetailsImpl.java

@Override
public Set<String> getAuthorizedGrantTypes() {
    return Collections.singleton("code");
}