下面列出了com.google.common.collect.ImmutableList#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private boolean isBestPathNew(final ImmutableList<AddPathBestPath> newBestPathList) {
this.isNonAddPathBestPathNew = !isNonAddPathBestPathTheSame(newBestPathList);
filterRemovedPaths(newBestPathList);
if (this.bestPathRemoved != null && !this.bestPathRemoved.isEmpty()
|| newBestPathList != null
&& !newBestPathList.equals(this.bestPath)) {
if (this.bestPath != null) {
this.newBestPathToBeAdvertised = new ArrayList<>(newBestPathList);
this.newBestPathToBeAdvertised.removeAll(this.bestPath);
} else {
this.newBestPathToBeAdvertised = newBestPathList;
}
this.bestPath = newBestPathList;
LOG.trace("Actual Best {}, removed best {}", this.bestPath, this.bestPathRemoved);
return true;
}
return false;
}
public AggCall sort(Iterable<RexNode> orderKeys) {
final ImmutableList<RexNode> orderKeyList =
ImmutableList.copyOf(orderKeys);
return orderKeyList.equals(this.orderKeys)
? this
: new AggCallImpl(aggFunction, distinct, approximate, ignoreNulls,
filter, alias, operands, orderKeyList);
}
/**
* Re-sort all {@link Competitor}s from scratch, according to the current {@link VictoryCondition}.
* This should be called when the state of the match changes in a way that affects the
* rank of any competitors.
*/
public void invalidateCompetitorRanking() {
final ImmutableList<Competitor> before = ImmutableList.copyOf(calculator().rankedCompetitors());
calculator().invalidateRanking();
final ImmutableList<Competitor> after = ImmutableList.copyOf(calculator().rankedCompetitors());
if(!before.equals(after)) {
eventBus.callEvent(new RankingsChangeEvent(match, before, after));
}
}
public GenericMethodType<? extends T> resolveIn(TypeToken<?> context) {
final TypeToken<? extends T> returnType = (TypeToken<? extends T>) context.resolveType(this.returnType.getType());
final ImmutableList<TypeToken<?>> parameterTypes = this.parameterTypes.stream()
.map(t -> context.resolveType(t.getType()))
.collect(Collectors.toImmutableList());
return returnType.equals(this.returnType) && parameterTypes.equals(this.parameterTypes)
? this
: new GenericMethodType<>(returnType, parameterTypes);
}
private static ImmutableList<ScriptChunk> iterateOptimize(ImmutableList<ScriptChunk> scriptChunks) {
ImmutableList<ScriptChunk> value = scriptChunks;
ImmutableList<ScriptChunk> newValue = optimize(scriptChunks);
while (!newValue.equals(value)) {
value = newValue;
newValue = optimize(value);
}
;
return newValue;
}
public void hasSameContentAs(List<String> expectedContent) {
checkNotNull(expectedContent, "expectedContent");
ImmutableList<String> expected = ImmutableList.copyOf(expectedContent);
if (expected.equals(actual)) {
return;
}
String diffString = diffFormat.generateDiff(expected, actual);
failWithoutActual(
Fact.simpleFact(
Joiner.on('\n')
.join(
"Files differ in content. Displaying " + Ascii.toLowerCase(diffFormat.name()),
diffString)));
}
/**
* Finds any methods in the set that return the builder type. If the builder has type parameters
* {@code <A, B>}, then the return type of the method must be {@code Builder<A, B>} with
* the same parameter names. We enforce elsewhere that the names and bounds of the builder
* parameters must be the same as those of the @RetroFacebook class. Here's a correct example:
* <pre>
* {@code @RetroFacebook abstract class Foo<A extends Number, B> {
* abstract int someProperty();
*
* abstract Builder<A, B> toBuilder();
*
* interface Builder<A extends Number, B> {...}
* }}
* </pre>
* <p/>
* <p>We currently impose that there cannot be more than one such method.</p>
*/
ImmutableSet<ExecutableElement> toBuilderMethods(
Types typeUtils, Set<ExecutableElement> abstractMethods) {
ImmutableList<String> builderTypeParamNames =
FluentIterable.from(builderTypeElement.getTypeParameters())
.transform(SimpleNameFunction.INSTANCE)
.toList();
ImmutableSet.Builder<ExecutableElement> methods = ImmutableSet.builder();
for (ExecutableElement method : abstractMethods) {
if (builderTypeElement.equals(typeUtils.asElement(method.getReturnType()))) {
methods.add(method);
DeclaredType returnType = MoreTypes.asDeclared(method.getReturnType());
ImmutableList.Builder<String> typeArguments = ImmutableList.builder();
for (TypeMirror typeArgument : returnType.getTypeArguments()) {
if (typeArgument.getKind().equals(TypeKind.TYPEVAR)) {
typeArguments.add(typeUtils.asElement(typeArgument).getSimpleName().toString());
}
}
if (!builderTypeParamNames.equals(typeArguments.build())) {
errorReporter.reportError(
"Builder converter method should return "
+ builderTypeElement
+ TypeSimplifier.actualTypeParametersString(builderTypeElement),
method);
}
}
}
ImmutableSet<ExecutableElement> builderMethods = methods.build();
if (builderMethods.size() > 1) {
errorReporter.reportError(
"There can be at most one builder converter method", builderMethods.iterator().next());
}
return builderMethods;
}
/**
* Finds any methods in the set that return the builder type. If the builder has type parameters
* {@code <A, B>}, then the return type of the method must be {@code Builder<A, B>} with
* the same parameter names. We enforce elsewhere that the names and bounds of the builder
* parameters must be the same as those of the @RetroFacebook class. Here's a correct example:
* <pre>
* {@code @RetroFacebook abstract class Foo<A extends Number, B> {
* abstract int someProperty();
*
* abstract Builder<A, B> toBuilder();
*
* interface Builder<A extends Number, B> {...}
* }}
* </pre>
* <p/>
* <p>We currently impose that there cannot be more than one such method.</p>
*/
ImmutableSet<ExecutableElement> toBuilderMethods(
Types typeUtils, Set<ExecutableElement> abstractMethods) {
ImmutableList<String> builderTypeParamNames =
FluentIterable.from(builderTypeElement.getTypeParameters())
.transform(SimpleNameFunction.INSTANCE)
.toList();
ImmutableSet.Builder<ExecutableElement> methods = ImmutableSet.builder();
for (ExecutableElement method : abstractMethods) {
if (builderTypeElement.equals(typeUtils.asElement(method.getReturnType()))) {
methods.add(method);
DeclaredType returnType = MoreTypes.asDeclared(method.getReturnType());
ImmutableList.Builder<String> typeArguments = ImmutableList.builder();
for (TypeMirror typeArgument : returnType.getTypeArguments()) {
if (typeArgument.getKind().equals(TypeKind.TYPEVAR)) {
typeArguments.add(typeUtils.asElement(typeArgument).getSimpleName().toString());
}
}
if (!builderTypeParamNames.equals(typeArguments.build())) {
errorReporter.reportError(
"Builder converter method should return "
+ builderTypeElement
+ TypeSimplifier.actualTypeParametersString(builderTypeElement),
method);
}
}
}
ImmutableSet<ExecutableElement> builderMethods = methods.build();
if (builderMethods.size() > 1) {
errorReporter.reportError(
"There can be at most one builder converter method", builderMethods.iterator().next());
}
return builderMethods;
}
/**
* Finds any methods in the set that return the builder type. If the builder has type parameters
* {@code <A, B>}, then the return type of the method must be {@code Builder<A, B>} with
* the same parameter names. We enforce elsewhere that the names and bounds of the builder
* parameters must be the same as those of the @RetroWeibo class. Here's a correct example:
* <pre>
* {@code @RetroWeibo abstract class Foo<A extends Number, B> {
* abstract int someProperty();
*
* abstract Builder<A, B> toBuilder();
*
* interface Builder<A extends Number, B> {...}
* }}
* </pre>
* <p/>
* <p>We currently impose that there cannot be more than one such method.</p>
*/
ImmutableSet<ExecutableElement> toBuilderMethods(
Types typeUtils, Set<ExecutableElement> abstractMethods) {
ImmutableList<String> builderTypeParamNames =
FluentIterable.from(builderTypeElement.getTypeParameters())
.transform(SimpleNameFunction.INSTANCE)
.toList();
ImmutableSet.Builder<ExecutableElement> methods = ImmutableSet.builder();
for (ExecutableElement method : abstractMethods) {
if (builderTypeElement.equals(typeUtils.asElement(method.getReturnType()))) {
methods.add(method);
DeclaredType returnType = MoreTypes.asDeclared(method.getReturnType());
ImmutableList.Builder<String> typeArguments = ImmutableList.builder();
for (TypeMirror typeArgument : returnType.getTypeArguments()) {
if (typeArgument.getKind().equals(TypeKind.TYPEVAR)) {
typeArguments.add(typeUtils.asElement(typeArgument).getSimpleName().toString());
}
}
if (!builderTypeParamNames.equals(typeArguments.build())) {
errorReporter.reportError(
"Builder converter method should return "
+ builderTypeElement
+ TypeSimplifier.actualTypeParametersString(builderTypeElement),
method);
}
}
}
ImmutableSet<ExecutableElement> builderMethods = methods.build();
if (builderMethods.size() > 1) {
errorReporter.reportError(
"There can be at most one builder converter method", builderMethods.iterator().next());
}
return builderMethods;
}
public AggCall sort(Iterable<RexNode> orderKeys) {
final ImmutableList<RexNode> orderKeyList =
ImmutableList.copyOf(orderKeys);
return orderKeyList.equals(this.orderKeys)
? this
: new AggCallImpl(aggFunction, distinct, approximate, ignoreNulls,
filter, alias, operands, orderKeyList);
}
private Optional<? extends AndroidResources> assertFilter(
AndroidResources unfiltered, ImmutableList<Artifact> filteredResources, boolean isDependency)
throws Exception {
ImmutableList.Builder<Artifact> filteredDepsBuilder = ImmutableList.builder();
ResourceFilter fakeFilter =
ResourceFilter.of(ImmutableSet.copyOf(filteredResources), filteredDepsBuilder::add);
Optional<? extends AndroidResources> filtered =
unfiltered.maybeFilter(errorConsumer, fakeFilter, isDependency);
if (filteredResources.equals(unfiltered.getResources())) {
// We expect filtering to have been a no-op
assertThat(filtered.isPresent()).isFalse();
} else {
// The resources and their roots should be filtered
assertThat(filtered.get().getResources())
.containsExactlyElementsIn(filteredResources)
.inOrder();
assertThat(filtered.get().getResourceRoots())
.containsExactlyElementsIn(getResourceRoots(filteredResources))
.inOrder();
}
if (!isDependency) {
// The filter should not record any filtered dependencies
assertThat(filteredDepsBuilder.build()).isEmpty();
} else {
// The filtered dependencies should be exactly the list of filtered resources
assertThat(unfiltered.getResources())
.containsExactlyElementsIn(
Iterables.concat(filteredDepsBuilder.build(), filteredResources));
}
return filtered;
}
@Override
public AggCall sort(Iterable<RexNode> orderKeys) {
final ImmutableList<RexNode> orderKeyList = ImmutableList.copyOf(orderKeys);
return orderKeyList.equals(this.orderKeys) ? this
: new AggCallImpl(aggFunction, distinct, approximate, filter, alias, operands, orderKeyList);
}
/**
* Returns new problems in the BOM specified by {@code groupId} and {@code artifactId}. This
* method compares the latest release of the BOM and its snapshot version which uses artifacts in
* {@link #localArtifacts}.
*/
private ImmutableSet<SymbolProblem> run(String groupId, String artifactId)
throws RepositoryException, IOException, MavenRepositoryException, ModelBuildingException {
String latestBomCoordinates =
RepositoryUtility.findLatestCoordinates(repositorySystem, groupId, artifactId);
logger.info("BOM Coordinates: " + latestBomCoordinates);
Bom baseline = Bom.readBom(latestBomCoordinates);
ImmutableSet<SymbolProblem> problemsInBaseline =
LinkageChecker.create(baseline, null).findSymbolProblems().keySet();
Bom snapshot = copyWithSnapshot(repositorySystem, session, baseline, localArtifacts);
// Comparing coordinates because DefaultArtifact does not override equals
ImmutableList<String> baselineCoordinates = coordinatesList(baseline.getManagedDependencies());
ImmutableList<String> snapshotCoordinates = coordinatesList(snapshot.getManagedDependencies());
if (baselineCoordinates.equals(snapshotCoordinates)) {
logger.info(
"Snapshot is same as baseline. Not running comparison.");
logger.info(
"Baseline coordinates: " + Joiner.on(";").join(baselineCoordinates));
return ImmutableSet.of();
}
ImmutableList<Artifact> snapshotManagedDependencies = snapshot.getManagedDependencies();
ClassPathResult classPathResult = (new ClassPathBuilder()).resolve(snapshotManagedDependencies);
ImmutableList<ClassPathEntry> classpath = classPathResult.getClassPath();
List<ClassPathEntry> entryPointJars = classpath.subList(0, snapshotManagedDependencies.size());
ImmutableSetMultimap<SymbolProblem, ClassFile> snapshotSymbolProblems =
LinkageChecker.create(classpath, ImmutableSet.copyOf(entryPointJars), null)
.findSymbolProblems();
ImmutableSet<SymbolProblem> problemsInSnapshot = snapshotSymbolProblems.keySet();
if (problemsInBaseline.equals(problemsInSnapshot)) {
logger.info(
"Snapshot versions have the same " + problemsInBaseline.size() + " errors as baseline");
return ImmutableSet.of();
}
Set<SymbolProblem> fixedProblems = Sets.difference(problemsInBaseline, problemsInSnapshot);
if (!fixedProblems.isEmpty()) {
logger.info(messageForFixedErrors(fixedProblems));
}
Set<SymbolProblem> newProblems = Sets.difference(problemsInSnapshot, problemsInBaseline);
if (!newProblems.isEmpty()) {
logger.severe(
messageForNewErrors(snapshotSymbolProblems, problemsInBaseline, classPathResult));
}
return ImmutableSet.copyOf(newProblems);
}