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:com.avanza.ymer.TestSpaceMirrorFactory.java

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

From source file:ch.cyberduck.core.manta.AbstractMantaTest.java

@Before
public void setup() throws Exception {
    final Profile profile = new ProfilePlistReader(
            new ProtocolFactory(Collections.singleton(new MantaProtocol())))
                    .read(new Local("../profiles/Joyent Triton Object Storage.cyberduckprofile"));

    final String hostname;
    final Local file;
    if (ObjectUtils.allNotNull(System.getProperty("manta.key_path"), System.getProperty("manta.url"))) {
        file = new Local(System.getProperty("manta.key_path"));
        hostname = new URL(System.getProperty("manta.url")).getHost();
    } else {// w w  w . j  ava2s.  com
        final String key = System.getProperty("manta.key");
        file = TemporaryFileServiceFactory.get().create(new AlphanumericRandomStringService().random());
        LocalTouchFactory.get().touch(file);
        IOUtils.write(key, file.getOutputStream(false), Charset.defaultCharset());
        hostname = profile.getDefaultHostname();
    }

    final String user = System.getProperty("manta.user");
    final Host host = new Host(profile, hostname, new Credentials(user).withIdentity(file));
    session = new MantaSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final String testRoot = "cyberduck-test-" + new AlphanumericRandomStringService().random();
    testPathPrefix = new Path(
            new MantaAccountHomeInfo(host.getCredentials().getUsername(), host.getDefaultPath())
                    .getAccountPrivateRoot(),
            testRoot, EnumSet.of(Type.directory));
    session.getClient().putDirectory(testPathPrefix.getAbsolute());
}

From source file:com.nesscomputing.cache.NamespacedCache.java

/**
 * Tries to add a cache entry if it does not already exist.
 *
 *  This is an optional operation.//from   w  ww . j  ava  2s .  co  m
 */
public boolean add(String key, byte[] value, DateTime expiry) {
    return BooleanUtils.toBoolean(cache
            .add(namespace, Collections.singleton(CacheStores.fromSharedBytes(key, value, expiry))).get(key));
}

From source file:sample.data.mock.MockConversionService.java

public Set<ConvertiblePair> getConvertibleTypes() {
    return Collections.singleton(new ConvertiblePair(Object.class, Object.class));
}

From source file:sample.session.SmartHttpSessionStrategy.java

@Autowired
public SmartHttpSessionStrategy(ContentNegotiationStrategy contentNegotiationStrategy) {
    this(new CookieHttpSessionStrategy(), new HeaderHttpSessionStrategy());
    MediaTypeRequestMatcher matcher = new MediaTypeRequestMatcher(contentNegotiationStrategy,
            Arrays.asList(MediaType.TEXT_HTML));
    matcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));

    RequestHeaderRequestMatcher javascript = new RequestHeaderRequestMatcher("X-Requested-With");

    this.browserMatcher = new OrRequestMatcher(Arrays.asList(matcher, javascript));
}

From source file:org.elasticsearch.example.role.CustomRolesProviderIT.java

@Override
protected Collection<Class<? extends Plugin>> transportClientPlugins() {
    return Collections.singleton(XPackClientPlugin.class);
}

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

@Override
public Set<VertexComputeKey> getVertexComputeKeys() {
    return Collections.singleton(VertexComputeKey.of(edgeCountPropertyKey, false));
}

From source file:com.qubit.solution.fenixedu.integration.cgd.webservices.messages.CgdMessageUtils.java

public static Person readPersonByMemberCode(String populationCode, String memberCode) {
    Person requestedPerson = null;/*from w w w . j a  v  a  2s .co  m*/
    if (!StringUtils.isEmpty(memberCode) && !StringUtils.isEmpty(populationCode)) {
        switch (populationCode.charAt(0)) {
        case 'A':
            Student student = null;

            try {
                int number = Integer.parseInt(memberCode);
                student = Student.readStudentByNumber(number);
            } catch (Exception e) {
                logger.warn(String.format("Invalid student number: [%s]", memberCode));
            }

            if (student != null) {
                requestedPerson = student.getPerson();
            }
        case 'E':
            // NOT YET IMPLEMENTED
            break;
        case 'D':
            List<Teacher> readByNumbers = Teacher.readByNumbers(Collections.singleton(memberCode));
            Teacher teacher = readByNumbers.isEmpty() ? null : readByNumbers.iterator().next();
            if (teacher != null) {
                requestedPerson = teacher.getPerson();
            }
        }
    }
    return requestedPerson;
}

From source file:com.citrus.sdk.webops.SavePayOption.java

@Override
protected Void doInBackground(Void... params) {
    try {/*from  ww  w .j  ava 2 s.  c  o m*/
        cardDetails.put("paymentOptions", new JSONArray(Collections.singleton(this.paymentOption)));
    } catch (JSONException e) {

    }
    client = new MobileClient(this.activity, Constants.CITRUS_OAUTH_URL);
    subscriptionService = client.getSubscriptionService(Constants.SIGNUP_KEY, Constants.SIGNUP_SECRET,
            Constants.SIGNIN_ID, Constants.SIGNIN_SECRET);
    PaymentConfiguration payment = new PaymentConfiguration();
    payment.parse(cardDetails);
    try {
        subscriptionService.updateProfile(payment);
        result = "success";
    } catch (ProtocolException e) {
        result = "proto";
    } catch (OAuth2Exception e) {
        result = "oauth";
    } catch (SubscriptionException e) {
        result = "subsc";
    }

    return null;
}

From source file:com.orange.cepheus.cep.EventSinkListenerTest.java

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);

    broker = new Broker("http://orion");
    broker.setServiceName("SN");
    broker.setServicePath("SP");
    broker.setAuthToken("AUTH_TOKEN");

    Attribute attr = new Attribute("avgTemp", "double");
    attr.setMetadata(Collections.singleton(new Metadata("unit", "string")));

    // TestConfiguration setup
    Configuration configuration = new Configuration();
    EventTypeOut eventTypeOut = new EventTypeOut("OUT1", "TempSensorAvg", false);
    eventTypeOut.addBroker(broker);//from  ww w  .j a  va 2 s  .c om
    eventTypeOut.addAttribute(attr);
    configuration.setEventTypeOuts(Collections.singletonList(eventTypeOut));

    eventSinkListener.setConfiguration(configuration);
}