@Override public boolean add(final E object, final int count) { synchronized (lock) { return getBag().add(object, count); } }
@Override public boolean add(final E object, final int count) { return decorated().add(object, count); }
/** * <i>(Change)</i> * Adds <code>count</code> copies of the specified object to the Bag. * <p> * Since this method always increases the size of the bag, it * will always return <code>true</code>. * * @param object the object to add * @param count the number of copies to add * @return <code>true</code>, always */ @Override public boolean add(final E object, final int count) { decorated().add(object, count); return true; }
@Override public boolean add(final E object, final int count) { validate(object); return decorated().add(object, count); }
@Override public boolean add(final E object, final int nCopies) { return getBag().add(transform(object), nCopies); }
/** * Remove any members of the bag that are not in the given bag, respecting * cardinality. * @see #retainAll(Collection) * * @param other the bag to retain * @return <code>true</code> if this call changed the collection */ boolean retainAll(final Bag<?> other) { boolean result = false; final Bag<E> excess = new HashBag<>(); final Iterator<E> i = uniqueSet().iterator(); while (i.hasNext()) { final E current = i.next(); final int myCount = getCount(current); final int otherCount = other.getCount(current); if (1 <= otherCount && otherCount <= myCount) { excess.add(current, myCount - otherCount); } else { excess.add(current, myCount); } } if (!excess.isEmpty()) { result = removeAll(excess); } return result; }
/** * @param specFile to parse * @return all tags used in spec */ public static Collection<String> getTags(File specFile) { try { Bag<String> tags = new HashBag<>(); List<String> lines = FileUtils.readLines(specFile); for (String line : lines) { String trimmedLine = line.trim(); if (StringUtils.startsWith(trimmedLine, PATTERN_LINE_WITH_TAGS_IN_SPEC)) { String tagsAsString = StringUtils.removeStart(trimmedLine, PATTERN_LINE_WITH_TAGS_IN_SPEC); String[] tagsAsArray = tagsAsString.split(","); for (String tag : tagsAsArray) { if (StringUtils.isNotBlank(tag)) { String cleanedTag = tag.trim().replaceAll("[^A-Za-z0-9]*", ""); if (StringUtils.isNotBlank(cleanedTag)) { tags.add(cleanedTag); } } } } } return tags.uniqueSet(); } catch (IOException ex) { throw new GaleniumException("when parsing '" + specFile + "'"); } }