List of usage examples for com.google.common.base Preconditions checkState
public static void checkState(boolean expression, @Nullable Object errorMessage)
From source file:com.google.cloud.tools.eclipse.appengine.facets.NonSystemJobSuspender.java
public static void resume() { Preconditions.checkState(suspended.get(), "Not suspended."); resumeInternal(); }
From source file:com.nesscomputing.jms.JsonProducerCallback.java
@Override @CheckForNull/*from w w w. j av a 2s .co m*/ public Message buildMessage(final AbstractProducer<Object> producer, final Object data) throws IOException, JMSException { Preconditions.checkState(mapper != null, "need object mapper configured!"); final TextMessage message = producer.createTextMessage(); if (message == null) { throw new JMSException("Could not create text message, not connected?"); } else { final String dataText = mapper.writeValueAsString(data); message.setText(dataText); return message; } }
From source file:com.facebook.buck.zip.CustomZipOutputStream.java
public final void putNextEntry(ZipEntry entry) throws IOException { Preconditions.checkState(state != State.CLOSED, "Stream has been closed."); Preconditions.checkNotNull(entry);// ww w. jav a2 s . c o m state = State.OPEN; closeEntry(); actuallyPutNextEntry(entry); entryOpen = true; }
From source file:co.cask.cdap.logging.KafkaTestBase.java
private static Properties generateKafkaConfig() throws IOException { int port = Networks.getRandomPort(); Preconditions.checkState(port > 0, "Failed to get random port."); Properties prop = new Properties(); prop.setProperty("broker.id", "1"); prop.setProperty("port", Integer.toString(port)); prop.setProperty("num.network.threads", "2"); prop.setProperty("num.io.threads", "2"); prop.setProperty("socket.send.buffer.bytes", "1048576"); prop.setProperty("socket.receive.buffer.bytes", "1048576"); prop.setProperty("socket.request.max.bytes", "104857600"); prop.setProperty("log.dir", tmpFolder.newFolder().getAbsolutePath()); prop.setProperty("num.partitions", "2"); prop.setProperty("log.flush.interval.messages", "10000"); prop.setProperty("log.flush.interval.ms", "1000"); prop.setProperty("log.retention.hours", "1"); prop.setProperty("log.segment.bytes", "536870912"); prop.setProperty("log.cleanup.interval.mins", "1"); prop.setProperty("zookeeper.connect", zkServer.getConnectionStr()); prop.setProperty("zookeeper.connection.timeout.ms", "1000000"); return prop;/*from w w w .j a v a 2 s .co m*/ }
From source file:com.google.devtools.build.lib.profiler.output.TextPrinter.java
/** * Decrease indentation level/*from w w w .j a v a 2s. c o m*/ */ protected void up() { Preconditions.checkState(indent.length() >= INDENT.length(), "Cannot reduce indentation level, this/a previous call to up() is not matched by down()."); indent.setLength(indent.length() - INDENT.length()); }
From source file:org.apache.james.jwt.JwtConfiguration.java
public JwtConfiguration(Optional<String> jwtPublicKeyPem) { Preconditions.checkState(validPublicKey(jwtPublicKeyPem), "The provided public key is not valid"); this.jwtPublicKeyPem = jwtPublicKeyPem; }