Java Code Examples for org.immutables.value.Value

The following examples show how to use org.immutables.value.Value. These examples are extracted from open source projects. 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 Project: buck   Source File: ErrorLogRecord.java    License: 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 Project: buck   Source File: IjLibrary.java    License: 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 Project: buck   Source File: ParserConfig.java    License: 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 4
Source Project: roboslack   Source File: Attachment.java    License: 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 5
Source Project: immutables   Source File: Constitution.java    License: 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 6
Source Project: immutables   Source File: Constitution.java    License: 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 7
Source Project: tac-kbp-eal   Source File: _CorpusQueryAssessments.java    License: 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 8
Source Project: buck   Source File: CxxConstructorArg.java    License: 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 9
Source Project: immutables   Source File: GsonMessageBodyProvider.java    License: 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 10
Source Project: buck   Source File: ErrorLogRecord.java    License: 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 11
Source Project: buck   Source File: ParserConfig.java    License: 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 12
Source Project: glowroot   Source File: PluginConfig.java    License: 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 13
Source Project: buck   Source File: CxxSymlinkTreeHeaders.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Auxiliary
@CustomFieldBehavior(NameToPathMapInputsBehavior.class)
public abstract ImmutableSortedMap<Path, SourcePath> getNameToPathMap();
 
Example 14
Source Project: Fluxxan   Source File: Todo.java    License: MIT License 4 votes vote down vote up
@Value
public abstract String getUid();
 
Example 15
Source Project: buck   Source File: ActionGraphConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Derived
public Map<IncrementalActionGraphMode, Double> getIncrementalActionGraphExperimentGroups() {
  return getDelegate()
      .getExperimentGroups(
          "cache", "incremental_action_graph_experiment", IncrementalActionGraphMode.class);
}
 
Example 16
Source Project: immutables   Source File: NullAsDefault.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Default
public int a() {
  return -1;
}
 
Example 17
Source Project: cf-java-client-sap   Source File: CloudRoute.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Default
public boolean hasServiceUsingRoute() {
    return false;
}
 
Example 18
Source Project: glowroot   Source File: RoleConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Derived
@JsonIgnore
public String version() {
    return Versions.getJsonVersion(this);
}
 
Example 19
Source Project: immutables   Source File: PrimitiveArrays.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Parameter
char[] chars();
 
Example 20
Source Project: buck   Source File: CxxConstructorArg.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Default
default PatternMatchedCollection<ImmutableList<StringWithMacros>> getPlatformCompilerFlags() {
  return PatternMatchedCollection.of();
}
 
Example 21
@Value.Parameter
public abstract Resource<UnionServiceInstanceEntity> getResource();
 
Example 22
Source Project: immutables   Source File: PrimitiveOptionals.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Parameter
Optional<Integer> v1();
 
Example 23
Source Project: camel-k-runtime   Source File: RuntimeSpec.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Default
default Set<MavenArtifact> getDependencies() {
    return Collections.emptySet();
}
 
Example 24
Source Project: roboslack   Source File: Attachment.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Check
protected final void check() {
    checkArgument(!Strings.isNullOrEmpty(fallback()), "Attachment fallback message cannot be null or empty");
}
 
Example 25
Source Project: immutables   Source File: SillyLazy.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Lazy
public int val1() {
  return counter().incrementAndGet();
}
 
Example 26
Source Project: immutables   Source File: StyleInfo.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Parameter
@Override
public abstract boolean attributeBuilderDetection();
 
Example 27
Source Project: immutables   Source File: Proto.java    License: Apache License 2.0 4 votes vote down vote up
@Override
@Value.Auxiliary
public abstract TypeElement element();
 
Example 28
Source Project: buck   Source File: PrebuiltRustLibraryDescription.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Default
default String getCrate() {
  return getName();
}
 
Example 29
Source Project: camel-k-runtime   Source File: CamelLoader.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Auxiliary
@Value.Default
default Set<String> getLanguages() {
    return Collections.emptySet();
}
 
Example 30
Source Project: immutables   Source File: Struct.java    License: Apache License 2.0 4 votes vote down vote up
@Value.Parameter
ListMultimap<Integer, String> indexList();