Java Code Examples for org.immutables.value.Value#Check

The following examples show how to use org.immutables.value.Value#Check . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UrielConfiguration.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
@Value.Check
default void check() {
    if (getSubmissionConfig().getFs() instanceof AwsFsConfiguration && !getAwsConfig().isPresent()) {
        throw new IllegalStateException("aws config is required by submission config");
    }
    if (getFileConfig().getFs() instanceof AwsFsConfiguration && !getAwsConfig().isPresent()) {
        throw new IllegalStateException("aws config is required by file config");
    }
}
 
Example 2
Source File: MessageRequest.java    From roboslack with Apache License 2.0 5 votes vote down vote up
@Value.Check
final MessageRequest normalizedCopy() {
    if (iconEmoji().isPresent()) {
        if (iconEmoji().get().equals(SlackMarkdown.EMOJI.decorate(iconEmoji().get()))) {
            return this;
        }
        return builderClone().iconEmoji(SlackMarkdown.EMOJI.decorate(iconEmoji().get()))
                .build();
    }
    return this;
}
 
Example 3
Source File: CxxSourceRuleFactory.java    From buck with Apache License 2.0 5 votes vote down vote up
@Value.Check
protected void checkPrefixAndPrecompiledHeaderArgs() {
  if (getPrefixHeader().isPresent() && getPrecompiledHeader().isPresent()) {
    throw new HumanReadableException(
        "Cannot use `prefix_header` and `precompiled_header` in the same rule.");
  }
}
 
Example 4
Source File: Ids.java    From quilt with Apache License 2.0 5 votes vote down vote up
/**
 * Always normalize Link-type String values to full uppercase to avoid casing ambiguity in properties files.
 *
 * @return A Link type.
 */
@Value.Check
public _LinkType normalize() {
  final String linkTypeString = this.value();
  if (!linkTypeString.toUpperCase().equals(linkTypeString)) {
    return LinkType.of(linkTypeString.toUpperCase());
  } else {
    return this;
  }
}
 
Example 5
Source File: BuildLogEntry.java    From buck with Apache License 2.0 5 votes vote down vote up
@Value.Check
default void pathIsRelative() {
  Preconditions.checkState(!getRelativePath().isAbsolute());
  if (getRuleKeyLoggerLogFile().isPresent()) {
    Preconditions.checkState(!getRuleKeyLoggerLogFile().get().isAbsolute());
  }
  if (getTraceFile().isPresent()) {
    Preconditions.checkState(!getTraceFile().get().isAbsolute());
  }
}
 
Example 6
Source File: Revision.java    From digdag with Apache License 2.0 5 votes vote down vote up
@Value.Check
protected void check()
{
    ModelValidator.builder()
        .checkIdentifierName("name", getName())
        .validate("revision", this);
}
 
Example 7
Source File: _Response.java    From tac-kbp-eal with MIT License 5 votes vote down vote up
@Value.Check
protected void check() {
  checkArgument(!docID().asString().isEmpty(), "Document ID may not be empty for a response");
  checkArgument(!type().asString().isEmpty(), "Event type may not be empty for a response");
  checkArgument(!role().asString().isEmpty(), "Argument role may not be empty for a response");
  checkPredicateJustificationsContainsBaseFiller();
  checkArgument(!predicateJustifications().isEmpty(), "Predicate justifications may not be empty");
}
 
Example 8
Source File: FakeClock.java    From buck with Apache License 2.0 5 votes vote down vote up
@Value.Check
protected void checkNanoTimeIsNotDerivedFromCurrentTimeMillis() {
  // Being a little overly conservative here given the method name, but really nano time should
  // never be anywhere near currentTimeMillis so it's OK.
  Preconditions.checkState(
      Math.abs(TimeUnit.NANOSECONDS.toMillis(nanoTime()) - currentTimeMillis()) > 1);
}
 
Example 9
Source File: GroupedSource.java    From buck with Apache License 2.0 5 votes vote down vote up
@Value.Check
protected void check() {
  switch (getType()) {
    case SOURCE_WITH_FLAGS:
      Preconditions.checkArgument(getSourceWithFlags().isPresent());
      Preconditions.checkArgument(!getSourcePath().isPresent());
      Preconditions.checkArgument(!getSourceGroupName().isPresent());
      Preconditions.checkArgument(!getSourceGroupPathRelativeToTarget().isPresent());
      Preconditions.checkArgument(!getSourceGroup().isPresent());
      break;
    case IGNORED_SOURCE:
    case PUBLIC_HEADER:
    case PRIVATE_HEADER:
      Preconditions.checkArgument(!getSourceWithFlags().isPresent());
      Preconditions.checkArgument(getSourcePath().isPresent());
      Preconditions.checkArgument(!getSourceGroupName().isPresent());
      Preconditions.checkArgument(!getSourceGroupPathRelativeToTarget().isPresent());
      Preconditions.checkArgument(!getSourceGroup().isPresent());
      break;
    case SOURCE_GROUP:
      Preconditions.checkArgument(!getSourceWithFlags().isPresent());
      Preconditions.checkArgument(!getSourcePath().isPresent());
      Preconditions.checkArgument(getSourceGroupName().isPresent());
      Preconditions.checkArgument(getSourceGroupPathRelativeToTarget().isPresent());
      Preconditions.checkArgument(getSourceGroup().isPresent());
      break;
    default:
      throw new RuntimeException("Unhandled type: " + getType());
  }
}
 
Example 10
Source File: EmrOperatorFactory.java    From digdag with Apache License 2.0 5 votes vote down vote up
@Value.Check
default void validate()
{
    if (type() == DIRECT) {
        Preconditions.checkArgument(!reference().isPresent());
        Preconditions.checkArgument(contents().isPresent());
    }
    else {
        Preconditions.checkArgument(reference().isPresent());
        Preconditions.checkArgument(!contents().isPresent());
    }
}
 
Example 11
Source File: NativeLinkTargetMode.java    From buck with Apache License 2.0 4 votes vote down vote up
@Value.Check
public void check() {
  Preconditions.checkState(
      getType() == Linker.LinkType.SHARED || getType() == Linker.LinkType.EXECUTABLE);
  Preconditions.checkState(!getLibraryName().isPresent() || getType() == Linker.LinkType.SHARED);
}
 
Example 12
Source File: DefaultJavaLibraryRules.java    From buck with Apache License 2.0 4 votes vote down vote up
@Value.Check
void validateResources() {
  ResourceValidator.validateResources(
      getSourcePathResolver(), getProjectFilesystem(), getResources());
}
 
Example 13
Source File: Color.java    From roboslack with Apache License 2.0 4 votes vote down vote up
@Value.Check
final Color normalize() {
    return value().toLowerCase().equals(value())
            ? this
            : of(value().toLowerCase());
}
 
Example 14
Source File: MultipleChecks.java    From immutables with Apache License 2.0 4 votes vote down vote up
default @Value.Check void checkA() {
  Preconditions.checkState(a() > 0);
}
 
Example 15
Source File: CorpusQuery2016.java    From tac-kbp-eal with MIT License 4 votes vote down vote up
@Value.Check
protected void check() {
  checkArgument(!id().asString().isEmpty(), "Query ID may not be empty");
  checkArgument(!id().asString().contains("\t"), "Query ID may not contain a tab");
  checkArgument(!entryPoints().isEmpty(), "Query may not lack entry points");
}
 
Example 16
Source File: AbstractValidate.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Value.Check
protected void check() {}
 
Example 17
Source File: UserFlavor.java    From buck with Apache License 2.0 4 votes vote down vote up
@Override
@Value.Check
public void check() {
  Flavor.super.check();
  Preconditions.checkArgument(!getDescription().isEmpty(), "Empty user flavor description");
}
 
Example 18
Source File: StringDecorator.java    From roboslack with Apache License 2.0 4 votes vote down vote up
@Value.Check
protected final void check() {
    MorePreconditions.checkAtLeastOnePresentAndValid(
            ImmutableList.of("prefix", "suffix"),
            ImmutableList.of(prefix(), suffix()));
}
 
Example 19
Source File: BuildPackagePathToUnconfiguredTargetNodePackageKey.java    From buck with Apache License 2.0 4 votes vote down vote up
@Value.Check
protected void check() {
  Preconditions.checkArgument(!getPath().isAbsolute());
}
 
Example 20
Source File: SlackDateTimeFormatter.java    From roboslack with Apache License 2.0 4 votes vote down vote up
@Value.Check
protected final void check() {
    checkArgument(!Strings.isNullOrEmpty(pattern()), PATTERN_EMPTY_ERR);
    checkArgument(MorePreconditions.containsDateTimeFormatTokens(pattern(), AT_LEAST_ONE), FORMAT_TOKENS_ERR);
}