List of usage examples for com.google.common.base Preconditions checkNotNull
public static <T> T checkNotNull(T reference)
From source file:org.duniter.elasticsearch.model.Movements.java
public static Stream<Movement> stream(final BlockchainBlock block) { Preconditions.checkNotNull(block); // No Tx/* w w w . j a v a2 s.c o m*/ if (CollectionUtils.isEmpty(block.getTransactions())) { return Stream.empty(); } return Arrays.stream(block.getTransactions()).flatMap(tx -> Movements.streamFromTx(block, tx)); }
From source file:com.gradleware.tooling.toolingmodel.buildaction.BuildActionFactory.java
/** * Creates a new {@code ModelForSingleProjectBuildAction} that fetches the given model for the given project path. * * @param projectPath the path of the project for which to fetch the model * @param modelType the model to fetch//from w w w . ja v a 2 s.c o m * @param <T> the model type * @return the build action */ public static <T> ModelForSingleProjectBuildAction<T> getModelForProject(String projectPath, Class<T> modelType) { Preconditions.checkNotNull(projectPath); Preconditions.checkNotNull(modelType); return new ModelForSingleProjectBuildAction<T>(projectPath, modelType); }
From source file:org.apache.james.mailbox.store.mail.model.impl.Cid.java
public static Cid from(String cidAsString) { Preconditions.checkNotNull(cidAsString); Preconditions.checkArgument(!cidAsString.isEmpty(), "'cidAsString' is mandatory"); return new Cid(normalizedCid(cidAsString)); }
From source file:edu.byu.nlp.math.optimize.ConvergenceCheckers.java
public static ConvergenceChecker and(final ConvergenceChecker a, final ConvergenceChecker b) { Preconditions.checkNotNull(a); Preconditions.checkNotNull(b);/* w ww .j a v a 2 s.c o m*/ return new ConvergenceChecker() { @Override public boolean isConverged(int iteration, double prev, double cur) { return a.isConverged(iteration, prev, cur) && b.isConverged(iteration, prev, cur); } }; }
From source file:com.palantir.atlasdb.table.description.IndexComponent.java
/** * This takes an existing row component and uses it in the index. *//* w w w .j av a 2s . co m*/ public static IndexComponent createFromRow(NameComponentDescription rowKeyDesc, String rowComponentName) { return new IndexComponent(Preconditions.checkNotNull(rowKeyDesc), Preconditions.checkNotNull(rowComponentName), null, null, null, false); }
From source file:org.metaborg.intellij.utils.CollectionUtils.java
/** * Returns an immutable list with the elements in the iterable. * * @param iterable The iterable.//from ww w .j av a 2 s . c om * @param <T> The type of elements. * @return An immutable list. */ public static <T> List<T> toList(final Iterable<? extends T> iterable) { Preconditions.checkNotNull(iterable); return Collections.unmodifiableList(toMutableList(iterable)); }
From source file:com.palantir.atlasdb.keyvalue.partition.map.InMemoryPartitionMapService.java
public static InMemoryPartitionMapService create(DynamicPartitionMap partitionMap) { return new InMemoryPartitionMapService(Preconditions.checkNotNull(partitionMap)); }
From source file:org.haiku.pkg.model.RawInlineAttribute.java
public RawInlineAttribute(AttributeId attributeId, byte[] rawValue) { super(attributeId); Preconditions.checkNotNull(rawValue); this.rawValue = rawValue; }
From source file:com.google.cloud.tools.appengine.cloudsdk.internal.FileUtil.java
/** * Implementation of recursive directory copy, does NOT overwrite * * @param source an existing source directory to copy from. * @param destination an existing destination directory to copy to. *//* w ww. j av a2 s . c o m*/ public static void copyDirectory(final Path source, final Path destination) throws IOException { Preconditions.checkNotNull(source); Preconditions.checkNotNull(destination); Preconditions.checkArgument(Files.isDirectory(source)); Preconditions.checkArgument(Files.isDirectory(destination)); Preconditions.checkArgument(!source.equals(destination)); Preconditions.checkArgument(!destination.startsWith(source), "destination is child of source"); Files.walkFileTree(source, new SimpleFileVisitor<Path>() { final CopyOption[] copyOptions = new CopyOption[] { StandardCopyOption.COPY_ATTRIBUTES }; @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { if (dir.equals(source)) { return FileVisitResult.CONTINUE; } Files.copy(dir, destination.resolve(source.relativize(dir)), copyOptions); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.copy(file, destination.resolve(source.relativize(file)), copyOptions); return FileVisitResult.CONTINUE; } }); }
From source file:com.google.copybara.util.console.LogConsole.java
/** * Creates a new instance of {@link LogConsole} with write capabilities, only. *///from w w w.j a va2 s. c o m public static LogConsole writeOnlyConsole(PrintStream output) { return new LogConsole(/*input*/ null, Preconditions.checkNotNull(output)); }