List of usage examples for com.google.common.base Preconditions checkArgument
public static void checkArgument(boolean expression, @Nullable Object errorMessage)
From source file:com.qcadoo.mes.materialFlowResources.constants.ProductsToUpdate.java
public static ProductsToUpdate of(final Entity entity) { Preconditions.checkArgument(entity != null, "Passed entity have to be non null"); return parseString(entity.getStringField(CostNormsGeneratorFields.PRODUCTS_TO_UPDATE)); }
From source file:com.dnanexus.DXProject.java
private static void checkProjectId(String projectId) { Preconditions.checkArgument(projectId.startsWith("project-"), "Project ID " + projectId + " must start with project-"); }
From source file:org.haiku.haikudepotserver.job.model.JobDataWithByteSink.java
public JobDataWithByteSink(JobData jobData, ByteSink byteSink) { Preconditions.checkArgument(null != jobData, "the job data must be supplied"); Preconditions.checkArgument(null != byteSink, "the byte sink must be supplied"); this.jobData = jobData; this.byteSink = byteSink; }
From source file:org.haiku.haikudepotserver.job.model.JobDataWithByteSource.java
public JobDataWithByteSource(JobData jobData, ByteSource byteSource) { Preconditions.checkArgument(null != jobData, "job data must be supplied"); Preconditions.checkArgument(null != byteSource, "byte source must be supplied"); this.jobData = jobData; this.byteSource = byteSource; }
From source file:eu.interedition.text.util.Database.java
public static JdbcConnectionPool h2(File directory) { Preconditions.checkArgument(directory.isDirectory() || directory.mkdirs(), directory); return h2(new File(directory, "texts").getPath() + ";DB_CLOSE_DELAY=10;CACHE_SIZE=131072"); }
From source file:org.tensorics.core.function.MathFunctions.java
public static <X, Y> Tensor<DiscreteFunction<X, Y>> functionsFrom(Tensor<Y> tensor, Class<X> dimensionClass) { Preconditions.checkArgument(tensor.shape().dimensionality() >= 1, "tensor must contain at least one dimension"); return Tensorics.from(tensor).reduce(dimensionClass).by(new ToFunctions<>()); }
From source file:org.apache.james.util.streams.JamesCollectors.java
public static <D> Collector<D, ?, Map<Integer, List<D>>> chunker(int chunkSize) { Preconditions.checkArgument(chunkSize > 0, "ChunkSize should be strictly positive"); AtomicInteger counter = new AtomicInteger(-1); return Collectors.groupingBy(x -> counter.incrementAndGet() / chunkSize); }
From source file:net.minecrell.serverlistplus.canary.CanaryFavicon.java
public static String create(BufferedImage image) { Preconditions.checkArgument(image.getWidth() == 64 && image.getHeight() == 64, "Invalid favicon bounds"); byte[] buf;/*from w ww .ja v a2s. c om*/ try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { ImageIO.write(image, "PNG", out); buf = out.toByteArray(); } catch (IOException e) { throw new AssertionError(e); } return "data:image/png;base64," + BaseEncoding.base64().encode(buf); }
From source file:org.sonar.core.measure.db.MeasureKey.java
public static MeasureKey of(String componentKey, String metricKey) { Preconditions.checkArgument(!Strings.isNullOrEmpty(componentKey), "Component key must be set"); Preconditions.checkArgument(!Strings.isNullOrEmpty(metricKey), "Metric key must be set"); return new MeasureKey(componentKey, metricKey); }
From source file:io.druid.segment.data.RangeIndexedInts.java
public static RangeIndexedInts create(final int size) { Preconditions.checkArgument(size >= 0, "size >= 0"); if (size < CACHE_LIMIT) { return CACHE[size]; } else {/*from w w w . j a va 2 s .c om*/ return new RangeIndexedInts(size); } }