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:org.obiba.mica.web.model.LocalizedStringDtos.java

/**
 *
 * @param localizedMap// ww w . j a va2s  .c  om
 * @param locale Preferred locale if exists, otherwise all locales are returned
 * @return
 */
public Iterable<Mica.LocalizedStringDto> asDto(Map<String, String> localizedMap, @Nullable String locale) {
    if (localizedMap == null || localizedMap.isEmpty())
        return Collections.emptyList();
    if (locale != null && localizedMap.containsKey(locale)) {
        return Collections.singleton(Mica.LocalizedStringDto.newBuilder().setLang(locale)
                .setValue(localizedMap.get(locale)).build());
    }
    return localizedMap.entrySet().stream().map(entry -> Mica.LocalizedStringDto.newBuilder()
            .setLang(entry.getKey()).setValue(entry.getValue()).build()).collect(Collectors.toList());
}

From source file:com.developmentsprint.spring.breaker.annotations.AnnotationCircuitBreakerAttributeSource.java

/**
 * Create a custom AnnotationCircuitBreakerAttributeSource.
 * /*from  w w w.  ja v  a2  s  .co m*/
 * @param annotationParser
 *            the CircuitBreakerAnnotationParser to use
 */
public AnnotationCircuitBreakerAttributeSource(CircuitBreakerAnnotationParser annotationParser) {
    this.publicMethodsOnly = true;
    Assert.notNull(annotationParser, "CircuitBreakerAnnotationParser must not be null");
    this.annotationParsers = Collections.singleton(annotationParser);
}

From source file:ai.grakn.graql.internal.analytics.DegreeVertexProgram.java

@Override
public Set<String> getElementComputeKeys() {
    return Collections.singleton(degreePropertyKey);
}

From source file:org.cloudfoundry.identity.uaa.oauth.RemoteTokenServicesTests.java

@Test
public void testTokenRetrievalWithClientAuthorities() throws Exception {
    body.put("client_authorities", Collections.singleton("uaa.none"));
    OAuth2Authentication result = services.loadAuthentication("FOO");
    assertNotNull(result);//from   w w  w .  j ava 2 s  . com
    assertEquals("[uaa.none]", result.getAuthorizationRequest().getAuthorities().toString());
}

From source file:com.xtructure.xutil.coll.UTestListBuilder.java

public void addAndAddAllBehaveAsExpected() {
    ListBuilder<String> lb = new ListBuilder<String>();
    assertThat("", //
            lb.newInstance(), isEmpty());
    ListBuilder<String> got = lb.add("one");
    assertThat("", //
            got, isSameAs(lb));//  w ww  .j  ava 2s.  com
    assertThat("", //
            lb.newInstance(), isEqualTo(Arrays.asList("one")));
    got = lb.add("two", "three");
    assertThat("", //
            got, isSameAs(lb));
    assertThat("", //
            lb.newInstance(), isEqualTo(Arrays.asList("one", "two", "three")));
    got = lb.addAll("one", "two");
    assertThat("", //
            got, isSameAs(lb));
    assertThat("", //
            lb.newInstance(), isEqualTo(Arrays.asList("one", "two", "three", "one", "two")));
    got = lb.addAll(Collections.singleton("three"));
    assertThat("", //
            got, isSameAs(lb));
    assertThat("", //
            lb.newInstance(), isEqualTo(Arrays.asList("one", "two", "three", "one", "two", "three")));
}

From source file:com.rapidminer.operator.preprocessing.RemoveUnusedNominalValuesOperator.java

@Override
protected Collection<AttributeMetaData> modifyAttributeMetaData(ExampleSetMetaData emd, AttributeMetaData amd)
        throws UndefinedParameterError {
    amd.setValueSetRelation(SetRelation.SUBSET);
    return Collections.singleton(amd);
}

From source file:io.seldon.mf.MfFeaturesManager.java

@Autowired
public MfFeaturesManager(ExternalResourceStreamer featuresFileHandler, NewResourceNotifier notifier) {
    super(notifier, Collections.singleton(MF_NEW_LOC_PATTERN));
    this.featuresFileHandler = featuresFileHandler;
}

From source file:org.excalibur.discovery.service.p2p.DiscoveryServiceImpl.java

@Override
public <T> void registerResource(String name, T resource) throws Exception {
    registerResources(name, Collections.singleton(resource));
}

From source file:com.hp.autonomy.frontend.find.idol.beanconfiguration.IdolSecurityCustomizerImpl.java

@Override
public Collection<AuthenticationProvider> getAuthenticationProviders() {
    return Collections.singleton(communityAuthenticationProvider());
}

From source file:org.apache.drill.exec.ref.rse.ClasspathRSE.java

@Override
public Collection<ReadEntry> getReadEntries(Scan scan) throws IOException {
    ClasspathInputConfig c = scan.getSelection().getWith(ClasspathInputConfig.class);
    c.rootPath = scan.getOutputReference();
    return Collections.singleton((ReadEntry) c);
}