/** * Specifies the ordering of the generated multimap's values for each key. * * @since 8.0 */ @CanIgnoreReturnValue public Builder<K, V> orderValuesBy(Comparator<? super V> valueComparator) { this.valueComparator = checkNotNull(valueComparator); return this; }
/** * Specifies the ordering of the generated multimap's keys. * * @since 8.0 */ @CanIgnoreReturnValue public Builder<K, V> orderKeysBy(Comparator<? super K> keyComparator) { this.keyComparator = checkNotNull(keyComparator); return this; }
/** Specifies the ordering of the generated table's rows. */ @CanIgnoreReturnValue public Builder<R, C, V> orderRowsBy(Comparator<? super R> rowComparator) { this.rowComparator = checkNotNull(rowComparator, "rowComparator"); return this; }
/** Specifies the ordering of the generated table's rows. */ @CanIgnoreReturnValue public Builder<R, C, V> orderRowsBy(Comparator<? super R> rowComparator) { this.rowComparator = checkNotNull(rowComparator, "rowComparator"); return this; }
/** Specifies the ordering of the generated table's columns. */ @CanIgnoreReturnValue public Builder<R, C, V> orderColumnsBy(Comparator<? super C> columnComparator) { this.columnComparator = checkNotNull(columnComparator, "columnComparator"); return this; }
/** * Specifies the ordering of the generated multimap's values for each key. * * @since 8.0 */ @CanIgnoreReturnValue public Builder<K, V> orderValuesBy(Comparator<? super V> valueComparator) { this.valueComparator = checkNotNull(valueComparator); return this; }
/** * Specifies the ordering of the generated multimap's keys. * * @since 8.0 */ @CanIgnoreReturnValue public Builder<K, V> orderKeysBy(Comparator<? super K> keyComparator) { this.keyComparator = checkNotNull(keyComparator); return this; }
/** Specifies the ordering of the generated table's columns. */ @CanIgnoreReturnValue public Builder<R, C, V> orderColumnsBy(Comparator<? super C> columnComparator) { this.columnComparator = checkNotNull(columnComparator, "columnComparator"); return this; }
/** Add a new mapping from an index to an object to the escaping. */ @CanIgnoreReturnValue public CharEscaperBuilder addEscape(char c, String r) { map.put(c, checkNotNull(r)); if (c > max) { max = c; } return this; }
/** Add a new mapping from an index to an object to the escaping. */ @CanIgnoreReturnValue public CharEscaperBuilder addEscape(char c, String r) { map.put(c, checkNotNull(r)); if (c > max) { max = c; } return this; }
@CanIgnoreReturnValue Builder<E> combine(Builder<E> builder) { checkNotNull(builder); add(builder.contents, builder.size); return this; }
@Override @CanIgnoreReturnValue public boolean remove(Object object) { return delegate().remove(checkNotNull(object)); }
/** * Adds {@code element} to the {@code ImmutableMultiset}. * * @param element the element to add * @return this {@code Builder} object * @throws NullPointerException if {@code element} is null */ @CanIgnoreReturnValue @Override public Builder<E> add(E element) { contents.add(checkNotNull(element)); return this; }
@CanIgnoreReturnValue Builder<K, V> combine(Builder<K, V> other) { checkNotNull(other); ensureCapacity(this.size + other.size); System.arraycopy(other.entries, 0, this.entries, this.size, other.size); this.size += other.size; return this; }
/** * Adds a number of occurrences of an element to this {@code ImmutableMultiset}. * * @param element the element to add * @param occurrences the number of occurrences of the element to add. May be zero, in which * case no change will be made. * @return this {@code Builder} object * @throws NullPointerException if {@code element} is null * @throws IllegalArgumentException if {@code occurrences} is negative, or if this operation * would result in more than {@link Integer#MAX_VALUE} occurrences of the element */ @CanIgnoreReturnValue public Builder<E> addCopies(E element, int occurrences) { contents.add(checkNotNull(element), occurrences); return this; }
/** Add multiple mappings at once for a particular index. */ @CanIgnoreReturnValue public CharEscaperBuilder addEscapes(char[] cs, String r) { checkNotNull(r); for (char c : cs) { addEscape(c, r); } return this; }
/** * Adds a replacement string for the given input character. The specified character will be * replaced by the given string whenever it occurs in the input, irrespective of whether it lies * inside or outside the 'safe' range. * * @param c the character to be replaced * @param replacement the string to replace the given character * @return the builder instance * @throws NullPointerException if {@code replacement} is null */ @CanIgnoreReturnValue public Builder addEscape(char c, String replacement) { checkNotNull(replacement); // This can replace an existing character (the builder is re-usable). replacementMap.put(c, replacement); return this; }
@CanIgnoreReturnValue @Override public V put(R rowKey, C columnKey, V value) { checkNotNull(rowKey); checkNotNull(columnKey); checkNotNull(value); return getOrCreate(rowKey).put(columnKey, value); }
/** * Configures this {@code Builder} to order entries by value according to the specified * comparator. * * <p>The sort order is stable, that is, if two entries have values that compare as equivalent, * the entry that was inserted first will be first in the built map's iteration order. * * @throws IllegalStateException if this method was already called * @since 19.0 */ @CanIgnoreReturnValue @Beta public Builder<K, V> orderEntriesByValue(Comparator<? super V> valueComparator) { checkState(this.valueComparator == null, "valueComparator was already set"); this.valueComparator = checkNotNull(valueComparator, "valueComparator"); return this; }
@CanIgnoreReturnValue @Override public boolean addAll(int index, Collection<? extends V> elements) { checkNotNull(elements); checkPositionIndex(index, 0); throw new IllegalArgumentException("Key does not satisfy predicate: " + key); }