Java Code Examples for java.util.Collections.singleton()

The following are Jave code examples for showing how to use singleton() of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: monarch   File:   Source Code and License Vote up 6 votes
public static PutAllResponse send(DistributedMember recipient, EntryEventImpl event,
    PutAllEntryData[] putAllData, int putAllDataCount, boolean useOriginRemote, int processorType,
    boolean possibleDuplicate) throws RemoteOperationException {
  // Assert.assertTrue(recipient != null, "RemotePutAllMessage NULL recipient"); recipient can be
  // null for event notifications
  Set recipients = Collections.singleton(recipient);
  PutAllResponse p = new PutAllResponse(event.getRegion().getSystem(), recipients);
  RemotePutAllMessage msg =
      new RemotePutAllMessage(event, recipients, p, putAllData, putAllDataCount, useOriginRemote,
          processorType, possibleDuplicate, !event.isGenerateCallbacks());
  Set failures = event.getRegion().getDistributionManager().putOutgoing(msg);
  if (failures != null && failures.size() > 0) {
    throw new RemoteOperationException(
  return p;
Example 2
Project: lams   File:   Source Code and License Vote up 5 votes
/** {@inheritDoc} */
public boolean add(ElementType element) {
    if (delegate.isEmpty()) {
        delegate = Collections.singleton(element);
        return true;
    } else {
        delegate = createImplementation();
        return delegate.add(element);
Example 3
Project: sushi-bar-BE   File:   Source Code and License Vote up 5 votes
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    User user = userRepository.findByUsername(username)
            .orElseThrow(() -> new UsernameNotFoundException("User not found"));
    String role = user.getRole();

    return new, user.getPassword(),
            user.isEnabled(), true, true, user.getConfirmed(), Collections.singleton(new SimpleGrantedAuthority(role)));
Example 4
Project: bullet-kafka   File:   Source Code and License Vote up 5 votes
public void testMakeKafkaProperties() {
    KafkaConfig config = new KafkaConfig("");
    Set<String> keys = new HashSet<>(Collections.singleton(KafkaConfig.REQUEST_TOPIC_NAME));
    Map<String, Object> kafkaProperties = config.getAllWithPrefix(Optional.of(keys), KafkaConfig.KAFKA_NAMESPACE, true);

    String strippedName = KafkaConfig.REQUEST_TOPIC_NAME.substring(KafkaConfig.KAFKA_NAMESPACE.length());
    Assert.assertEquals(kafkaProperties.size(), 1);
    Assert.assertEquals(kafkaProperties.get(strippedName), "bullet.queries");
Example 5
Project: kafka-   File:   Source Code and License Vote up 5 votes
private <T> KTable<K, T> doAggregate(final ProcessorSupplier<K, Change<V>> aggregateSupplier,
                                     final String functionName,
                                     final StateStoreSupplier<KeyValueStore> storeSupplier) {
    String sinkName = topology.newName(KStreamImpl.SINK_NAME);
    String sourceName = topology.newName(KStreamImpl.SOURCE_NAME);
    String funcName = topology.newName(functionName);

    String topic = + KStreamImpl.REPARTITION_TOPIC_SUFFIX;

    Serializer<? extends K> keySerializer = keySerde == null ? null : keySerde.serializer();
    Deserializer<? extends K> keyDeserializer = keySerde == null ? null : keySerde.deserializer();
    Serializer<? extends V> valueSerializer = valSerde == null ? null : valSerde.serializer();
    Deserializer<? extends V> valueDeserializer = valSerde == null ? null : valSerde.deserializer();

    ChangedSerializer<? extends V> changedValueSerializer = new ChangedSerializer<>(valueSerializer);
    ChangedDeserializer<? extends V> changedValueDeserializer = new ChangedDeserializer<>(valueDeserializer);

    // send the aggregate key-value pairs to the intermediate topic for partitioning
    topology.addSink(sinkName, topic, keySerializer, changedValueSerializer,;

    // read the intermediate topic
    topology.addSource(sourceName, keyDeserializer, changedValueDeserializer, topic);

    // aggregate the values with the aggregator and local store
    topology.addProcessor(funcName, aggregateSupplier, sourceName);
    topology.addStateStore(storeSupplier, funcName);

    // return the KTable representation with the intermediate topic as the sources
    return new KTableImpl<>(topology, funcName, aggregateSupplier, Collections.singleton(sourceName),, isQueryable);
Example 6
Project: athena   File:   Source Code and License Vote up 5 votes
 * Test ARP request from external network to an internal host.
public void testReplyToRequestForUs() {
    Ip4Address theirIp = Ip4Address.valueOf("");
    Ip4Address ourFirstIp = Ip4Address.valueOf("");
    Ip4Address ourSecondIp = Ip4Address.valueOf("");
    MacAddress firstMac = MacAddress.valueOf(1L);
    MacAddress secondMac = MacAddress.valueOf(2L);

    Host requestor = new DefaultHost(PID, HID1, MAC1, VLAN1, LOC1,


    Ethernet arpRequest = buildArp(ARP.OP_REQUEST, VLAN1, MAC1, null, theirIp, ourFirstIp);

    proxyArp.reply(arpRequest, LOC1);

    assertEquals(1, packetService.packets.size());
    Ethernet arpReply = buildArp(ARP.OP_REPLY, VLAN1, firstMac, MAC1, ourFirstIp, theirIp);
    verifyPacketOut(arpReply, LOC1, packetService.packets.get(0));

    // Test a request for the second address on that port
    arpRequest = buildArp(ARP.OP_REQUEST, VLAN1, MAC1, null, theirIp, ourSecondIp);

    proxyArp.reply(arpRequest, LOC1);

    assertEquals(1, packetService.packets.size());
    arpReply = buildArp(ARP.OP_REPLY, VLAN1, secondMac, MAC1, ourSecondIp, theirIp);
    verifyPacketOut(arpReply, LOC1, packetService.packets.get(0));
Example 7
Project: openjdk-jdk10   File:   Source Code and License Vote up 4 votes
Iterable<Set<Location>> listLocationsForModules() throws IOException {
    return Collections.singleton(moduleTable.locations());
Example 8
Project: Reer   File:   Source Code and License Vote up 4 votes
public CacheableTaskOutputCompositeFilePropertyElementSpec(CompositeTaskOutputPropertySpec parentProperty, String propertySuffix, File file) {
    this.parentProperty = parentProperty;
    this.propertySuffix = propertySuffix;
    this.files = new SimpleFileCollection(Collections.singleton(file));
    this.file = file;
Example 9
Project: Nird2   File:   Source Code and License Vote up 4 votes
private BdfMessageContext validateComment(Message m, Group g, BdfList body)
		throws InvalidMessageException, FormatException {

	// comment, parent_original_id, parent_id, signature
	checkSize(body, 4);

	// Comment
	String comment = body.getOptionalString(0);
	checkLength(comment, 1, MAX_BLOG_COMMENT_LENGTH);

	// parent_original_id
	// The ID of a post or comment in this group or another group
	byte[] pOriginalIdBytes = body.getRaw(1);
	checkLength(pOriginalIdBytes, MessageId.LENGTH);
	MessageId pOriginalId = new MessageId(pOriginalIdBytes);

	// parent_id
	// The ID of a post, comment, wrapped post or wrapped comment in this
	// group, which had the ID parent_original_id in the group
	// where it was originally posted
	byte[] currentIdBytes = body.getRaw(2);
	checkLength(currentIdBytes, MessageId.LENGTH);
	MessageId currentId = new MessageId(currentIdBytes);

	// Signature
	byte[] sig = body.getRaw(3);
	checkLength(sig, 0, MAX_SIGNATURE_LENGTH);
	BdfList signed =
			BdfList.of(g.getId(), m.getTimestamp(), comment, pOriginalId,
	Blog b = blogFactory.parseBlog(g);
	Author a = b.getAuthor();
	try {
		clientHelper.verifySignature(SIGNING_LABEL_COMMENT, sig,
				a.getPublicKey(), signed);
	} catch (GeneralSecurityException e) {
		throw new InvalidMessageException(e);

	// Return the metadata and dependencies
	BdfDictionary meta = new BdfDictionary();
	if (comment != null) meta.put(KEY_COMMENT, comment);
	meta.put(KEY_ORIGINAL_MSG_ID, m.getId());
	meta.put(KEY_ORIGINAL_PARENT_MSG_ID, pOriginalId);
	meta.put(KEY_PARENT_MSG_ID, currentId);
	meta.put(KEY_AUTHOR, authorToBdfDictionary(a));
	Collection<MessageId> dependencies = Collections.singleton(currentId);
	return new BdfMessageContext(meta, dependencies);
Example 10
Project: cas-5.1.0   File:   Source Code and License Vote up 4 votes
public Collection<Pair<String, UniqueTicketIdGenerator>> buildUniqueTicketIdGenerators() {
    return Collections.singleton(Pair.of(SamlService.class.getCanonicalName(), samlServiceTicketUniqueIdGenerator()));
Example 11
Project: incubator-netbeans   File:   Source Code and License Vote up 4 votes
public Set<QName> getElementQNames() {
    return Collections.singleton(HTTPQName.OPERATION.getQName());
Example 12
Project: Equella   File:   Source Code and License Vote up 4 votes
public HierarchyDialog(Frame frame, final ClientService clientService)

	final RemoteHierarchyService hierarchyService = clientService.getService(RemoteHierarchyService.class);

	tree = new AbstractTreeEditor<HierarchyTreeNode>()
		private static final long serialVersionUID = 1L;

		protected EntityCache cache;

		protected AbstractTreeNodeEditor createEditor(HierarchyTreeNode node)
			if( !tree.canEdit(node) )
				return new BasicMessageEditor(getString("notopic.noteditable"));

			HierarchyPack pack = hierarchyService.getHierarchyPack(node.getId());
			if( cache == null )
				cache = new EntityCache(clientService);
			return new TopicEditor(clientService, cache, node, pack);

		protected AbstractTreeEditorTree<HierarchyTreeNode> createTree()
			Collection<String> privs = Collections.singleton("EDIT_HIERARCHY_TOPIC");
			final boolean canAddRootTopics = !clientService.getService(RemoteTLEAclManager.class)
				.filterNonGrantedPrivileges(null, privs).isEmpty();

			return new TreeEditor(hierarchyService, canAddRootTopics);

	JPanel all = new JPanel(new MigLayout("fill, wrap 1", "[grow]", "[fill, grow][][]"));
	all.add(tree, "grow, push");
	all.add(new JSeparator(), "growx");
	all.add(new JButton(closeAction), "alignx right");


	addWindowListener(new WindowAdapter()
		public void windowClosing(WindowEvent e)

	ComponentHelper.percentageOfScreen(this, 0.9f, 0.9f);
Example 13
Project: elasticsearch_my   File:   Source Code and License Vote up 4 votes
protected Collection<Class<? extends Plugin>> nodePlugins() {
    return Collections.singleton(MockRepository.Plugin.class);
Example 14
Project: elasticsearch_my   File:   Source Code and License Vote up 4 votes
protected Collection<Class<? extends Plugin>> nodePlugins() {
    return Collections.singleton(CustomScriptPlugin.class);
Example 15
Project: incubator-netbeans   File:   Source Code and License Vote up 4 votes
public @Override Set<String> getMimeTypes() {
    return Collections.singleton("text/plain");
Example 16
Project: Pogamut3   File:   Source Code and License Vote up 4 votes
public Set getReportArtifacts()
    return Collections.singleton( "" );
Example 17
Project: incubator-netbeans   File:   Source Code and License Vote up 4 votes
public @Override Set<String> getSupportedAnnotationTypes() {
    return Collections.singleton(A.class.getCanonicalName());
Example 18
Project: Logisim   File:   Source Code and License Vote up 4 votes
public ModelAddAction(CanvasModel model, CanvasObject added) {
	this(model, Collections.singleton(added));
Example 19
Project: JRediClients   File:   Source Code and License Vote up 4 votes
public JedisCluster(HostAndPort node, final GenericObjectPoolConfig poolConfig) {
	this(Collections.singleton(node), DEFAULT_TIMEOUT, DEFAULT_MAX_REDIRECTIONS, poolConfig);
Example 20
Project: kafka-   File:   Source Code and License Vote up 3 votes
 * Repartition a stream. This is required on join operations occurring after
 * an operation that changes the key, i.e, selectKey, map(..), flatMap(..).
 * @param keySerde      Serdes for serializing the keys
 * @param valSerde      Serdes for serilaizing the values
 * @param topicNamePrefix  prefix of topic name created for repartitioning, can be null,
 *                         in which case the prefix will be auto-generated internally.
 * @return a new {@link KStreamImpl}
private KStreamImpl<K, V> repartitionForJoin(Serde<K> keySerde,
                                             Serde<V> valSerde,
                                             final String topicNamePrefix) {

    String repartitionedSourceName = createReparitionedSource(this, keySerde, valSerde, topicNamePrefix);
    return new KStreamImpl<>(topology, repartitionedSourceName, Collections
        .singleton(repartitionedSourceName), false);