下面列出了com.google.common.collect.ImmutableSortedMap#containsKey ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected void addImplicitTablesBasedOnNullaryFunctionsToBuilder(
ImmutableSortedMap.Builder<String, Table> builder) {
ImmutableSortedMap<String, Table> explicitTables = builder.build();
final long now = System.currentTimeMillis();
final NameSet set = implicitFunctionCache.get(now);
for (String s : set.iterable()) {
// explicit table wins.
if (explicitTables.containsKey(s)) {
continue;
}
for (Function function : schema.getFunctions(s)) {
if (function instanceof TableMacro
&& function.getParameters().isEmpty()) {
final Table table = ((TableMacro) function).apply(ImmutableList.of());
builder.put(s, table);
}
}
}
}
protected void addImplicitTablesBasedOnNullaryFunctionsToBuilder(
ImmutableSortedMap.Builder<String, Table> builder) {
ImmutableSortedMap<String, Table> explicitTables = builder.build();
for (String s : schema.getFunctionNames()) {
// explicit table wins.
if (explicitTables.containsKey(s)) {
continue;
}
for (Function function : schema.getFunctions(s)) {
if (function instanceof TableMacro && function.getParameters().isEmpty()) {
final Table table = ((TableMacro) function).apply(ImmutableList.of());
builder.put(s, table);
}
}
}
}
protected void addImplicitTablesBasedOnNullaryFunctionsToBuilder(
ImmutableSortedMap.Builder<String, Table> builder) {
ImmutableSortedMap<String, Table> explicitTables = builder.build();
final long now = System.currentTimeMillis();
final NameSet set = implicitFunctionCache.get(now);
for (String s : set.iterable()) {
// explicit table wins.
if (explicitTables.containsKey(s)) {
continue;
}
for (Function function : schema.getFunctions(s)) {
if (function instanceof TableMacro
&& function.getParameters().isEmpty()) {
final Table table = ((TableMacro) function).apply(ImmutableList.of());
builder.put(s, table);
}
}
}
}
protected void addImplicitTablesBasedOnNullaryFunctionsToBuilder(
ImmutableSortedMap.Builder<String, Table> builder) {
ImmutableSortedMap<String, Table> explicitTables = builder.build();
for (String s : schema.getFunctionNames()) {
// explicit table wins.
if (explicitTables.containsKey(s)) {
continue;
}
for (Function function : schema.getFunctions(s)) {
if (function instanceof TableMacro
&& function.getParameters().isEmpty()) {
final Table table = ((TableMacro) function).apply(ImmutableList.of());
builder.put(s, table);
}
}
}
}
protected void addImplicitTablesBasedOnNullaryFunctionsToBuilder(
ImmutableSortedMap.Builder<String, Table> builder) {
ImmutableSortedMap<String, Table> explicitTables = builder.build();
final long now = System.currentTimeMillis();
final NameSet set = implicitFunctionCache.get(now);
for (String s : set.iterable()) {
// explicit table wins.
if (explicitTables.containsKey(s)) {
continue;
}
for (Function function : schema.getFunctions(s)) {
if (function instanceof TableMacro
&& function.getParameters().isEmpty()) {
final Table table = ((TableMacro) function).apply(ImmutableList.of());
builder.put(s, table);
}
}
}
}
protected void addImplicitTablesBasedOnNullaryFunctionsToBuilder(
ImmutableSortedMap.Builder<String, Table> builder) {
ImmutableSortedMap<String, Table> explicitTables = builder.build();
for (String s : schema.getFunctionNames()) {
// explicit table wins.
if (explicitTables.containsKey(s)) {
continue;
}
for (Function function : schema.getFunctions(s)) {
if (function instanceof TableMacro
&& function.getParameters().isEmpty()) {
final Table table = ((TableMacro) function).apply(ImmutableList.of());
builder.put(s, table);
}
}
}
}
private static NestedSet<Artifact> getGroupArtifacts(
RuleContext ruleContext,
List<String> targets,
ImmutableSortedMap<PathFragment, PhonyTarget> phonyTargetsMap,
PhonyTargetArtifacts phonyTargetsArtifacts,
NinjaGraphArtifactsHelper artifactsHelper)
throws GenericParsingException {
NestedSetBuilder<Artifact> nestedSetBuilder = NestedSetBuilder.stableOrder();
for (String target : targets) {
PathFragment path = PathFragment.create(target);
if (phonyTargetsMap.containsKey(path)) {
NestedSet<Artifact> artifacts = phonyTargetsArtifacts.getPhonyTargetArtifacts(path);
nestedSetBuilder.addTransitive(artifacts);
} else {
Artifact outputArtifact = artifactsHelper.createOutputArtifact(path);
if (outputArtifact == null) {
ruleContext.ruleError(
String.format("Required target '%s' is not created in ninja_graph.", path));
return NestedSetBuilder.emptySet(Order.STABLE_ORDER);
}
nestedSetBuilder.add(outputArtifact);
}
}
return nestedSetBuilder.build();
}
protected void addImplicitSubSchemaToBuilder(
ImmutableSortedMap.Builder<String, CalciteSchema> builder) {
ImmutableSortedMap<String, CalciteSchema> explicitSubSchemas = builder.build();
final long now = System.currentTimeMillis();
final SubSchemaCache subSchemaCache = implicitSubSchemaCache.get(now);
for (String name : subSchemaCache.names.iterable()) {
if (explicitSubSchemas.containsKey(name)) {
// explicit sub-schema wins.
continue;
}
builder.put(name, subSchemaCache.cache.getUnchecked(name));
}
}
protected void addImplicitSubSchemaToBuilder(ImmutableSortedMap.Builder<String, CalciteSchema> builder) {
ImmutableSortedMap<String, CalciteSchema> explicitSubSchemas = builder.build();
for (String schemaName : schema.getSubSchemaNames()) {
if (explicitSubSchemas.containsKey(schemaName)) {
// explicit subschema wins.
continue;
}
Schema s = schema.getSubSchema(schemaName);
if (s != null) {
CalciteSchema calciteSchema = new SimpleCalciteSchema(this, s, schemaName);
builder.put(schemaName, calciteSchema);
}
}
}
protected void addImplicitSubSchemaToBuilder(
ImmutableSortedMap.Builder<String, CalciteSchema> builder) {
ImmutableSortedMap<String, CalciteSchema> explicitSubSchemas = builder.build();
final long now = System.currentTimeMillis();
final SubSchemaCache subSchemaCache = implicitSubSchemaCache.get(now);
for (String name : subSchemaCache.names.iterable()) {
if (explicitSubSchemas.containsKey(name)) {
// explicit sub-schema wins.
continue;
}
builder.put(name, subSchemaCache.cache.getUnchecked(name));
}
}
protected void addImplicitSubSchemaToBuilder(
ImmutableSortedMap.Builder<String, CalciteSchema> builder) {
ImmutableSortedMap<String, CalciteSchema> explicitSubSchemas = builder.build();
for (String schemaName : schema.getSubSchemaNames()) {
if (explicitSubSchemas.containsKey(schemaName)) {
// explicit subschema wins.
continue;
}
Schema s = schema.getSubSchema(schemaName);
if (s != null) {
CalciteSchema calciteSchema = new SimpleCalciteSchema(this, s, schemaName);
builder.put(schemaName, calciteSchema);
}
}
}
protected void addImplicitSubSchemaToBuilder(
ImmutableSortedMap.Builder<String, CalciteSchema> builder) {
ImmutableSortedMap<String, CalciteSchema> explicitSubSchemas = builder.build();
final long now = System.currentTimeMillis();
final SubSchemaCache subSchemaCache = implicitSubSchemaCache.get(now);
for (String name : subSchemaCache.names.iterable()) {
if (explicitSubSchemas.containsKey(name)) {
// explicit sub-schema wins.
continue;
}
builder.put(name, subSchemaCache.cache.getUnchecked(name));
}
}
protected void addImplicitSubSchemaToBuilder(
ImmutableSortedMap.Builder<String, CalciteSchema> builder) {
ImmutableSortedMap<String, CalciteSchema> explicitSubSchemas = builder.build();
for (String schemaName : schema.getSubSchemaNames()) {
if (explicitSubSchemas.containsKey(schemaName)) {
// explicit subschema wins.
continue;
}
Schema s = schema.getSubSchema(schemaName);
if (s != null) {
CalciteSchema calciteSchema = new SimpleCalciteSchema(this, s, schemaName);
builder.put(schemaName, calciteSchema);
}
}
}
@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();
}
/**
* @return the native library map with additional entries for library names with the version
* suffix stripped (e.g. libfoo.so.1.0 -> libfoo.so) to appease LuaJIT, which wants to load
* libraries using the build-time name.
*/
private ImmutableSortedMap<String, SourcePath> addVersionLessLibraries(
CxxPlatform cxxPlatform, ImmutableSortedMap<String, SourcePath> libraries) {
Pattern versionedExtension =
Pattern.compile(
Joiner.on("[.\\d]*")
.join(
Iterables.transform(
Splitter.on("%s")
.split(cxxPlatform.getSharedLibraryVersionedExtensionFormat()),
input -> input.isEmpty() ? input : Pattern.quote(input))));
Map<String, SourcePath> librariesPaths = new HashMap<>();
for (Map.Entry<String, SourcePath> ent : libraries.entrySet()) {
String name = ent.getKey();
if (librariesPaths.containsKey(name) && librariesPaths.get(name) != ent.getValue()) {
throw new HumanReadableException(
"Library %s has multiple possible paths: %s and %s",
name, ent.getValue(), librariesPaths.get(name));
}
librariesPaths.put(name, ent.getValue());
Matcher matcher = versionedExtension.matcher(name);
String versionLessName = matcher.replaceAll(cxxPlatform.getSharedLibraryExtension());
if (!versionLessName.equals(ent.getKey()) && !libraries.containsKey(versionLessName)) {
librariesPaths.put(versionLessName, ent.getValue());
}
}
return ImmutableSortedMap.copyOf(librariesPaths);
}