當前位置: 首頁>>代碼示例>>Java>>正文


Java Collections.singleton方法代碼示例

本文整理匯總了Java中java.util.Collections.singleton方法的典型用法代碼示例。如果您正苦於以下問題:Java Collections.singleton方法的具體用法?Java Collections.singleton怎麽用?Java Collections.singleton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Collections的用法示例。


在下文中一共展示了Collections.singleton方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: send

import java.util.Collections; //導入方法依賴的package包/類
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());
  msg.setTransactionDistributed(event.getRegion().getCache().getTxManager().isDistributed());
  Set failures = event.getRegion().getDistributionManager().putOutgoing(msg);
  if (failures != null && failures.size() > 0) {
    throw new RemoteOperationException(
        LocalizedStrings.RemotePutMessage_FAILED_SENDING_0.toLocalizedString(msg));
  }
  return p;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:19,代碼來源:RemotePutAllMessage.java

示例2: add

import java.util.Collections; //導入方法依賴的package包/類
/** {@inheritDoc} */
public boolean add(ElementType element) {
    if (delegate.isEmpty()) {
        delegate = Collections.singleton(element);
        return true;
    } else {
        delegate = createImplementation();
        return delegate.add(element);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:11,代碼來源:LazySet.java

示例3: loadUserByUsername

import java.util.Collections; //導入方法依賴的package包/類
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    User user = userRepository.findByUsername(username)
            .orElseThrow(() -> new UsernameNotFoundException("User not found"));
    String role = user.getRole();

    return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(),
            user.isEnabled(), true, true, user.getConfirmed(), Collections.singleton(new SimpleGrantedAuthority(role)));
}
 
開發者ID:egch,項目名稱:sushi-bar-BE,代碼行數:10,代碼來源:UserDetailsServiceImpl.java

示例4: testMakeKafkaProperties

import java.util.Collections; //導入方法依賴的package包/類
@Test
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.assertTrue(kafkaProperties.containsKey(strippedName));
    Assert.assertEquals(kafkaProperties.get(strippedName), "bullet.queries");
}
 
開發者ID:yahoo,項目名稱:bullet-kafka,代碼行數:12,代碼來源:KafkaConfigTest.java

示例5: doAggregate

import java.util.Collections; //導入方法依賴的package包/類
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 = storeSupplier.name() + 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.addInternalTopic(topic);
    topology.addSink(sinkName, topic, keySerializer, changedValueSerializer, this.name);

    // 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), storeSupplier.name(), isQueryable);
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:32,代碼來源:KGroupedTableImpl.java

示例6: testReplyToRequestForUs

import java.util.Collections; //導入方法依賴的package包/類
/**
 * Test ARP request from external network to an internal host.
 */
@Test
public void testReplyToRequestForUs() {
    Ip4Address theirIp = Ip4Address.valueOf("10.0.1.254");
    Ip4Address ourFirstIp = Ip4Address.valueOf("10.0.1.1");
    Ip4Address ourSecondIp = Ip4Address.valueOf("10.0.2.1");
    MacAddress firstMac = MacAddress.valueOf(1L);
    MacAddress secondMac = MacAddress.valueOf(2L);

    Host requestor = new DefaultHost(PID, HID1, MAC1, VLAN1, LOC1,
            Collections.singleton(theirIp));

    expect(hostService.getHost(HID1)).andReturn(requestor);
    replay(hostService);
    replay(interfaceService);

    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
    packetService.packets.clear();
    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));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:37,代碼來源:ProxyArpManagerTest.java

示例7: listLocationsForModules

import java.util.Collections; //導入方法依賴的package包/類
@Override
Iterable<Set<Location>> listLocationsForModules() throws IOException {
    return Collections.singleton(moduleTable.locations());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:Locations.java

示例8: CacheableTaskOutputCompositeFilePropertyElementSpec

import java.util.Collections; //導入方法依賴的package包/類
public CacheableTaskOutputCompositeFilePropertyElementSpec(CompositeTaskOutputPropertySpec parentProperty, String propertySuffix, File file) {
    this.parentProperty = parentProperty;
    this.propertySuffix = propertySuffix;
    this.files = new SimpleFileCollection(Collections.singleton(file));
    this.file = file;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:7,代碼來源:CacheableTaskOutputCompositeFilePropertyElementSpec.java

示例9: validateComment

import java.util.Collections; //導入方法依賴的package包/類
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,
					currentId);
	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);
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:50,代碼來源:BlogPostValidator.java

示例10: buildUniqueTicketIdGenerators

import java.util.Collections; //導入方法依賴的package包/類
@Override
public Collection<Pair<String, UniqueTicketIdGenerator>> buildUniqueTicketIdGenerators() {
    return Collections.singleton(Pair.of(SamlService.class.getCanonicalName(), samlServiceTicketUniqueIdGenerator()));
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:5,代碼來源:SamlUniqueTicketIdGeneratorConfiguration.java

示例11: getElementQNames

import java.util.Collections; //導入方法依賴的package包/類
public Set<QName> getElementQNames() {
    return Collections.singleton(HTTPQName.OPERATION.getQName());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:4,代碼來源:HTTPElementFactoryProvider.java

示例12: HierarchyDialog

import java.util.Collections; //導入方法依賴的package包/類
public HierarchyDialog(Frame frame, final ClientService clientService)
{
	super(frame);

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

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

		protected EntityCache cache;

		@Override
		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);
		}

		@Override
		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");

	setTitle(getString("hierarchydialog.title"));
	setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
	getContentPane().add(all);
	setModal(true);

	addWindowListener(new WindowAdapter()
	{
		@Override
		public void windowClosing(WindowEvent e)
		{
			closeAction.actionPerformed(null);
		}
	});

	ComponentHelper.percentageOfScreen(this, 0.9f, 0.9f);
	ComponentHelper.centreOnScreen(this);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:62,代碼來源:HierarchyDialog.java

示例13: nodePlugins

import java.util.Collections; //導入方法依賴的package包/類
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
    return Collections.singleton(MockRepository.Plugin.class);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:5,代碼來源:MinThreadsSnapshotRestoreIT.java

示例14: nodePlugins

import java.util.Collections; //導入方法依賴的package包/類
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
    return Collections.singleton(CustomScriptPlugin.class);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:5,代碼來源:CardinalityIT.java

示例15: getMimeTypes

import java.util.Collections; //導入方法依賴的package包/類
public @Override Set<String> getMimeTypes() {
    return Collections.singleton("text/plain");
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:4,代碼來源:RepositoryUpdater2Test.java


注:本文中的java.util.Collections.singleton方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。