当前位置: 首页>>代码示例>>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;未经允许,请勿转载。