@Override public void setMaxOutboundMessageSize(int maxSize) { checkState(maxOutboundMessageSize == NO_MAX_OUTBOUND_MESSAGE_SIZE, "max size already set"); maxOutboundMessageSize = maxSize; }
@Override public void addOutEdge(E edge, N node) { N previousNode = outEdgeMap.put(edge, node); checkState(previousNode == null); } }
@Override public void remove() { checkState(!hasPeeked, "Can't remove after you've peeked at next"); iterator.remove(); }
MapMaker setValueStrength(Strength strength) { checkState(valueStrength == null, "Value strength was already set to %s", valueStrength); valueStrength = checkNotNull(strength); if (strength != Strength.STRONG) { // STRONG could be used during deserialization. useCustomMap = true; } return this; }
String consumeToken(CharMatcher matcher) { int startPosition = position; String token = consumeTokenIfPresent(matcher); checkState(position != startPosition); return token; }
char consumeCharacter(char c) { checkState(hasMore()); checkState(previewChar() == c); position++; return c; }
@Override public final T loadBalancerFactory(LoadBalancer.Factory loadBalancerFactory) { Preconditions.checkState(directServerAddress == null, "directServerAddress is set (%s), which forbids the use of LoadBalancer.Factory", directServerAddress); if (loadBalancerFactory != null) { this.loadBalancerFactory = loadBalancerFactory; } else { this.loadBalancerFactory = DEFAULT_LOAD_BALANCER_FACTORY; } return thisT(); }
@Override @Deprecated public void setState(TaggingState state) { Preconditions.checkNotNull(state, "state"); Preconditions.checkState(!isRead, "State was already read, cannot set state."); } }
private void setDecompressorRegistry(DecompressorRegistry decompressorRegistry) { Preconditions.checkState(this.listener == null, "Already called start"); this.decompressorRegistry = checkNotNull(decompressorRegistry, "decompressorRegistry"); }
/** * Returns true when there is gzippedData that has not been input to the inflater or the inflater * has not consumed all of its input, or all data has been consumed but we are at not at the * boundary between gzip streams. */ boolean hasPartialData() { checkState(!closed, "GzipInflatingBuffer is closed"); return gzipMetadataReader.readableBytes() != 0 || state != State.HEADER; }
/** * Adds more gzipped data, which will be consumed only when needed to fulfill requests made via * {@link #inflateBytes}. */ void addGzippedBytes(ReadableBuffer buffer) { checkState(!closed, "GzipInflatingBuffer is closed"); gzippedData.addBuffer(buffer); isStalled = false; }
@Override public final boolean hasNext() { checkState(state != State.FAILED); switch (state) { case READY: return true; case DONE: return false; default: } return tryToComputeNext(); }
@Override void visitParameterizedType(ParameterizedType parameterizedType) { Class<?> rawClass = (Class<?>) parameterizedType.getRawType(); TypeVariable<?>[] vars = rawClass.getTypeParameters(); Type[] typeArgs = parameterizedType.getActualTypeArguments(); checkState(vars.length == typeArgs.length); for (int i = 0; i < vars.length; i++) { map(new TypeVariableKey(vars[i]), typeArgs[i]); } visit(rawClass); visit(parameterizedType.getOwnerType()); }
@VisibleForTesting void setListener(ServerStreamListener listener) { Preconditions.checkNotNull(listener, "listener must not be null"); Preconditions.checkState(this.listener == null, "Listener already set"); this.listener = listener; }
private AvlNode<E> rotateRight() { checkState(left != null); AvlNode<E> newTop = left; this.left = newTop.right; newTop.right = this; newTop.totalCount = this.totalCount; newTop.distinctElements = this.distinctElements; this.recompute(); newTop.recomputeHeight(); return newTop; }
@Override public void request(int numMessages) { checkState(stream != null, "Not started"); checkArgument(numMessages >= 0, "Number requested must be non-negative"); stream.request(numMessages); }
/** * Adds {@code node} to the graph and returns the associated {@link GraphConnections}. * * @throws IllegalStateException if {@code node} is already present */ @CanIgnoreReturnValue private GraphConnections<N, V> addNodeInternal(N node) { GraphConnections<N, V> connections = newConnections(); checkState(nodeConnections.put(node, connections) == null); return connections; }
@Override public N removeInEdge(E edge, boolean isSelfLoop) { N node = super.removeInEdge(edge, isSelfLoop); Multiset<N> predecessors = getReference(predecessorsReference); if (predecessors != null) { checkState(predecessors.remove(node)); } return node; }
@Override public void fail(Status status) { checkArgument(!status.isOk(), "Cannot fail with OK status"); checkState(!finalized, "apply() or fail() already called"); finalizeWith(new FailingClientStream(status)); }
@Override public void close(Status status, Metadata trailers) { checkState(!closeCalled, "call already closed"); closeCalled = true; if (status.isOk() && method.getType().serverSendsOneMessage() && !messageSent) { internalClose(Status.INTERNAL.withDescription(MISSING_RESPONSE)); return; } stream.close(status, trailers); }