Java Code Examples for org.apache.commons.collections.CollectionUtils#isEqualCollection()

The following examples show how to use org.apache.commons.collections.CollectionUtils#isEqualCollection() . 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: StreamDefinition.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (!(obj instanceof StreamDefinition)) {
        return false;
    }
    StreamDefinition streamDefinition = (StreamDefinition) obj;
    return Objects.equals(this.streamId, streamDefinition.streamId)
        && Objects.equals(this.group, streamDefinition.group)
        && Objects.equals(this.description, streamDefinition.description)
        && Objects.equals(this.validate, streamDefinition.validate)
        && Objects.equals(this.timeseries, streamDefinition.timeseries)
        && Objects.equals(this.dataSource, streamDefinition.dataSource)
        && Objects.equals(this.streamSource, streamDefinition.streamSource)
        && Objects.equals(this.siteId, streamDefinition.siteId)
        && CollectionUtils.isEqualCollection(this.columns, streamDefinition.columns);
}
 
Example 2
Source File: PolicyEntity.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(Object that) {
    if (that == this) {
        return true;
    }

    if (!(that instanceof PolicyEntity)) {
        return false;
    }

    PolicyEntity another = (PolicyEntity) that;

    return Objects.equals(another.name, this.name)
            && Objects.equals(another.definition, this.definition)
            && CollectionUtils.isEqualCollection(another.getAlertPublishmentIds(), alertPublishmentIds);
}
 
Example 3
Source File: CellValidator.java    From deep-spark with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }
    if (o == null || getClass() != o.getClass()) {
        return false;
    }

    CellValidator that = (CellValidator) o;

    if (validatorKind != that.validatorKind) {
        return false;
    }
    if (!validatorClassName.equals(that.validatorClassName)) {
        return false;
    }
    if (validatorKind != Kind.NOT_A_COLLECTION &&
            !CollectionUtils.isEqualCollection(validatorTypes, that.validatorTypes)) {
        return false;
    }

    return true;
}
 
Example 4
Source File: BuildingPanelVehicleMaintenance.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Update this panel
 */
public void update() {
	// Update vehicle list and vehicle mass label

	if (!CollectionUtils.isEqualCollection(vehicleCache, garage.getVehicles())) {
		vehicleCache = new ArrayList<Vehicle>(garage.getVehicles());
		vehicleListModel.clear();
		Iterator<Vehicle> i = vehicleCache.iterator();
		while (i.hasNext()) vehicleListModel.addElement(i.next());

		vehicleNumberCache = garage.getCurrentVehicleNumber();
		vehicleNumberLabel.setText(Msg.getString("BuildingPanelVehicleMaintenance.numberOfVehicles",
				vehicleNumberCache));
	}
}
 
Example 5
Source File: StreamPartition.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object other) {
    if (other == this) {
        return true;
    }
    if (!(other instanceof StreamPartition)) {
        return false;
    }
    StreamPartition sp = (StreamPartition) other;
    return Objects.equals(streamId, sp.streamId) && Objects.equals(type, sp.type)
        && CollectionUtils.isEqualCollection(columns, sp.columns) && Objects.equals(sortSpec, sp.sortSpec);
}
 
Example 6
Source File: PolicyDefinition.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object that) {
    if (that == this) {
        return true;
    }

    if (!(that instanceof PolicyDefinition)) {
        return false;
    }

    PolicyDefinition another = (PolicyDefinition) that;

    if (Objects.equals(another.siteId, this.siteId)
            && Objects.equals(another.name, this.name)
            && Objects.equals(another.description, this.description)
            && CollectionUtils.isEqualCollection(another.inputStreams, this.inputStreams)
            && CollectionUtils.isEqualCollection(another.outputStreams, this.outputStreams)
            && (another.definition != null && another.definition.equals(this.definition))
            && Objects.equals(this.definition, another.definition)
            && CollectionUtils.isEqualCollection(another.partitionSpec, this.partitionSpec)
            && another.policyStatus.equals(this.policyStatus)
            && another.parallelismHint == this.parallelismHint
            && Objects.equals(another.alertDefinition, alertDefinition)
            && CollectionUtils.isEqualCollection(another.alertDeduplications, alertDeduplications)) {
        return true;
    }
    return false;
}
 
Example 7
Source File: CollectionEqualsMatcher.java    From luxun with Apache License 2.0 5 votes vote down vote up
public boolean matches(Object collection) {
    /*
     * The expected collection is not null, so a null input should return false. Note that
     * instanceof will fail for null input.
     */
    return ((collection instanceof Collection<?>) 
            && CollectionUtils.isEqualCollection(expectedCollection, (Collection<?>) collection));
}
 
Example 8
Source File: StreamRepartitionStrategy.java    From eagle with Apache License 2.0 5 votes vote down vote up
public boolean equals(Object obj) {
    if (!(obj instanceof StreamRepartitionStrategy)) {
        return false;
    }
    StreamRepartitionStrategy o = (StreamRepartitionStrategy) obj;
    return partition.equals(o.partition)
        && CollectionUtils.isEqualCollection(totalTargetBoltIds, o.totalTargetBoltIds);
}
 
Example 9
Source File: CNodeMultiAgg.java    From systemds with Apache License 2.0 5 votes vote down vote up
@Override 
public boolean equals(Object o) {
	if(!(o instanceof CNodeMultiAgg))
		return false;
	CNodeMultiAgg that = (CNodeMultiAgg)o;
	return super.equals(o)
		&& CollectionUtils.isEqualCollection(_aggOps, that._aggOps)	
		&& equalInputReferences(
			_outputs, that._outputs, _inputs, that._inputs);
}
 
Example 10
Source File: PolicyWorkerQueue.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(Object other) {
    if (this == other) {
        return true;
    }
    if (!(other instanceof PolicyWorkerQueue)) {
        return false;
    }
    PolicyWorkerQueue that = (PolicyWorkerQueue) other;
    return Objects.equals(partition, that.partition)
        && CollectionUtils.isEqualCollection(workers, that.workers);
}
 
Example 11
Source File: BuildingPanelInhabitable.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Update this panel.
 */
public void update() {

	// Update population list and number label
	if (!CollectionUtils.isEqualCollection(inhabitantCache, inhabitable.getOccupants())) {
		inhabitantCache = new ArrayList<Person>(inhabitable.getOccupants());
		inhabitantListModel.clear();
		Iterator<Person> i = inhabitantCache.iterator();
		while (i.hasNext()) inhabitantListModel.addElement(i.next());

		numberLabel.setText(Msg.getString("BuildingPanelInhabitable.number", inhabitantCache.size())); //$NON-NLS-1$
	}
}
 
Example 12
Source File: ReflectionServiceHelper.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private static boolean areBothListsEqual(Collection collection1, Collection collection2) {
  // CollectionUtils.isEqualCollection is not null safe
  if (collection1 == null || collection2 == null) {
    return CollectionUtils.isEmpty(collection1) && CollectionUtils.isEmpty(collection2);
  } else {
    return CollectionUtils.isEqualCollection(collection1, collection2);
  }
}
 
Example 13
Source File: CsvBatchInputFileTypeBase.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Validates the CSV file content against the CSVEnum items as header
 * 1. content header must match CSVEnum order/value
 * 2. each data row should have same size as the header
 * 
 * @param expectedHeaderList        expected CSV header String list 
 * @param fileContents              contents to validate 
 * 
 * @throws IOException
 */
private void validateCSVFileInput(final List<String> expectedHeaderList, InputStream fileContents) throws IOException {

    //use csv reader to parse the csv content
    CSVReader csvReader = new CSVReader(new InputStreamReader(fileContents));
    List<String> inputHeaderList = Arrays.asList(csvReader.readNext());

    String errorMessage = null;
    
    // validate
    if (!CollectionUtils.isEqualCollection(expectedHeaderList, inputHeaderList)){
        errorMessage = "CSV Batch Input File contains incorrect number of headers";
        //collection has same elements, now check the exact content orders by looking at the toString comparisons
    }else if (!expectedHeaderList.equals(inputHeaderList)){
        errorMessage = "CSV Batch Input File headers are different";
    }else {
        
        //check the content size as well if headers are validated
        int line = 1;
        List<String> inputDataList = null;
        while ((inputDataList = Arrays.asList(csvReader.readNext())) != null && errorMessage != null){
            //if the data list size does not match header list (its missing data)
            if (inputDataList.size() != expectedHeaderList.size()){
                errorMessage = "line " + line + " layout does not match the header";
            }
            line++;
        }
    }
    
    if (errorMessage != null){
        LOG.error(errorMessage);
        throw new RuntimeException(errorMessage);
    }
}
 
Example 14
Source File: Attribute.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
public boolean equals(Owner o1, Owner o2) throws Exception {
    final Object v1 = getValue(o1);
    final Object v2 = getValue(o2);
    if (v1 == null && v2 == null) return true;
    if (multiple && v1 instanceof Collection && v2 instanceof Collection) {
        Collection c1 = (Collection) v1;
        Collection c2 = (Collection) v2;
        return CollectionUtils.isEqualCollection(c1, c2);
    }
    return v1 != null && v1.equals(v2);
}
 
Example 15
Source File: CNodeMultiAgg.java    From systemds with Apache License 2.0 5 votes vote down vote up
@Override 
public boolean equals(Object o) {
	if(!(o instanceof CNodeMultiAgg))
		return false;
	CNodeMultiAgg that = (CNodeMultiAgg)o;
	return super.equals(o)
		&& CollectionUtils.isEqualCollection(_aggOps, that._aggOps)	
		&& equalInputReferences(
			_outputs, that._outputs, _inputs, that._inputs);
}
 
Example 16
Source File: RangerDefaultPolicyResourceMatcher.java    From ranger with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isCompleteMatch(RangerAccessResource resource, Map<String, Object> evalContext) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> RangerDefaultPolicyResourceMatcher.isCompleteMatch(" + resource + ", " + evalContext + ")");
    }

    RangerPerfTracer perf = null;

    if(RangerPerfTracer.isPerfTraceEnabled(PERF_POLICY_RESOURCE_MATCHER_MATCH_LOG)) {
        perf = RangerPerfTracer.getPerfTracer(PERF_POLICY_RESOURCE_MATCHER_MATCH_LOG, "RangerDefaultPolicyResourceMatcher.grantRevokeMatch()");
    }

    boolean            ret          = false;
    Collection<String> resourceKeys = resource == null ? null : resource.getKeys();
    Collection<String> policyKeys   = policyResources == null ? null : policyResources.keySet();
    boolean            keysMatch    = resourceKeys != null && policyKeys != null && CollectionUtils.isEqualCollection(resourceKeys, policyKeys);

    if (keysMatch) {
        for (RangerResourceDef resourceDef : serviceDef.getResources()) {
            String                resourceName  = resourceDef.getName();
            Object                resourceValue = resource.getValue(resourceName);
            RangerResourceMatcher matcher       = getResourceMatcher(resourceName);

            if (resourceValue == null) {
                ret = matcher == null || matcher.isCompleteMatch(null, evalContext);
            } else if (resourceValue instanceof String) {
                String strValue = (String) resourceValue;

                if (StringUtils.isEmpty(strValue)) {
                    ret = matcher == null || matcher.isCompleteMatch(strValue, evalContext);
                } else {
                    ret = matcher != null && matcher.isCompleteMatch(strValue, evalContext);
                }
            } else { // return false for any other type of resourceValue
                ret = false;
            }

            if (!ret) {
                break;
            }
        }
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug("isCompleteMatch(): keysMatch=false. resourceKeys=" + resourceKeys + "; policyKeys=" + policyKeys);
        }
    }

    RangerPerfTracer.log(perf);

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== RangerDefaultPolicyResourceMatcher.isCompleteMatch(" + resource + ", " + evalContext + "): " + ret);
    }

    return ret;
}
 
Example 17
Source File: GoogleWebmasterExtractorIteratorTest.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
@Override
public boolean matches(Object actual) {
  return CollectionUtils.isEqualCollection((Collection) actual, _expected);
}
 
Example 18
Source File: RangerDefaultPolicyResourceMatcher.java    From ranger with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isCompleteMatch(Map<String, RangerPolicyResource> resources, Map<String, Object> evalContext) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> RangerDefaultPolicyResourceMatcher.isCompleteMatch(" + resources + ", " + evalContext + ")");
    }

    RangerPerfTracer perf = null;

    if(RangerPerfTracer.isPerfTraceEnabled(PERF_POLICY_RESOURCE_MATCHER_MATCH_LOG)) {
        perf = RangerPerfTracer.getPerfTracer(PERF_POLICY_RESOURCE_MATCHER_MATCH_LOG, "RangerDefaultPolicyResourceMatcher.applyPolicyMatch()");
    }

    boolean            ret          = false;
    Collection<String> resourceKeys = resources == null ? null : resources.keySet();
    Collection<String> policyKeys   = policyResources == null ? null : policyResources.keySet();
    boolean            keysMatch    = resourceKeys != null && policyKeys != null && CollectionUtils.isEqualCollection(resourceKeys, policyKeys);

    if (keysMatch) {
        for (RangerResourceDef resourceDef : serviceDef.getResources()) {
            String               resourceName   = resourceDef.getName();
            RangerPolicyResource resourceValues = resources.get(resourceName);
            RangerPolicyResource policyValues   = policyResources == null ? null : policyResources.get(resourceName);

            if (resourceValues == null || CollectionUtils.isEmpty(resourceValues.getValues())) {
                ret = (policyValues == null || CollectionUtils.isEmpty(policyValues.getValues()));
            } else if (policyValues != null && CollectionUtils.isNotEmpty(policyValues.getValues())) {
                ret = CollectionUtils.isEqualCollection(resourceValues.getValues(), policyValues.getValues());
            }

            if (!ret) {
                break;
            }
        }
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug("isCompleteMatch(): keysMatch=false. resourceKeys=" + resourceKeys + "; policyKeys=" + policyKeys);
        }
    }

    RangerPerfTracer.log(perf);

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== RangerDefaultPolicyResourceMatcher.isCompleteMatch(" + resources + ", " + evalContext + "): " + ret);
    }

    return ret;
}
 
Example 19
Source File: GridIoManagerSelfTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * Matches a given collection to the specified in constructor expected one
 * with Apache {@code CollectionUtils.isEqualCollection()}.
 *
 * @param colToCheck Collection to be matched against the expected one.
 * @return True if collections matches.
 */
@Override public boolean matches(Object colToCheck) {
    return CollectionUtils.isEqualCollection(expCol, (Collection)colToCheck);
}
 
Example 20
Source File: ServiceTagsProcessor.java    From ranger with Apache License 2.0 2 votes vote down vote up
private RangerTag findMatchingTag(RangerTag incomingTag, List<RangerTag> existingTags) throws Exception {

		RangerTag ret = null;

		if(StringUtils.isNotEmpty(incomingTag.getGuid())) {
			ret = tagStore.getTagByGuid(incomingTag.getGuid());
		}

		if (ret == null) {

			if (isResourcePrivateTag(incomingTag)) {

				for (RangerTag existingTag : existingTags) {

					if (StringUtils.equals(incomingTag.getType(), existingTag.getType())) {

						// Check attribute values
						Map<String, String> incomingTagAttributes = incomingTag.getAttributes();
						Map<String, String> existingTagAttributes = existingTag.getAttributes();

						if (CollectionUtils.isEqualCollection(incomingTagAttributes.keySet(), existingTagAttributes.keySet())) {

							boolean matched = true;

							for (Map.Entry<String, String> entry : incomingTagAttributes.entrySet()) {

								String key = entry.getKey();
								String value = entry.getValue();

								if (!StringUtils.equals(value, existingTagAttributes.get(key))) {
									matched = false;
									break;
								}

							}
							if (matched) {
								ret = existingTag;
								break;
							}
						}

					}
				}
			}

		}

		return ret;
	}