import java.nio.ByteBuffer;
import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
/**
* Stores information about a {@link JournalSegment} of the log.
private final ByteBuffer buffer;
private Builder(ByteBuffer buffer) {
- this.buffer = checkNotNull(buffer, "buffer cannot be null");
+ this.buffer = requireNonNull(buffer, "buffer cannot be null");
buffer.putInt(VERSION_POSITION, VERSION);
}
import java.io.File;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
/**
* Segment file utility.
* @throws NullPointerException if {@code file} is null
*/
public static boolean isSegmentFile(String journalName, String fileName) {
- checkNotNull(journalName, "journalName cannot be null");
- checkNotNull(fileName, "fileName cannot be null");
+ requireNonNull(journalName, "journalName cannot be null");
+ requireNonNull(fileName, "fileName cannot be null");
int partSeparator = fileName.lastIndexOf(PART_SEPARATOR);
int extensionSeparator = fileName.lastIndexOf(EXTENSION_SEPARATOR);
* Creates a segment file for the given directory, log name, segment ID, and segment version.
*/
static File createSegmentFile(String name, File directory, long id) {
- return new File(directory, String.format("%s-%d.log", checkNotNull(name, "name cannot be null"), id));
+ return new File(directory, String.format("%s-%d.log", requireNonNull(name, "name cannot be null"), id));
}
/**
import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
/**
* Segmented journal.
int maxEntriesPerSegment,
double indexDensity,
boolean flushOnCommit) {
- this.name = checkNotNull(name, "name cannot be null");
- this.storageLevel = checkNotNull(storageLevel, "storageLevel cannot be null");
- this.directory = checkNotNull(directory, "directory cannot be null");
- this.namespace = checkNotNull(namespace, "namespace cannot be null");
+ this.name = requireNonNull(name, "name cannot be null");
+ this.storageLevel = requireNonNull(storageLevel, "storageLevel cannot be null");
+ this.directory = requireNonNull(directory, "directory cannot be null");
+ this.namespace = requireNonNull(namespace, "namespace cannot be null");
this.maxSegmentSize = maxSegmentSize;
this.maxEntrySize = maxEntrySize;
this.maxEntriesPerSegment = maxEntriesPerSegment;
* @return The storage builder.
*/
public Builder<E> withName(String name) {
- this.name = checkNotNull(name, "name cannot be null");
+ this.name = requireNonNull(name, "name cannot be null");
return this;
}
* @return The storage builder.
*/
public Builder<E> withStorageLevel(StorageLevel storageLevel) {
- this.storageLevel = checkNotNull(storageLevel, "storageLevel cannot be null");
+ this.storageLevel = requireNonNull(storageLevel, "storageLevel cannot be null");
return this;
}
* @throws NullPointerException If the {@code directory} is {@code null}
*/
public Builder<E> withDirectory(String directory) {
- return withDirectory(new File(checkNotNull(directory, "directory cannot be null")));
+ return withDirectory(new File(requireNonNull(directory, "directory cannot be null")));
}
/**
* @throws NullPointerException If the {@code directory} is {@code null}
*/
public Builder<E> withDirectory(File directory) {
- this.directory = checkNotNull(directory, "directory cannot be null");
+ this.directory = requireNonNull(directory, "directory cannot be null");
return this;
}
* @return The journal builder.
*/
public Builder<E> withNamespace(Namespace namespace) {
- this.namespace = checkNotNull(namespace, "namespace cannot be null");
+ this.namespace = requireNonNull(namespace, "namespace cannot be null");
return this;
}
import java.util.List;
import java.util.Objects;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import static org.slf4j.LoggerFactory.getLogger;
/**
* @return this
*/
public Builder register(Serializer<?> serializer, final Class<?>... classes) {
- types.add(Pair.of(classes, checkNotNull(serializer)));
+ types.add(Pair.of(classes, requireNonNull(serializer)));
return this;
}
this.registrationRequired = registrationRequired;
this.classLoader = classLoader;
this.compatible = compatible;
- this.friendlyName = checkNotNull(friendlyName);
+ this.friendlyName = requireNonNull(friendlyName);
}
/**