org.immutables.value.Value Java Examples

The following examples show how to use org.immutables.value.Value. 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: ErrorLogRecord.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Computes a category key based on relevant LogRecord information. If an exception is present,
 * categorizes on the class + method that threw it. If no exception is found, categorizes on the
 * logger name and the beginning of the message.
 */
@Value.Default
public String getCategory() {
  String logger = "";
  if (getRecord().getLoggerName() != null) {
    logger = getRecord().getLoggerName();
  }
  StringBuilder sb = new StringBuilder(logger).append(":");
  Throwable throwable = getRecord().getThrown();
  if (throwable != null) {
    Throwable originalThrowable = getInitialCause(throwable);
    if (originalThrowable.getStackTrace().length > 0) {
      sb.append(extractClassMethod(getThrowableOrigin(originalThrowable)));
      return sb.toString();
    }
  }
  sb.append(truncateMessage(getRecord().getMessage()));
  return sb.toString();
}
 
Example #2
Source File: IjLibrary.java    From buck with Apache License 2.0 6 votes vote down vote up
@Value.Check
protected void eitherBinaryJarOrClassPathPresent() {
  if (getType() == Type.DEFAULT) {
    // IntelliJ library should have a binary jar or classpath, but we also allow it to have an
    // optional res folder so that resources can be loaded properly.
    boolean hasClasspathsWithoutRes =
        getClassPaths().stream().anyMatch(input -> !input.endsWith("res"));

    Preconditions.checkArgument(!getBinaryJars().isEmpty() ^ hasClasspathsWithoutRes);
  } else if (getType() == Type.KOTLIN_JAVA_RUNTIME) {
    // KotlinJavaRuntime is not generated from a target and it depends on an external template
    // file so all those properties should be empty
    Preconditions.checkArgument(getTargets().isEmpty());
    Preconditions.checkArgument(getBinaryJars().isEmpty());
    Preconditions.checkArgument(getClassPaths().isEmpty());
    Preconditions.checkArgument(getSourceJars().isEmpty());
    Preconditions.checkArgument(getJavadocUrls().isEmpty());
    Preconditions.checkArgument(getSourceJars().isEmpty());
  }
}
 
Example #3
Source File: Constitution.java    From immutables with Apache License 2.0 5 votes vote down vote up
@Value.Lazy
public NameForms typeEnclosing() {
  String name = protoclass().kind().isDefinedValue()
      ? names().typeImmutable
      : names().typeImmutableEnclosing();

  return ImmutableConstitution.NameForms.builder()
      .simple(name)
      .relativeRaw(name)
      .packageOf(implementationPackage())
      .visibility(implementationEnclosingVisibility())
      .build();
}
 
Example #4
Source File: _CorpusQueryAssessments.java    From tac-kbp-eal with MIT License 5 votes vote down vote up
@Value.Check
protected void check() {
  checkArgument(queryReponses().containsAll(metadata().keySet()),
      "Metadata contained an unknown query; error in constructing the store!");
  checkArgument(queryReponses().containsAll(assessments().keySet()),
      "Assessments contained an unknown query; error in constructing the store!");
  checkArgument(queryReponses().equals(queryResponsesToSystemIDs().keySet()));
  final Iterable<String> systemIDStrings = transform(queryResponsesToSystemIDs().values(),
      desymbolizeFunction());
  checkArgument(all(systemIDStrings, not(isEmpty())), "System IDs may not be empty");
  checkArgument(all(systemIDStrings, not(anyCharMatches(CharMatcher.WHITESPACE))),
      "System IDs may not contain whitespace");
}
 
Example #5
Source File: PluginConfig.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private static boolean isValidType(PluginProperty.Value.ValCase valueType,
        PropertyType targetType) {
    switch (targetType) {
        case BOOLEAN:
            return valueType == ValCase.BVAL;
        case STRING:
            return valueType == ValCase.SVAL;
        case DOUBLE:
            return valueType == ValCase.DVAL || valueType == ValCase.DVAL_NULL;
        case LIST:
            return valueType == ValCase.LVAL;
        default:
            throw new AssertionError("Unexpected property type: " + targetType);
    }
}
 
Example #6
Source File: ParserConfig.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * @return a syntax to assume for build files without explicit build file syntax marker. *
 *     <p>For a list of supported syntax see {@link Syntax}.
 */
@Value.Lazy
public Syntax getDefaultBuildFileSyntax() {
  return getDelegate()
      .getEnum("parser", "default_build_file_syntax", Syntax.class)
      .orElse(Syntax.PYTHON_DSL);
}
 
Example #7
Source File: ErrorLogRecord.java    From buck with Apache License 2.0 5 votes vote down vote up
@Value.Derived
public Optional<String> getInitialErrorMsg() {
  Throwable throwable = getRecord().getThrown();
  if (throwable != null) {
    return Optional.ofNullable(getInitialCause(throwable).getLocalizedMessage());
  }
  return Optional.empty();
}
 
Example #8
Source File: GsonMessageBodyProvider.java    From immutables with Apache License 2.0 5 votes vote down vote up
/**
 * the fully configured gson instance.
 * @return the gson instanse
 */
@Value.Default
public Gson gson() {
  GsonBuilder gsonBuilder = new GsonBuilder();
  for (TypeAdapterFactory factory : ServiceLoader.load(TypeAdapterFactory.class)) {
    gsonBuilder.registerTypeAdapterFactory(factory);
  }
  return gsonBuilder.create();
}
 
Example #9
Source File: Attachment.java    From roboslack with Apache License 2.0 5 votes vote down vote up
/**
 * The {@link Footer} for this {@link Attachment}. This will appear below the body of the main message
 * {@link Attachment} in smaller, grayed-out text.
 *
 * @return an {@link Optional} containing the {@link Footer}
 */
@Value.Default
@Nullable
@JsonUnwrapped
public Footer footer() {
    return null;
}
 
Example #10
Source File: CxxConstructorArg.java    From buck with Apache License 2.0 5 votes vote down vote up
/** @return C/C++ deps which are *not* propagated to dependents. */
@Value.Derived
default CxxDeps getPrivateCxxDeps() {
  return CxxDeps.builder()
      .addDeps(getDeps())
      .addPlatformDeps(getPlatformDeps())
      .addDep(getPrecompiledHeader())
      .build();
}
 
Example #11
Source File: Constitution.java    From immutables with Apache License 2.0 5 votes vote down vote up
@Value.Lazy
public NameForms typeModifiable() {
  checkState(protoclass().kind().isModifiable());
  String simple = names().typeModifiable();
  return ImmutableConstitution.NameForms.builder()
      .simple(simple)
      .relativeRaw(inPackage(simple))
      .genericArgs(generics().args())
      .packageOf(implementationPackage())
      .visibility(implementationVisibility())
      .build();
}
 
Example #12
Source File: ParserConfig.java    From buck with Apache License 2.0 5 votes vote down vote up
/** @return the type of the glob handler used by the Skylark parser. */
@Value.Lazy
public SkylarkGlobHandler getSkylarkGlobHandler() {
  return getDelegate()
      .getEnum("parser", "skylark_glob_handler", SkylarkGlobHandler.class)
      .orElse(SkylarkGlobHandler.JAVA);
}
 
Example #13
Source File: BuckPaths.java    From buck with Apache License 2.0 4 votes vote down vote up
@Value.Derived
public Path getXcodeDir() {
  return getBuckOut().resolve("xcode");
}
 
Example #14
Source File: ServerSummaryStatistics.java    From waltz with Apache License 2.0 4 votes vote down vote up
@Value.Default
public long totalCount() {
    return virtualCount() + physicalCount();
}
 
Example #15
Source File: DockerComposeManager.java    From docker-compose-rule with Apache License 2.0 4 votes vote down vote up
@Value.Default
public ProjectName projectName() {
    return ProjectName.random();
}
 
Example #16
Source File: ConstructorArgMarshallerImmutableTest.java    From buck with Apache License 2.0 4 votes vote down vote up
@Value.Default
public Boolean getBeGood() {
  return true;
}
 
Example #17
Source File: State.java    From slide with MIT License 4 votes vote down vote up
@Value.Lazy
public List<Slide> slides() {
    return Slide.parse(text());
}
 
Example #18
Source File: SafeDerivedInit.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Value.Default
default int a() {
  return 1;
}
 
Example #19
Source File: LogicalDataElement.java    From waltz with Apache License 2.0 4 votes vote down vote up
@Value.Default
public EntityKind kind() { return EntityKind.LOGICAL_DATA_ELEMENT; }
 
Example #20
Source File: CentralStorageConfig.java    From glowroot with Apache License 2.0 4 votes vote down vote up
@Override
@Value.Default
public ImmutableList<Integer> profileRollupExpirationHours() {
    return DEFAULT_DETAIL_ROLLUP_EXPIRATION_HOURS;
}
 
Example #21
Source File: StyleInfo.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Value.Parameter
@Override
public abstract boolean finalInstanceFields();
 
Example #22
Source File: OtherType.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Value.Parameter
SetMultimap<Integer, Hjk> setMultimap();
 
Example #23
Source File: PrebuiltOcamlLibraryDescription.java    From buck with Apache License 2.0 4 votes vote down vote up
@Value.Default
String getLibName() {
  return getName();
}
 
Example #24
Source File: ProjectGeneratorOptions.java    From buck with Apache License 2.0 4 votes vote down vote up
/** Generate read-only project files */
@Value.Default
default boolean shouldGenerateReadOnlyFiles() {
  return false;
}
 
Example #25
Source File: AbstractLeg.java    From activator-lagom-cargotracker with Apache License 2.0 4 votes vote down vote up
@Value.Parameter
String getCargoId();
 
Example #26
Source File: AndroidBundleDescription.java    From buck with Apache License 2.0 4 votes vote down vote up
@Value.Default
boolean getRedex() {
  return false;
}
 
Example #27
Source File: LogConfigSetup.java    From buck with Apache License 2.0 4 votes vote down vote up
@Value.Default
public long getMaxLogSizeBytes() {
  return DEFAULT_MAX_LOG_SIZE_BYTES;
}
 
Example #28
Source File: AuthoritativeSource.java    From waltz with Apache License 2.0 4 votes vote down vote up
@Value.Default
public String provenance() {
    return "waltz";
}
 
Example #29
Source File: OrderAttributeValue.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Value.ReverseOrder
public abstract SortedMultiset<String> reverseMultiset();
 
Example #30
Source File: RetryPolicy.java    From buck with Apache License 2.0 4 votes vote down vote up
@Value.Default
public Backoff.Strategy getBackoffStrategy() {
  return Backoff.constant(0);
}