io.atomix.catalyst.util.Assert类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(76)

本文整理了Java中io.atomix.catalyst.util.Assert类的一些代码示例,展示了Assert类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert类的具体详情如下:
包路径:io.atomix.catalyst.util.Assert
类名称:Assert

Assert介绍

[英]Assertion utilities.
[中]断言实用程序。

代码示例

代码示例来源:origin: atomix/copycat

FileSnapshot(SnapshotFile file, SnapshotStore store) {
 super(store);
 this.file = Assert.notNull(file, "file");
 this.store = Assert.notNull(store, "store");
}

代码示例来源:origin: atomix/copycat

/**
 * Sets the last index of the replica's log.
 *
 * @param index The last index of the replica's log.
 * @return The append response builder.
 * @throws IllegalArgumentException if {@code index} is negative
 */
public Builder withLogIndex(long index) {
 response.logIndex = Assert.argNot(index, index < 0, "term must not be negative");
 return this;
}

代码示例来源:origin: atomix/copycat

/**
 * Sets the client session timeout.
 *
 * @param sessionTimeout The client's session timeout.
 * @return The client builder.
 * @throws NullPointerException if the session timeout is null
 * @throws IllegalArgumentException if the session timeout is not {@code -1} or positive
 */
public Builder withSessionTimeout(Duration sessionTimeout) {
 this.sessionTimeout = Assert.arg(Assert.notNull(sessionTimeout, "sessionTimeout"), sessionTimeout.toMillis() >= -1, "session timeout must be positive or -1");
 return this;
}

代码示例来源:origin: atomix/copycat

public Configuration(long index, long term, long time, Collection<Member> members) {
 this.index = index;
 this.term = term;
 this.time = Assert.argNot(time, time <= 0, "time must be positive");
 this.members = Assert.notNull(members, "members");
}

代码示例来源:origin: atomix/copycat

/**
  * @throws IllegalStateException if member is null
  */
 @Override
 public InstallRequest build() {
  super.build();
  Assert.stateNot(request.term <= 0, "term must be positive");
  Assert.argNot(request.index < 0, "index must be positive");
  Assert.notNull(request.data, "data");
  return request;
 }
}

代码示例来源:origin: atomix/copycat

/**
 * Opens the given snapshot writer.
 */
protected SnapshotWriter openWriter(SnapshotWriter writer, SnapshotDescriptor descriptor) {
 checkWriter();
 Assert.stateNot(descriptor.locked(), "cannot write to locked snapshot descriptor");
 this.writer = Assert.notNull(writer, "writer");
 return writer;
}

代码示例来源:origin: atomix/copycat

/**
 * Checks that the snapshot can be written.
 */
protected void checkWriter() {
 Assert.state(writer == null, "cannot create multiple writers for the same snapshot");
}

代码示例来源:origin: atomix/copycat

/**
 * Sets the last sequence number.
 *
 * @param lastSequence The last sequence number.
 * @return The command response builder.
 */
@SuppressWarnings("unchecked")
public T withLastSequence(long lastSequence) {
 response.lastSequence = Assert.arg(lastSequence, lastSequence >= 0, "lastSequence must be positive");
 return (T) this;
}

代码示例来源:origin: atomix/copycat

/**
 * @throws IllegalStateException if status is null
 */
@Override
public U build() {
 Assert.stateNot(response.status == null, "status cannot be null");
 return response;
}

代码示例来源:origin: io.atomix.catalyst/catalyst-common

/**
 * @throws IndexOutOfBoundsException when {@code expression} is false
 */
public static void indexNot(boolean expression, String errorMessageFormat, Object... args) {
 index(!expression, errorMessageFormat, args);
}

代码示例来源:origin: atomix/copycat

/**
  * @throws IllegalStateException if member is null
  */
 @Override
 public ConfigureRequest build() {
  super.build();
  Assert.stateNot(request.term <= 0, "term must be positive");
  Assert.argNot(request.index < 0, "index must be positive");
  Assert.notNull(request.members, "members");
  return request;
 }
}

代码示例来源:origin: atomix/copycat

/**
 * Sets the timeout after which suspended global replication will resume and force a partitioned follower
 * to truncate its log once the partition heals.
 *
 * @param globalSuspendTimeout The timeout after which to resume global replication.
 * @return The server builder.
 */
public Builder withGlobalSuspendTimeout(Duration globalSuspendTimeout) {
 Assert.notNull(globalSuspendTimeout, "globalSuspendTimeout");
 this.globalSuspendTimeout = Assert.argNot(globalSuspendTimeout, globalSuspendTimeout.isNegative() || globalSuspendTimeout.isZero(), "globalSuspendTimeout must be positive");
 return this;
}

代码示例来源:origin: atomix/copycat

/**
 * Asserts that the manager is open.
 * 
 * @throws IllegalStateException if the segment manager is not open
 */
private void assertOpen() {
 Assert.state(currentSegment != null, "segment manager not open");
}

代码示例来源:origin: atomix/copycat

/**
 * Sets the request term.
 *
 * @param term The request term.
 * @return The append request builder.
 * @throws IllegalArgumentException if the {@code term} is not positive
 */
public Builder withTerm(long term) {
 request.term = Assert.arg(term, term > 0, "term must be positive");
 return this;
}

代码示例来源:origin: atomix/copycat

/**
 * Returns the entry size.
 *
 * @return The entry size.
 * @throws IllegalStateException If the entry has not yet been persisted
 */
public int size() {
 Assert.stateNot(size == -1, "cannot determine size for non-persisted entry");
 return size;
}

代码示例来源:origin: atomix/copycat

/**
 * Asserts that the index is a valid index.
 *
 * @throws IndexOutOfBoundsException if the {@code index} is out of bounds
 */
private void assertValidIndex(long index) {
 Assert.index(validIndex(index), "invalid log index: %d", index);
}

代码示例来源:origin: atomix/copycat

SnapshotReader(Buffer buffer, Snapshot snapshot, Serializer serializer) {
 this.buffer = Assert.notNull(buffer, "buffer");
 this.snapshot = Assert.notNull(snapshot, "snapshot");
 this.serializer = Assert.notNull(serializer, "serializer");
}

代码示例来源:origin: io.atomix.copycat/copycat-server

/**
  * @throws IllegalStateException if member is null
  */
 @Override
 public InstallRequest build() {
  super.build();
  Assert.stateNot(request.term <= 0, "term must be positive");
  Assert.argNot(request.index < 0, "index must be positive");
  Assert.notNull(request.data, "data");
  return request;
 }
}

代码示例来源:origin: io.atomix.copycat/copycat-client

/**
 * Sets the client session timeout.
 *
 * @param sessionTimeout The client's session timeout.
 * @return The client builder.
 * @throws NullPointerException if the session timeout is null
 * @throws IllegalArgumentException if the session timeout is not {@code -1} or positive
 */
public Builder withSessionTimeout(Duration sessionTimeout) {
 this.sessionTimeout = Assert.arg(Assert.notNull(sessionTimeout, "sessionTimeout"), sessionTimeout.toMillis() >= -1, "session timeout must be positive or -1");
 return this;
}

代码示例来源:origin: atomix/copycat

/**
 * Sets the request sequence number.
 *
 * @param sequence The request sequence number.
 * @return The request builder.
 * @throws IllegalArgumentException If the request sequence number is not positive.
 */
@SuppressWarnings("unchecked")
public T withSequence(long sequence) {
 request.sequence = Assert.argNot(sequence, sequence < 0, "sequence must be positive");
 return (T) this;
}

相关文章