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


Java CanIgnoreReturnValue类代码示例

本文整理汇总了Java中com.google.errorprone.annotations.CanIgnoreReturnValue的典型用法代码示例。如果您正苦于以下问题:Java CanIgnoreReturnValue类的具体用法?Java CanIgnoreReturnValue怎么用?Java CanIgnoreReturnValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: copy

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * Copies all bytes from the input stream to the output stream. Does not close or flush either
 * stream.
 *
 * @param from the input stream to read from
 * @param to the output stream to write to
 * @return the number of bytes copied
 * @throws IOException if an I/O error occurs
 */
@CanIgnoreReturnValue
public static long copy(InputStream from, OutputStream to) throws IOException {
  checkNotNull(from);
  checkNotNull(to);
  byte[] buf = createBuffer();
  long total = 0;
  while (true) {
    int r = from.read(buf);
    if (r == -1) {
      break;
    }
    to.write(buf, 0, r);
    total += r;
  }
  return total;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:26,代码来源:ByteStreams.java

示例2: readLine

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * Reads a line of text. A line is considered to be terminated by any one of a line feed
 * ({@code '\n'}), a carriage return ({@code '\r'}), or a carriage return followed immediately by
 * a linefeed ({@code "\r\n"}).
 *
 * @return a {@code String} containing the contents of the line, not including any
 *     line-termination characters, or {@code null} if the end of the stream has been reached.
 * @throws IOException if an I/O error occurs
 */
@CanIgnoreReturnValue // to skip a line
public String readLine() throws IOException {
  while (lines.peek() == null) {
    cbuf.clear();
    // The default implementation of Reader#read(CharBuffer) allocates a
    // temporary char[], so we call Reader#read(char[], int, int) instead.
    int read = (reader != null)
        ? reader.read(buf, 0, buf.length)
        : readable.read(cbuf);
    if (read == -1) {
      lineBuf.finish();
      break;
    }
    lineBuf.add(buf, 0, read);
  }
  return lines.poll();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:27,代码来源:LineReader.java

示例3: remove

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
@CanIgnoreReturnValue
@Override
public boolean remove(@Nullable Object o) {
  int smearedHash = Hashing.smearedHash(o);
  int bucket = smearedHash & mask();
  ValueEntry<K, V> prev = null;
  for (ValueEntry<K, V> entry = hashTable[bucket];
      entry != null;
      prev = entry, entry = entry.nextInValueBucket) {
    if (entry.matchesValue(o, smearedHash)) {
      if (prev == null) {
        // first entry in the bucket
        hashTable[bucket] = entry.nextInValueBucket;
      } else {
        prev.nextInValueBucket = entry.nextInValueBucket;
      }
      deleteFromValueSet(entry);
      deleteFromMultimap(entry);
      size--;
      modCount++;
      return true;
    }
  }
  return false;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:26,代码来源:LinkedHashMultimap.java

示例4: readLines

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * Reads lines of text from this source, processing each line as it is read using the given
 * {@link LineProcessor processor}. Stops when all lines have been processed or the processor
 * returns {@code false} and returns the result produced by the processor.
 *
 * <p>Like {@link BufferedReader#readLine()}, this method considers a line to be a sequence of
 * text that is terminated by (but does not include) one of {@code \r\n}, {@code \r} or
 * {@code \n}. If the source's content does not end in a line termination sequence, it is treated
 * as if it does.
 *
 * @throws IOException if an I/O error occurs while reading from this source or if
 *     {@code processor} throws an {@code IOException}
 * @since 16.0
 */
@Beta
@CanIgnoreReturnValue // some processors won't return a useful result
public <T> T readLines(LineProcessor<T> processor) throws IOException {
  checkNotNull(processor);

  Closer closer = Closer.create();
  try {
    Reader reader = closer.register(openStream());
    return CharStreams.readLines(reader, processor);
  } catch (Throwable e) {
    throw closer.rethrow(e);
  } finally {
    closer.close();
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:30,代码来源:CharSource.java

示例5: appendTo

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * Appends the string representation of each entry in {@code entries}, using the previously
 * configured separator and key-value separator, to {@code appendable}.
 *
 * @since 11.0
 */
@Beta
@CanIgnoreReturnValue
public <A extends Appendable> A appendTo(A appendable, Iterator<? extends Entry<?, ?>> parts)
    throws IOException {
  checkNotNull(appendable);
  if (parts.hasNext()) {
    Entry<?, ?> entry = parts.next();
    appendable.append(joiner.toString(entry.getKey()));
    appendable.append(keyValueSeparator);
    appendable.append(joiner.toString(entry.getValue()));
    while (parts.hasNext()) {
      appendable.append(joiner.separator);
      Entry<?, ?> e = parts.next();
      appendable.append(joiner.toString(e.getKey()));
      appendable.append(keyValueSeparator);
      appendable.append(joiner.toString(e.getValue()));
    }
  }
  return appendable;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:27,代码来源:Joiner.java

示例6: put

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * Adds the given {@code cell} to the table, making it immutable if
 * necessary. Duplicate key pairs are not allowed and will cause {@link
 * #build} to fail.
 */
@CanIgnoreReturnValue
public Builder<R, C, V> put(Cell<? extends R, ? extends C, ? extends V> cell) {
  if (cell instanceof Tables.ImmutableCell) {
    checkNotNull(cell.getRowKey());
    checkNotNull(cell.getColumnKey());
    checkNotNull(cell.getValue());
    @SuppressWarnings("unchecked") // all supported methods are covariant
    Cell<R, C, V> immutableCell = (Cell<R, C, V>) cell;
    cells.add(immutableCell);
  } else {
    put(cell.getRowKey(), cell.getColumnKey(), cell.getValue());
  }
  return this;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:20,代码来源:ImmutableTable.java

示例7: get

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * <p>The default {@link AbstractFuture} implementation throws {@code InterruptedException} if the
 * current thread is interrupted before or during the call, even if the value is already
 * available.
 *
 * @throws InterruptedException if the current thread was interrupted before or during the call
 *     (optional but recommended).
 * @throws CancellationException {@inheritDoc}
 */
@CanIgnoreReturnValue
@Override
public V get() throws InterruptedException, ExecutionException {
  if (Thread.interrupted()) {
    throw new InterruptedException();
  }
  Object localValue = value;
  if (localValue != null & !(localValue instanceof SetFuture)) {
    return getDoneValue(localValue);
  }
  Waiter oldHead = waiters;
  if (oldHead != Waiter.TOMBSTONE) {
    Waiter node = new Waiter();
    do {
      node.setNext(oldHead);
      if (ATOMIC_HELPER.casWaiters(this, oldHead, node)) {
        // we are on the stack, now wait for completion.
        while (true) {
          LockSupport.park(this);
          // Check interruption first, if we woke up due to interruption we need to honor that.
          if (Thread.interrupted()) {
            removeWaiter(node);
            throw new InterruptedException();
          }
          // Otherwise re-read and check doneness. If we loop then it must have been a spurious
          // wakeup
          localValue = value;
          if (localValue != null & !(localValue instanceof SetFuture)) {
            return getDoneValue(localValue);
          }
        }
      }
      oldHead = waiters; // re-read and loop.
    } while (oldHead != Waiter.TOMBSTONE);
  }
  // re-read value, if we get here then we must have observed a TOMBSTONE while trying to add a
  // waiter.
  return getDoneValue(value);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:51,代码来源:AbstractFuture.java

示例8: copyInto

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * Copies all the elements from this fluent iterable to {@code collection}. This is equivalent to
 * calling {@code Iterables.addAll(collection, this)}.
 *
 * <p><b>{@code Stream} equivalent:</b> {@code stream.forEachOrdered(collection::add)} or
 * {@code stream.forEach(collection::add)}.
 *
 * @param collection the collection to copy elements to
 * @return {@code collection}, for convenience
 * @since 14.0
 */
@CanIgnoreReturnValue
public final <C extends Collection<? super E>> C copyInto(C collection) {
  checkNotNull(collection);
  Iterable<E> iterable = getDelegate();
  if (iterable instanceof Collection) {
    collection.addAll(Collections2.cast(iterable));
  } else {
    for (E item : iterable) {
      collection.add(item);
    }
  }
  return collection;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:25,代码来源:FluentIterable.java

示例9: put

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * Associates the specified range with the specified value.
 *
 * @throws IllegalArgumentException if {@code range} is empty
 */
@CanIgnoreReturnValue
public Builder<K, V> put(Range<K> range, V value) {
  checkNotNull(range);
  checkNotNull(value);
  checkArgument(!range.isEmpty(), "Range must not be empty, but was %s", range);
  entries.add(Maps.immutableEntry(range, value));
  return this;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:14,代码来源:ImmutableRangeMap.java

示例10: readUnsignedShort

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * Reads an unsigned {@code short} as specified by {@link DataInputStream#readUnsignedShort()},
 * except using little-endian byte order.
 *
 * @return the next two bytes of the input stream, interpreted as an unsigned 16-bit integer in
 *     little-endian byte order
 * @throws IOException if an I/O error occurs
 */
@CanIgnoreReturnValue // to skip some bytes
@Override
public int readUnsignedShort() throws IOException {
  byte b1 = readAndCheckByte();
  byte b2 = readAndCheckByte();

  return Ints.fromBytes((byte) 0, (byte) 0, b2, b1);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:17,代码来源:LittleEndianDataInputStream.java

示例11: add

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * Guaranteed to throw an exception and leave the collection unmodified.
 *
 * @throws UnsupportedOperationException always
 * @deprecated Unsupported operation.
 */
@CanIgnoreReturnValue
@Deprecated
@Override
public final boolean add(E e) {
  throw new UnsupportedOperationException();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:13,代码来源:ImmutableCollection.java

示例12: addEscape

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:12,代码来源:CharEscaperBuilder.java

示例13: checkNotNull

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * Ensures that an object reference passed as a parameter to the calling method is not null.
 *
 * <p>See {@link #checkNotNull(Object, String, Object...)} for details.
 */
@CanIgnoreReturnValue
public static <T> T checkNotNull(
    T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, @Nullable Object p2) {
  if (obj == null) {
    throw new NullPointerException(format(errorMessageTemplate, p1, p2));
  }
  return obj;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:14,代码来源:Preconditions.java

示例14: putAll

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * Adds all of the given entries to the built map.  Duplicate keys are not
 * allowed, and will cause {@link #build} to fail.
 *
 * @throws NullPointerException if any key, value, or entry is null
 * @since 19.0
 */
@CanIgnoreReturnValue
@Beta
public Builder<K, V> putAll(Iterable<? extends Entry<? extends K, ? extends V>> entries) {
  if (entries instanceof Collection) {
    ensureCapacity(size + ((Collection<?>) entries).size());
  }
  for (Entry<? extends K, ? extends V> entry : entries) {
    put(entry);
  }
  return this;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:19,代码来源:ImmutableMap.java

示例15: pollLastEntry

import com.google.errorprone.annotations.CanIgnoreReturnValue; //导入依赖的package包/类
/**
 * Guaranteed to throw an exception and leave the map unmodified.
 *
 * @throws UnsupportedOperationException always
 * @deprecated Unsupported operation.
 */
@CanIgnoreReturnValue
@Deprecated
@Override
public final Entry<K, V> pollLastEntry() {
  throw new UnsupportedOperationException();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:13,代码来源:ImmutableSortedMap.java


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