当前位置: 首页>>代码示例>>Java>>正文


Java Collection.add方法代码示例

本文整理汇总了Java中java.util.Collection.add方法的典型用法代码示例。如果您正苦于以下问题:Java Collection.add方法的具体用法?Java Collection.add怎么用?Java Collection.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Collection的用法示例。


在下文中一共展示了Collection.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getItemLootInfo

import java.util.Collection; //导入方法依赖的package包/类
@Override
public Collection<ItemLootInfo> getItemLootInfo()
{
	Collection<ItemLootInfo> itemLoot = new LinkedList<>();
	itemLoot.add(new ItemLootInfo.Builder()
			.itemIdentifier(ItemIdentifiers.SMALL_HP_POTION)
			.chancesOfDropping(0.5f)
			.itemNumberRange(Range.between(1, 2))
			.build());
	itemLoot.add(new ItemLootInfo.Builder()
			.itemIdentifier(ItemIdentifiers.SMALL_MP_POTION)
			.chancesOfDropping(0.5f)
			.itemNumberRange(Range.between(2, 3))
			.build());
	itemLoot.add(new ItemLootInfo.Builder()
			.itemIdentifier(ItemIdentifiers.FISH)
			.chancesOfDropping(1.0f)
			.itemNumberRange(Range.between(2, 3))
			.build());
	return itemLoot;
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:22,代码来源:SkeletonLootGenerator.java

示例2: customValidate

import java.util.Collection; //导入方法依赖的package包/类
@Override
protected Collection<ValidationResult> customValidate(final ValidationContext context) {
    final Collection<ValidationResult> results = new ArrayList<>();

    PropertyValue usernameProperty = context.getProperty(USERNAME);
    PropertyValue passwordProperty = context.getProperty(PASSWORD);
    PropertyValue authDatabaseProperty = context.getProperty(AUTH_DATABASE);

    boolean valid = true;
    if (usernameProperty.isSet() || passwordProperty.isSet() || authDatabaseProperty.isSet()) {
        valid = usernameProperty.isSet() && passwordProperty.isSet() && authDatabaseProperty.isSet();
    }

    results.add(new ValidationResult.Builder()
            .explanation("Using authentication requires Username, Password, and the Authentication Database")
            .valid(valid)
            .subject("Mongo Authentication")
            .build());

    return results;
}
 
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:22,代码来源:StandardMongoClientService.java

示例3: removeItemsByTypeIdAndProviderId

import java.util.Collection; //导入方法依赖的package包/类
Collection<Item> removeItemsByTypeIdAndProviderId(final String typeId, final String providerId,
        final Collection<Item> items) {
    Map<String, Collection<Item>> itemsForTypeId = itemIndex.get(typeId);
    if (itemsForTypeId == null) {
        return Collections.emptyList(); // Immutable
    }
    Collection<Item> allItemsForProvider = itemsForTypeId.get(providerId);
    if (allItemsForProvider == null) {
        return Collections.emptyList(); // Immutable
    }
    Collection<Item> actuallyRemoved = new ArrayList<Item>(items.size());
    for (Item item : items) {
        if (allItemsForProvider.remove(item)) {
            actuallyRemoved.add(item);
        }
    }
    return actuallyRemoved;
}
 
开发者ID:HewlettPackard,项目名称:loom,代码行数:19,代码来源:SimpleStitcherSession.java

示例4: prepare

import java.util.Collection; //导入方法依赖的package包/类
@Override
public Object prepare(Object value) {

  if (!ObjectUtils.isArray(value)) {
    return value;
  }

  int length = Array.getLength(value);
  Collection<Object> result = new ArrayList<Object>(length);

  for (int i = 0; i < length; i++) {
    result.add(Array.get(value, i));
  }

  return result;
}
 
开发者ID:hexagonframework,项目名称:spring-data-ebean,代码行数:17,代码来源:StringQuery.java

示例5: create

import java.util.Collection; //导入方法依赖的package包/类
@Override
public Set<V> create(Object... elements) {
  @SuppressWarnings("unchecked")
  V[] valuesArray = (V[]) elements;

  // Start with a suitably shaped collection of entries
  Collection<Map.Entry<K, V>> originalEntries = mapGenerator.getSampleElements(elements.length);

  // Create a copy of that, with the desired value for each value
  Collection<Map.Entry<K, V>> entries = new ArrayList<Entry<K, V>>(elements.length);
  int i = 0;
  for (Map.Entry<K, V> entry : originalEntries) {
    entries.add(Helpers.mapEntry(entry.getKey(), valuesArray[i++]));
  }

  return mapGenerator.create(entries.toArray()).values();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:18,代码来源:DerivedGoogleCollectionGenerators.java

示例6: mapFromRegisteredService

import java.util.Collection; //导入方法依赖的package包/类
@Override
public LdapEntry mapFromRegisteredService(final String dn, final RegisteredService svc) {
    try {
        if (svc.getId() == RegisteredService.INITIAL_IDENTIFIER_VALUE) {
            ((AbstractRegisteredService) svc).setId(System.nanoTime());
        }
        final String newDn = getDnForRegisteredService(dn, svc);
        LOGGER.debug("Creating entry {}", newDn);

        final Collection<LdapAttribute> attrs = new ArrayList<>();
        attrs.add(new LdapAttribute(this.idAttribute, String.valueOf(svc.getId())));

        final StringWriter writer = new StringWriter();
        this.jsonSerializer.toJson(writer, svc);
        attrs.add(new LdapAttribute(this.serviceDefinitionAttribute, writer.toString()));
        attrs.add(new LdapAttribute(LdapUtils.OBJECTCLASS_ATTRIBUTE, "top", this.objectClass));

        return new LdapEntry(newDn, attrs);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:23,代码来源:DefaultLdapRegisteredServiceMapper.java

示例7: deleteAll

import java.util.Collection; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void deleteAll(Collection<?> keys) throws CacheWriterException {
    Collection<Cache.Entry<?, ?>> deletes = new ArrayList<>();
    for (Object key : keys) {
        deletes.add(new CacheEntryImpl<Object, Object>(key, TOMBSTONE));
    }
    putAll(deletes);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:9,代码来源:ActiveCacheStore.java

示例8: loadPlugins

import java.util.Collection; //导入方法依赖的package包/类
/**
 * odczytanie pluginów z pliku konfiguracyjnego
 *
 * @param fileName - nazwa pliku konfiguracyjnego
 * @return kolekcja pluginow
 */
private Collection<Plugin> loadPlugins(String fileName) {
    Collection<Plugin> list = new ArrayList<>();

    // odczytanie pliku z listą pluginów
    try {
        BufferedReader in = new BufferedReader(new InputStreamReader(PanelWorkbench.class.getClassLoader().getResourceAsStream(fileName)));
        while (true) {
            String line = in.readLine();
            if (line == null) {
                break;
            }
            if (line.startsWith("#")) {
                continue;
            }

            // mamy nazwe klasy, trzeba ja utworzyć
            try {
                Class<?> pluginClass = Class.forName(line);
                if (pluginClass != null) {
                    list.add((Plugin) pluginClass.newInstance());
                }
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
                logger().error("While loading class plugins:", e);
            }
        }
    } catch (IOException ex) {
        logger().error("While openning file:", ex);
    }
    return list;
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:37,代码来源:PanelWorkbench.java

示例9: getAuthorities

import java.util.Collection; //导入方法依赖的package包/类
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
  Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
  SimpleGrantedAuthority authority = new SimpleGrantedAuthority(this.role);
  authorities.add(authority);
  return authorities;
}
 
开发者ID:itmuch,项目名称:spring-cloud-docker-microservice-book-code,代码行数:8,代码来源:WebSecurityConfig.java

示例10: collectNewChildDescriptors

import java.util.Collection; //导入方法依赖的package包/类
/**
 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
 * that can be created under this object.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected void collectNewChildDescriptors ( Collection<Object> newChildDescriptors, Object object )
{
    super.collectNewChildDescriptors ( newChildDescriptors, object );

    newChildDescriptors.add
            ( createChildParameter
            ( ConfigurationPackage.Literals.UPDATE_TYPE__MAPPING,
                    ConfigurationFactory.eINSTANCE.createUpdateMappingType () ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:UpdateTypeItemProvider.java

示例11: visitBreak

import java.util.Collection; //导入方法依赖的package包/类
@Override
public Void visitBreak(BreakTree node, Collection<TreePath> trees) {
    if (!analyzeThrows && !seenTrees.contains(info.getTreeUtilities().getBreakContinueTarget(getCurrentPath()))) {
        trees.add(getCurrentPath());
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:TryCatchFinally.java

示例12: Joined

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Ctor.
 * @param items Items to concatenate
 */
public Joined(final Iterable<Iterable<T>> items) {
    super(() -> {
        final Collection<Iterator<T>> iterators = new LinkedList<>();
        for (final Iterable<T> item : items) {
            iterators.add(item.iterator());
        }
        return () -> new org.cactoos.iterator.Joined<>(iterators);
    });
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:14,代码来源:Joined.java

示例13: txDataToCacheUpdates

import java.util.Collection; //导入方法依赖的package包/类
private static Collection<Cache.Entry<?, ?>> txDataToCacheUpdates(Map<?, ?> txDataEntries) {
    Collection<Cache.Entry<?, ?>> updates = new ArrayList<>();

    for (Object value : txDataEntries.values()) {
        TransactionData txData = (TransactionData)value;
        AccountTransactionKey txKey = new AccountTransactionKey(txData.getTransactionId(),
            txData.getPartition());
        AccountTransaction accountTx = new AccountTransaction(
            txKey,
            txData.getFromAccountId(),
            txData.getToAccountId(),
            txData.getMoneyAmount()
        );
        AccountKey toAccountKey = new AccountKey(txData.getToAccountId(), txData.getPartition());
        AccountKey fromAccountKey = new AccountKey(txData.getFromAccountId(), txData.getPartition());
        Account toAccount = new Account(toAccountKey);
        Account fromAccount = new Account(fromAccountKey);
        long timestamp = System.currentTimeMillis();

        fromAccount.addTransaction(timestamp, txKey);
        toAccount.addTransaction(timestamp, txKey);

        updates.add(new CacheEntryImpl<>(txKey, accountTx));
        updates.add(new CacheEntryImpl<>(toAccountKey, toAccount));
        updates.add(new CacheEntryImpl<>(fromAccountKey, fromAccount));
    }
    return updates;
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:29,代码来源:KafkaWritingEntryProcessor.java

示例14: getWebSocketRegions

import java.util.Collection; //导入方法依赖的package包/类
@Override
public Collection<WebSocketRegion> getWebSocketRegions() {
	Collection<WebSocketRegion> regions = super.getWebSocketRegions();
	PullRequest request = getPullRequest();
	if (request != null) {
		regions.add(new CommitIndexedRegion(request.getBaseCommit()));
		regions.add(new CommitIndexedRegion(request.getHeadCommit()));
	}
	return regions;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:11,代码来源:NewRequestPage.java

示例15: collectNewChildDescriptors

import java.util.Collection; //导入方法依赖的package包/类
/**
 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
 * that can be created under this object.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected void collectNewChildDescriptors ( Collection<Object> newChildDescriptors, Object object )
{
    super.collectNewChildDescriptors ( newChildDescriptors, object );

    newChildDescriptors.add ( createChildParameter ( VisualInterfacePackage.Literals.XY_CONTAINER__CHILDREN, VisualInterfaceFactory.eINSTANCE.createXYChild () ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:15,代码来源:XYContainerItemProvider.java


注:本文中的java.util.Collection.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。