@Override protected void parseLong(CacheBuilderSpec spec, long value) { checkArgument(spec.maximumSize == null, "maximum size was already set to ", spec.maximumSize); checkArgument(spec.maximumWeight == null, "maximum weight was already set to ", spec.maximumWeight); spec.maximumSize = value; } }
@Override protected void parseInteger(CacheBuilderSpec spec, int value) { checkArgument(spec.initialCapacity == null, "initial capacity was already set to ", spec.initialCapacity); spec.initialCapacity = value; } }
@Override protected void parseInteger(CacheBuilderSpec spec, int value) { checkArgument(spec.concurrencyLevel == null, "concurrency level was already set to ", spec.concurrencyLevel); spec.concurrencyLevel = value; } }
@Override protected void parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit) { checkArgument(spec.accessExpirationTimeUnit == null, "expireAfterAccess already set"); spec.accessExpirationDuration = duration; spec.accessExpirationTimeUnit = unit; } }
@Override protected void parseDuration(CacheBuilderSpec spec, long duration, TimeUnit unit) { checkArgument(spec.refreshTimeUnit == null, "refreshAfterWrite already set"); spec.refreshDuration = duration; spec.refreshTimeUnit = unit; } }
@Override protected void parseLong(CacheBuilderSpec spec, long value) { checkArgument(spec.maximumSize == null, "maximum size was already set to ", spec.maximumSize); checkArgument(spec.maximumWeight == null, "maximum weight was already set to ", spec.maximumWeight); spec.maximumSize = value; } }
@Override public void parse(CacheBuilderSpec spec, String key, @Nullable String value) { checkArgument(value == null, "key %s does not take values", key); checkArgument(spec.keyStrength == null, "%s was already set to %s", key, spec.keyStrength); spec.keyStrength = strength; } }
@Override public void parse(CacheBuilderSpec spec, String key, @Nullable String value) { checkArgument(value == null, "recordStats does not take values"); checkArgument(spec.recordStats == null, "recordStats already set"); spec.recordStats = true; } }
@Override public void parse(CacheBuilderSpec spec, String key, @Nullable String value) { checkArgument(value == null, "recordStats does not take values"); checkArgument(spec.recordStats == null, "recordStats already set"); spec.recordStats = true; } }
Itr() { keyIterator = map.entrySet().iterator(); key = null; collection = null; valueIterator = Iterators.emptyModifiableIterator(); }
Itr() { keyIterator = map.entrySet().iterator(); key = null; collection = null; valueIterator = Iterators.emptyModifiableIterator(); }
@Override public void putAll(Map<? extends K, ? extends V> map) { for (Entry<? extends K, ? extends V> entry : map.entrySet()) { checkArgument(apply(entry.getKey(), entry.getValue())); } unfiltered.putAll(map); }
@Override public boolean addAll(Collection<? extends E> collection) { for (E element : collection) { checkArgument(predicate.apply(element)); } return unfiltered.addAll(collection); }
@Override public void parse(CacheBuilderSpec spec, String key, String value) { checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key); try { parseInteger(spec, Integer.parseInt(value)); } catch (NumberFormatException e) { throw new IllegalArgumentException( String.format("key %s value set to %s, must be integer", key, value), e); } } }
@Override public boolean addAll(Collection<? extends E> collection) { for (E element : collection) { checkArgument(predicate.apply(element)); } return unfiltered.addAll(collection); }
private HashMultimap(int expectedKeys, int expectedValuesPerKey) { super(Maps.<K, Collection<V>>newHashMapWithExpectedSize(expectedKeys)); Preconditions.checkArgument(expectedValuesPerKey >= 0); this.expectedValuesPerKey = expectedValuesPerKey; }
/** * Returns the IPv4 address embedded in an IPv4 compatible address. * * @param ip {@link Inet6Address} to be examined for an embedded IPv4 address * @return {@link Inet4Address} of the embedded IPv4 address * @throws IllegalArgumentException if the argument is not a valid IPv4 compatible address */ public static Inet4Address getCompatIPv4Address(Inet6Address ip) { Preconditions.checkArgument(isCompatIPv4Address(ip), "Address '%s' is not IPv4-compatible.", toAddrString(ip)); return getInet4Address(Arrays.copyOfRange(ip.getAddress(), 12, 16)); }
/** * Returns the IPv4 address embedded in a 6to4 address. * * @param ip {@link Inet6Address} to be examined for embedded IPv4 in 6to4 address * @return {@link Inet4Address} of embedded IPv4 in 6to4 address * @throws IllegalArgumentException if the argument is not a valid IPv6 6to4 address */ public static Inet4Address get6to4IPv4Address(Inet6Address ip) { Preconditions.checkArgument(is6to4Address(ip), "Address '%s' is not a 6to4 address.", toAddrString(ip)); return getInet4Address(Arrays.copyOfRange(ip.getAddress(), 2, 6)); }
/** * @since 12.0 */ @GwtIncompatible("NavigableSet") @Override public ImmutableSortedSet<E> subSet( E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) { checkNotNull(fromElement); checkNotNull(toElement); checkArgument(comparator.compare(fromElement, toElement) <= 0); return subSetImpl(fromElement, fromInclusive, toElement, toInclusive); }
PowerSet(Set<E> input) { ImmutableMap.Builder<E, Integer> builder = ImmutableMap.builder(); int i = 0; for (E e : checkNotNull(input)) { builder.put(e, i++); } this.inputSet = builder.build(); checkArgument(inputSet.size() <= 30, "Too many elements to create power set: %s > 30", inputSet.size()); }