Java Code Examples for com.google.common.collect.Iterables#elementsEqual()

The following examples show how to use com.google.common.collect.Iterables#elementsEqual() . 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: bazel   File: CcToolchainFeatures.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(Object object) {
  if (object == this) {
    return true;
  }
  if (object instanceof FeatureConfiguration) {
    FeatureConfiguration that = (FeatureConfiguration) object;
    // Only compare actionConfigByActionName, enabledActionConfigActionnames and enabledFeatures
    // because enabledFeatureNames is based on the list of Features.
    return Objects.equals(actionConfigByActionName, that.actionConfigByActionName)
        && Iterables.elementsEqual(
            enabledActionConfigActionNames, that.enabledActionConfigActionNames)
        && Iterables.elementsEqual(enabledFeatures, that.enabledFeatures);
  }
  return false;
}
 
Example 2
Source Project: bazel   File: CcToolchainFeatures.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(Object other) {
  if (other == this) {
    return true;
  }
  if (!(other instanceof ActionConfig)) {
    return false;
  }
  ActionConfig that = (ActionConfig) other;

  return Objects.equals(configName, that.configName)
      && Objects.equals(actionName, that.actionName)
      && enabled == that.enabled
      && Iterables.elementsEqual(tools, that.tools)
      && Iterables.elementsEqual(flagSets, that.flagSets)
      && Iterables.elementsEqual(implies, that.implies);
}
 
Example 3
Source Project: jimfs   File: JimfsPath.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public JimfsPath normalize() {
  if (isNormal()) {
    return this;
  }

  Deque<Name> newNames = new ArrayDeque<>();
  for (Name name : names) {
    if (name.equals(Name.PARENT)) {
      Name lastName = newNames.peekLast();
      if (lastName != null && !lastName.equals(Name.PARENT)) {
        newNames.removeLast();
      } else if (!isAbsolute()) {
        // if there's a root and we have an extra ".." that would go up above the root, ignore it
        newNames.add(name);
      }
    } else if (!name.equals(Name.SELF)) {
      newNames.add(name);
    }
  }

  return Iterables.elementsEqual(newNames, names) ? this : pathService.createPath(root, newNames);
}
 
Example 4
@Override
public boolean isBinaryEquivalent(@Nullable IDeclaration obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    EnumDeclaration other = (EnumDeclaration) obj;
    if (!fContainerType.isBinaryEquivalent(other.fContainerType)) {
        return false;
    }
    /*
     * Must iterate through the entry sets as the comparator used in the enum tree
     * does not respect the contract
     */
    return Iterables.elementsEqual(fEnumTree.entrySet(), other.fEnumTree.entrySet());
}
 
Example 5
@Override
public boolean equals(@Nullable Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    EnumDeclaration other = (EnumDeclaration) obj;
    if (!fContainerType.equals(other.fContainerType)) {
        return false;
    }
    /*
     * Must iterate through the entry sets as the comparator used in the enum tree
     * does not respect the contract
     */
    return Iterables.elementsEqual(fEnumTree.entrySet(), other.fEnumTree.entrySet());
}
 
Example 6
private boolean extraDataIsValid(
    final Collection<Address> expectedValidators, final BlockHeader header) {

  final CliqueExtraData cliqueExtraData = CliqueExtraData.decode(header);
  final Address proposer = cliqueExtraData.getProposerAddress();

  if (!expectedValidators.contains(proposer)) {
    LOG.trace("Proposer sealing block is not a member of the signers.");
    return false;
  }

  if (epochManager.isEpochBlock(header.getNumber())) {
    if (!Iterables.elementsEqual(cliqueExtraData.getValidators(), expectedValidators)) {
      LOG.trace(
          "Incorrect signers. Expected {} but got {}.",
          expectedValidators,
          cliqueExtraData.getValidators());
      return false;
    }
  } else {
    if (!cliqueExtraData.getValidators().isEmpty()) {
      LOG.trace("Signer list on non-epoch blocks must be empty.");
      return false;
    }
  }

  return true;
}
 
Example 7
Source Project: bazel   File: CcToolchainFeatures.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(@Nullable Object object) {
  if (this == object) {
    return true;
  }
  if (object instanceof WithFeatureSet) {
    WithFeatureSet that = (WithFeatureSet) object;
    return Iterables.elementsEqual(features, that.features)
        && Iterables.elementsEqual(notFeatures, that.notFeatures);
  }
  return false;
}
 
Example 8
Source Project: auto   File: FactoryDescriptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns true if the given {@link FactoryMethodDescriptor} and
 * {@link ImplementationMethodDescriptor} are duplicates.
 *
 * <p>Descriptors are duplicates if they have the same name and if they have the same passed types
 * in the same order.
 */
private static boolean areDuplicateMethodDescriptors(
    FactoryMethodDescriptor factory,
    ImplementationMethodDescriptor implementation) {

  if (!factory.name().equals(implementation.name())) {
    return false;
  }

  // Descriptors are identical if they have the same passed types in the same order.
  return Iterables.elementsEqual(
      Iterables.transform(factory.passedParameters(), Parameter::type),
      Iterables.transform(implementation.passedParameters(), Parameter::type));
}
 
Example 9
@Override
public boolean equals(Object obj) {
    if (obj instanceof CategoryContextMapping) {
        CategoryContextMapping other = (CategoryContextMapping) obj;
        if (this.fieldName.equals(other.fieldName)) {
            return Iterables.elementsEqual(this.defaultValues, other.defaultValues);
        }
    }
    return false;
}
 
Example 10
Source Project: bazel   File: CcToolchainFeatures.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(@Nullable Object object) {
  if (this == object) {
    return true;
  }
  if (object instanceof EnvEntry) {
    EnvEntry that = (EnvEntry) object;
    return Objects.equals(key, that.key)
        && Iterables.elementsEqual(valueChunks, that.valueChunks);
  }
  return false;
}
 
Example 11
Source Project: zuul   File: HttpQueryParams.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object obj)
{
    if (obj == null)
        return false;
    if (! (obj instanceof HttpQueryParams))
        return false;

    HttpQueryParams hqp2 = (HttpQueryParams) obj;
    return Iterables.elementsEqual(delegate.entries(), hqp2.delegate.entries());
}
 
Example 12
@Override
public void onMouseUp(MouseUpEvent event) {
	if (this.upRegistration != null) {
		this.upRegistration.removeHandler();
	}
	if (this.overRegistration != null) {
		this.overRegistration.removeHandler();
	}
	if (this.selectedRow != null) {
		StyleUtils.removeStyle(this.selectedRow, TableOrder.STYLE_ROW_DRAGING);
	}
	this.upRegistration = null;
	this.overRegistration = null;

	if (event != null) {
		event.stopPropagation();
		if (!Iterables.elementsEqual(this.rows, this.body.getRows())) {
			EventBus.get().fireEventFromSource(new RowOrderChangeEvent(this.body), TableOrder.this);
			this.body.setRowOrderDirty(true);
		}
	}

	this.body = null;
	this.hoverRow = null;
	this.selectedRow = null;
	TableOrder.this.disableTextSelection(false);

	RootPanel.get().getElement().getStyle().clearCursor();
}
 
Example 13
Source Project: big-c   File: AbstractMetricsRecord.java    License: Apache License 2.0 5 votes vote down vote up
@Override public boolean equals(Object obj) {
  if (obj instanceof MetricsRecord) {
    final MetricsRecord other = (MetricsRecord) obj;
    return Objects.equal(timestamp(), other.timestamp()) &&
           Objects.equal(name(), other.name()) &&
           Objects.equal(description(), other.description()) &&
           Objects.equal(tags(), other.tags()) &&
           Iterables.elementsEqual(metrics(), other.metrics());
  }
  return false;
}
 
Example 14
Source Project: AppTroy   File: DexWriter.java    License: Apache License 2.0 5 votes vote down vote up
@Override public boolean equals(Object o) {
    if (o instanceof EncodedArrayKey) {
        EncodedArrayKey other = (EncodedArrayKey)o;
        if (elements.size() != other.elements.size()) {
            return false;
        }
        return Iterables.elementsEqual(elements, other.elements);
    }
    return false;
}
 
Example 15
Source Project: buck   File: DaemonicParserState.java    License: Apache License 2.0 5 votes vote down vote up
private boolean invalidateIfProjectBuildFileParserStateChanged(Cell cell) {
  Iterable<String> defaultIncludes =
      cell.getBuckConfig().getView(ParserConfig.class).getDefaultIncludes();

  boolean invalidatedByDefaultIncludesChange = false;
  Iterable<String> expected;
  try (AutoCloseableLock readLock = cachedStateLock.readLock()) {
    expected = cachedIncludes.get(cell.getRoot());

    if (expected == null || !Iterables.elementsEqual(defaultIncludes, expected)) {
      // Someone's changed the default includes. That's almost definitely caused all our lovingly
      // cached data to be enormously wonky.
      invalidatedByDefaultIncludesChange = true;
    }

    if (!invalidatedByDefaultIncludesChange) {
      return false;
    }
  }
  try (AutoCloseableLock writeLock = cachedStateLock.writeLock()) {
    cachedIncludes.put(cell.getRoot(), defaultIncludes);
  }
  if (invalidateCellCaches(cell)) {
    LOG.warn(
        "Invalidating cache on default includes change (%s != %s)", expected, defaultIncludes);
    cacheInvalidatedByDefaultIncludesChangeCounter.inc();
  }
  return true;
}
 
Example 16
@NoWarning("GC")
public static void testIterablesOK(Iterable<String> i, Collection<String> c) {
    Iterables.contains(i, "x");
    Iterables.removeAll(i, c);
    Iterables.retainAll(i, c);
    Iterables.elementsEqual(i, c);
    Iterables.frequency(i, "x");
}
 
Example 17
Source Project: vjtools   File: CollectionUtil.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 两个集合中的所有元素按顺序相等.
 */
public static boolean elementsEqual(Iterable<?> iterable1, Iterable<?> iterable2) {
	return Iterables.elementsEqual(iterable1, iterable2);
}
 
Example 18
Source Project: spoofax   File: Assert2.java    License: Apache License 2.0 4 votes vote down vote up
public static <T> void assertIterableEquals(Iterable<T> expected, Iterable<T> actual, String message) {
    if(!Iterables.elementsEqual(expected, actual)) {
        fail(formatEquals(message, expected, actual));
    }
}
 
Example 19
@Override
protected boolean is(Iterable<Integer> input, Integer... elements) {
	return Iterables.elementsEqual(input, Lists.newArrayList(elements));
}
 
Example 20
Source Project: Elasticsearch   File: ContextMapping.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Test equality of two mapping
 *
 * @param thisMappings first mapping
 * @param otherMappings second mapping
 *
 * @return true if both arguments are equal
 */
public static boolean mappingsAreEqual(SortedMap<String, ? extends ContextMapping> thisMappings, SortedMap<String, ? extends ContextMapping> otherMappings) {
    return Iterables.elementsEqual(thisMappings.entrySet(), otherMappings.entrySet());
}