Example usage for java.util Set add

List of usage examples for java.util Set add

Introduction

In this page you can find the example usage for java.util Set add.

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:com.l2jfree.gameserver.document.DocumentEngine.java

public static List<L2Item> loadArmors(Map<Integer, Item> armorData) {
    final List<L2Item> list = loadData(armorData, listFiles("data/stats/armor"));

    Set<Integer> xmlItem = new HashSet<Integer>();

    for (L2Item item : list)
        xmlItem.add(item.getItemId());

    for (Item item : armorData.values())
        if (!xmlItem.contains(item.id))
            _log.warn("SkillsEngine: Missing XML side for L2Armor - id: " + item.id);

    return list;//w  w  w .  j a va 2s  . c  o  m
}

From source file:com.l2jfree.gameserver.document.DocumentEngine.java

public static List<L2Item> loadWeapons(Map<Integer, Item> weaponData) {
    final List<L2Item> list = loadData(weaponData, listFiles("data/stats/weapon"));

    Set<Integer> xmlItem = new HashSet<Integer>();

    for (L2Item item : list)
        xmlItem.add(item.getItemId());

    for (Item item : weaponData.values())
        if (!xmlItem.contains(item.id))
            _log.warn("SkillsEngine: Missing XML side for L2Weapon - id: " + item.id);

    return list;/*ww  w .  j  a  v  a2s  .  c  o m*/
}

From source file:de.mprengemann.intellij.plugin.androidicons.util.ExportNameUtils.java

public static String getExportDescription(List<ImageInformation> scalingInformationList) {
    Set<String> importFileNames = new HashSet<String>();
    for (ImageInformation information : scalingInformationList) {
        importFileNames.add(information.getImageFile().getName());
    }//from w w w.ja v a 2 s . co  m
    StringBuilder builder = new StringBuilder("Import of ");
    // No multi import
    if (importFileNames.size() == 1) {
        builder.append(importFileNames.iterator().next());
        if (scalingInformationList.size() == 1) {
            builder.append(" in resolution ");
        } else {
            builder.append(" in resolutions ");
        }
        for (Iterator<ImageInformation> iterator = scalingInformationList.iterator(); iterator.hasNext();) {
            ImageInformation information = iterator.next();
            builder.append(information.getTargetResolution());
            if (iterator.hasNext()) {
                builder.append(", ");
            }
        }
    } else {
        for (Iterator<String> iterator = importFileNames.iterator(); iterator.hasNext();) {
            String exportName = iterator.next();
            builder.append(exportName);
            if (iterator.hasNext()) {
                builder.append(", ");
            }
        }
        builder.append(" as ").append(scalingInformationList.get(0).getExportName());
    }
    return builder.toString();
}

From source file:Main.java

public static <T> Set<String> toStringSet(Collection<T> a_values)
/*     */ {/*from w w  w. ja v a2 s  .  c  om*/
    /* 443 */Set values = new HashSet();
    /*     */
    /* 445 */for (Iterator i$ = a_values.iterator(); i$.hasNext();) {
        Object value = i$.next();
        /*     */
        /* 447 */values.add(value.toString());
        /*     */}
    /*     */
    /* 450 */return values;
    /*     */}

From source file:Main.java

/**
 * @param propertyValue node.getProperty value.
 * @return a collection of all the values from a property. If the value is
 *         just a plain "single" value the collection will contain that
 *         single value. If the value is an array of values, all those
 *         values are added to the collection.
 *///  ww  w  .ja v  a2  s.c o m
public static Collection<Object> propertyValueToCollection(Object propertyValue) {
    Set<Object> values = new HashSet<Object>();
    try {
        int length = Array.getLength(propertyValue);
        for (int i = 0; i < length; i++) {
            values.add(Array.get(propertyValue, i));
        }
    } catch (IllegalArgumentException e) {
        values.add(propertyValue);
    }
    return values;
}

From source file:com.wrmsr.wava.basic.BasicLoopInfo.java

public static Set<Name> getLoopContents(Name loop, Multimap<Name, Name> inputs,
        Multimap<Name, Name> backEdges) {
    Set<Name> seen = new HashSet<>();
    seen.add(loop);
    Queue<Name> queue = new LinkedList<>();
    inputs.get(loop).stream().filter(n -> !n.equals(loop) && backEdges.containsEntry(loop, n))
            .forEach(queue::add);//  w w  w .jav  a2s . co  m
    queue.forEach(seen::add);
    while (!queue.isEmpty()) {
        Name cur = queue.poll();
        inputs.get(cur).stream().filter(input -> !seen.contains(input)).forEach(input -> {
            seen.add(input);
            queue.add(input);
        });
    }
    return seen;
}

From source file:org.apache.calcite.adapter.elasticsearch.ElasticsearchSchemaFactory.java

/**
 * Builds elastic rest client from user configuration
 * @param coordinates list of {@code hostname/port} to connect to
 * @return newly initialized low-level rest http client for ES
 *///from w  w  w  . ja v a  2  s  .c  om
private static RestClient connect(Map<String, Integer> coordinates) {
    Objects.requireNonNull(coordinates, "coordinates");
    Preconditions.checkArgument(!coordinates.isEmpty(), "no ES coordinates specified");
    final Set<HttpHost> set = new LinkedHashSet<>();
    for (Map.Entry<String, Integer> entry : coordinates.entrySet()) {
        set.add(new HttpHost(entry.getKey(), entry.getValue()));
    }

    return RestClient.builder(set.toArray(new HttpHost[0])).build();
}

From source file:net.diogobohm.timed.api.domain.Tag.java

public static Set<Tag> parseTagsFromString(String tagExpression) {
    String cleanTags = cleanExpression(tagExpression);
    Set<Tag> tagSet = Sets.newHashSet();

    for (String tagName : cleanTags.split("#")) {
        if (!tagName.isEmpty()) {
            tagSet.add(new Tag(tagName));
        }/*w  w  w  .  ja v  a  2s .c  o m*/
    }

    return tagSet;
}

From source file:fr.mby.portal.coreimpl.acl.AclHelper.java

public static Set<IPermission> builePermissionSet(final IPermission... permissions) {
    Assert.notNull(permissions, "No permissions supplied !");
    final Set<IPermission> set = new HashSet<IPermission>(permissions.length);
    for (final IPermission perm : permissions) {
        if (perm != null) {
            set.add(perm);
        }//w w w . j  a  va  2 s. c o m
    }
    return set;
}

From source file:com.l2jfree.gameserver.document.DocumentEngine.java

public static List<L2Item> loadItems(Map<Integer, Item> itemData) {
    final List<L2Item> list = loadData(itemData, listFiles("data/stats/etcitem"));

    Set<Integer> xmlItem = new HashSet<Integer>();

    for (L2Item item : list)
        xmlItem.add(item.getItemId());

    for (Item item : itemData.values()) {
        if (!xmlItem.contains(item.id)) {
            try {
                list.add(new L2EtcItem((L2EtcItemType) item.type, item.set));
            } catch (RuntimeException e) {
                _log.warn("Error while parsing item id " + item.id, e);
            }/*  w  w  w  .  j a  v a2  s.c om*/
        }
    }

    return list;
}