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

The following examples show how to use org.immutables.value.Value#Lazy . 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: DefaultJavaLibraryRules.java    From buck with Apache License 2.0 6 votes vote down vote up
@Value.Lazy
JarBuildStepsFactory getJarBuildStepsFactory() {
  DefaultJavaLibraryClasspaths classpaths = getClasspaths();
  return new JarBuildStepsFactory(
      getLibraryTarget(),
      getConfiguredCompiler(),
      getSrcs(),
      getResources(),
      getResourcesParameters(),
      getManifestFile(),
      getPostprocessClassesCommands(),
      getConfiguredCompilerFactory().trackClassUsage(getJavacOptions()),
      getJavacOptions().trackJavacPhaseEvents(),
      getClassesToRemoveFromJar(),
      getAbiGenerationMode(),
      getAbiCompatibilityMode(),
      classpaths.getDependencyInfos(),
      getRequiredForSourceOnlyAbi());
}
 
Example 2
Source File: Proto.java    From immutables with Apache License 2.0 6 votes vote down vote up
@Value.Lazy
@Override
public JacksonMode jacksonSerializeMode() {
  boolean wasJacksonSerialize = false;
  for (AnnotationMirror a : element().getAnnotationMirrors()) {
    TypeElement e = (TypeElement) a.getAnnotationType().asElement();
    if (!wasJacksonSerialize && e.getQualifiedName().contentEquals(JACKSON_SERIALIZE)) {
      wasJacksonSerialize = true;
    }
    if (e.getQualifiedName().contentEquals(JACKSON_DESERIALIZE)) {
      for (ExecutableElement attr : a.getElementValues().keySet()) {
        if (attr.getSimpleName().contentEquals("builder")) {
          // If builder attribute is specified, we don't consider this as
          // our, immutables, business to generate anything.
          return JacksonMode.BUILDER;
        }
      }
      return JacksonMode.DELEGATED;
    }
  }
  return wasJacksonSerialize
      ? JacksonMode.DELEGATED
      : JacksonMode.NONE;
}
 
Example 3
Source File: ParserConfig.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * A (possibly empty) sequence of paths to files that should be included by default when
 * evaluating a build file.
 */
@Value.Lazy
public Iterable<String> getDefaultIncludes() {
  ImmutableMap<String, String> entries =
      getDelegate().getEntriesForSection(BUILDFILE_SECTION_NAME);
  String includes = Strings.nullToEmpty(entries.get(INCLUDES_PROPERTY_NAME));
  return Splitter.on(' ').trimResults().omitEmptyStrings().split(includes);
}
 
Example 4
Source File: DefaultJavaLibraryClasspaths.java    From buck with Apache License 2.0 5 votes vote down vote up
@Value.Lazy
public ImmutableList<JavaDependencyInfo> getDependencyInfos() {
  ImmutableList.Builder<JavaDependencyInfo> builder = ImmutableList.builder();

  ImmutableSortedMap<BuildTarget, BuildRule> abiDeps =
      toLibraryTargetKeyedMap(getCompileTimeClasspathAbiDeps());
  ImmutableSortedMap<BuildTarget, BuildRule> sourceOnlyAbiDeps =
      toLibraryTargetKeyedMap(getSourceOnlyAbiClasspaths().getCompileTimeClasspathDeps());

  for (BuildRule compileTimeDep : getCompileTimeClasspathDeps()) {
    Preconditions.checkState(compileTimeDep instanceof HasJavaAbi);

    BuildTarget compileTimeDepLibraryTarget = toLibraryTarget(compileTimeDep);

    boolean requiredForSourceOnlyAbi = sourceOnlyAbiDeps.containsKey(compileTimeDepLibraryTarget);
    boolean isAbiDep = abiDeps.containsKey(compileTimeDepLibraryTarget);

    SourcePath compileTimeSourcePath = compileTimeDep.getSourcePathToOutput();

    // Some deps might not actually contain any source files. In that case, they have no output.
    // Just skip them.
    if (compileTimeSourcePath == null) {
      continue;
    }

    SourcePath abiClasspath;
    if (isAbiDep) {
      abiClasspath =
          Objects.requireNonNull(
              abiDeps.get(compileTimeDepLibraryTarget).getSourcePathToOutput());
    } else {
      abiClasspath = compileTimeSourcePath;
    }

    builder.add(
        new JavaDependencyInfo(compileTimeSourcePath, abiClasspath, requiredForSourceOnlyAbi));
  }

  return builder.build();
}
 
Example 5
Source File: Proto.java    From immutables with Apache License 2.0 5 votes vote down vote up
@Value.Lazy
public boolean isJacksonSerialized() {
  if (jacksonSerializeMode() == JacksonMode.DELEGATED) {
    // while DeclaringPackage cannot have those annotations
    // directly, just checking them as a general computation path
    // will not hurt much.
    return true;
  }
  for (MetaAnnotated metaAnnotated : metaAnnotated()) {
    if (metaAnnotated.isJacksonSerialized()) {
      return true;
    }
  }
  return false;
}
 
Example 6
Source File: ParserConfig.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * When set, requested target node will fail to configure if platform is not specified either
 * per-target with {@code default_target_platform} or globally with {@code --target-platforms=}
 * command line flag.
 */
@Value.Lazy
public boolean getRequireTargetPlatform() {
  // NOTE(nga): the future of this option is unknown at the moment.
  // It is possible that:
  // * we will change this option default to true
  // * we will remove this option (inlining it as true or false)
  return getDelegate().getBooleanValue("parser", "require_target_platform", false);
}
 
Example 7
Source File: KnownNativeRuleTypes.java    From buck with Apache License 2.0 5 votes vote down vote up
/** @return all known descriptions */
@Value.Lazy
public ImmutableList<BaseDescription<?>> getDescriptions() {
  return ImmutableList.<BaseDescription<?>>builder()
      .addAll(getKnownBuildDescriptions())
      .addAll(getKnownConfigurationDescriptions())
      .build();
}
 
Example 8
Source File: Proto.java    From immutables with Apache License 2.0 5 votes vote down vote up
@Value.Lazy
public CharSequence sourceCode() {
  if (!isTopLevel()) {
    return associatedTopLevel().sourceCode();
  }
  return SourceExtraction.extract(processing(), CachingElements.getDelegate(element()));
}
 
Example 9
Source File: Proto.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Value.Lazy
public boolean hasAstModule() {
  return hasElement(AstMirror.qualifiedName());
}
 
Example 10
Source File: DefaultJavaLibraryClasspaths.java    From buck with Apache License 2.0 4 votes vote down vote up
@Value.Lazy
protected ImmutableSortedSet<BuildRule> getCompileTimeClasspathFullDeps() {
  return getCompileTimeClasspathUnfilteredFullDeps().stream()
      .filter(dep -> dep instanceof HasJavaAbi)
      .collect(ImmutableSortedSet.toImmutableSortedSet(Ordering.natural()));
}
 
Example 11
Source File: SystemToolProvider.java    From buck with Apache License 2.0 4 votes vote down vote up
@Value.Lazy
public Tool resolve() {
  return new HashedFileTool(resolveSourcePath());
}
 
Example 12
Source File: Constitution.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Value.Lazy
public AppliedNameForms factoryCreate() {
  return typeModifiable().applied(names().create());
}
 
Example 13
Source File: FixBuckConfig.java    From buck with Apache License 2.0 4 votes vote down vote up
/** Get the contact to use to tell users who to contact when `buck fix` fails */
@Value.Lazy
public Optional<String> getFixScriptContact() {
  return getDelegate().getValue(FIX_SECTION, FIX_SCRIPT_CONTACT_FIELD);
}
 
Example 14
Source File: Proto.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Value.Lazy
public Optional<TransformMirror> getTransform() {
  return environment().hasTreesModule()
      ? TransformMirror.find(element())
      : Optional.<TransformMirror>absent();
}
 
Example 15
Source File: FixBuckConfig.java    From buck with Apache License 2.0 4 votes vote down vote up
/** Get the script to run when buck fix is invoked */
@Value.Lazy
public Optional<ImmutableList<String>> getFixScript() {
  return getDelegate().getOptionalListWithoutComments(FIX_SECTION, FIX_SCRIPT_FIELD, ' ');
}
 
Example 16
Source File: CleanCommandBuckConfig.java    From buck with Apache License 2.0 4 votes vote down vote up
@Value.Lazy
public ImmutableList<String> getCleanExcludedCaches() {
  return getDelegate().getListWithoutComments("clean", "excluded_dir_caches");
}
 
Example 17
Source File: Proto.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Value.Lazy
public boolean hasEncodeModule() {
  return hasElement(EncodingMirror.qualifiedName());
}
 
Example 18
Source File: LogBuckConfig.java    From buck with Apache License 2.0 4 votes vote down vote up
@Value.Lazy
public boolean isJavaGCEventLoggingEnabled() {
  return getDelegate().getBooleanValue(LOG_SECTION, "gc_event_logging_enabled", false);
}
 
Example 19
Source File: ParserConfig.java    From buck with Apache License 2.0 4 votes vote down vote up
/**
 * @return the parser target threshold. When the current targets produced exceed this value, a
 *     warning is emitted.
 */
@Value.Lazy
public int getParserTargetThreshold() {
  return getDelegate().getInteger("parser", "target_threshold").orElse(TARGET_PARSER_THRESHOLD);
}
 
Example 20
Source File: ParserConfig.java    From buck with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the module search path PYTHONPATH to set for the parser, as specified by the
 * 'python_path' key of the 'parser' section.
 *
 * @return The PYTHONPATH value or an empty string if not set.
 */
@Value.Lazy
public Optional<String> getPythonModuleSearchPath() {
  return getDelegate().getValue("parser", "python_path");
}