List of usage examples for org.apache.commons.collections CollectionUtils isEqualCollection
public static boolean isEqualCollection(final Collection a, final Collection b)
From source file:org.dataconservancy.packaging.tool.model.dprofile.NodeType.java
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (!(obj instanceof NodeType)) return false; NodeType other = (NodeType) obj;/*from www. j av a2s . c om*/ if (!other.canEqual(this)) return false; if (child_file_constraint == null) { if (other.child_file_constraint != null) return false; } else if (!child_file_constraint.equals(other.child_file_constraint)) return false; if (default_property_values == null) { if (other.default_property_values != null) return false; } else if (!default_property_values.equals(other.default_property_values)) return false; if (domain_types == null) { if (other.domain_types != null) return false; } else if (other.domain_types == null || !CollectionUtils.isEqualCollection(domain_types, other.domain_types)) return false; if (file_assoc != other.file_assoc) return false; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (inheritable_properties == null) { if (other.inheritable_properties != null) return false; } else if (other.inheritable_properties == null || !CollectionUtils.isEqualCollection(inheritable_properties, other.inheritable_properties)) return false; if (parent_constraints == null) { if (other.parent_constraints != null) return false; } else if (other.parent_constraints == null || !CollectionUtils.isEqualCollection(parent_constraints, other.parent_constraints)) return false; if (profile == null) { if (other.profile != null) return false; } else if (profile.getIdentifier() == null) { if (other.profile.getIdentifier() != null) return false; } else if (other.profile == null || other.profile.getIdentifier() == null || !profile.getIdentifier().equals(other.profile.getIdentifier())) return false; if (property_constraints == null) { if (other.property_constraints != null) return false; } else if (other.property_constraints == null || !CollectionUtils.isEqualCollection(property_constraints, other.property_constraints)) return false; if (supplied_properties == null) { if (other.supplied_properties != null) return false; } else if (!supplied_properties.equals(other.supplied_properties)) return false; if (preferredParentType == null) { if (other.preferredParentType != null) return false; } else if (preferredParentType.getIdentifier() == null) { if (other.preferredParentType.getIdentifier() != null) return false; } else if (other.preferredParentType == null || other.preferredParentType.getIdentifier() == null || !preferredParentType.getIdentifier().equals(other.preferredParentType.getIdentifier())) return false; return true; }
From source file:org.dataconservancy.packaging.tool.model.dprofile.Property.java
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof Property)) return false; Property other = (Property) obj;//w w w .jav a 2 s. c o m if (type == null) { if (other.type != null) return false; } else if (!type.equals(other.type)) return false; if (value == null) { if (other.value != null) return false; } else if (isSimpleValue() && !value.equals(other.value)) { return false; } else if (isComplexValue() && (other.value == null || !CollectionUtils.isEqualCollection(getComplexValue(), other.getComplexValue()))) { return false; } return true; }
From source file:org.dataconservancy.packaging.tool.model.dprofile.PropertyType.java
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (!(obj instanceof PropertyType)) return false; PropertyType other = (PropertyType) obj; if (!other.canEqual(this)) return false; if (allowed_values == null) { if (other.allowed_values != null) return false; } else if (other.allowed_values == null || !CollectionUtils.isEqualCollection(allowed_values, other.allowed_values)) return false; if (category == null) { if (other.category != null) return false; } else if (!category.equals(other.category)) return false; if (domain_pred == null) { if (other.domain_pred != null) return false; } else if (!domain_pred.equals(other.domain_pred)) return false; if (readonly != other.readonly) return false; if (complex_constraints == null) { if (other.complex_constraints != null) return false; } else if (other.complex_constraints == null || !CollectionUtils.isEqualCollection(complex_constraints, other.complex_constraints)) return false; if (complex_domain_types == null) { if (other.complex_domain_types != null) return false; } else if (other.complex_domain_types == null || !CollectionUtils.isEqualCollection(complex_domain_types, other.complex_domain_types)) return false; if (value_hint != other.value_hint) return false; if (value_type != other.value_type) return false; return true;//from ww w .java 2 s.c o m }
From source file:org.eclipse.hudson.model.project.property.DescribableListProjectProperty.java
@Override public boolean allowOverrideValue(DescribableList cascadingValue, DescribableList candidateValue) { if (null == cascadingValue && null == candidateValue) { return false; }/*www . jav a 2 s . com*/ if (null != cascadingValue && null != candidateValue) { List cascadingList = cascadingValue.toList(); List candidateList = candidateValue.toList(); return !(CollectionUtils.isEqualCollection(cascadingList, candidateList) || DeepEquals.deepEquals(cascadingList, candidateList)); } return true; }
From source file:org.efaps.esjp.common.AbstractCommon_Base.java
/** * @param _parameter Parameter as passed by the eFaps API * @param _offset offset to start to search for * @return QueryBuilder//from w w w . ja v a 2 s . c om * @throws EFapsException on error */ protected QueryBuilder getQueryBldrFromPropertiesInternal(final Parameter _parameter, final int _offset) throws EFapsException { QueryBuilder ret = null; final Map<Integer, String> types = analyseProperty(_parameter, "Type", _offset); final Map<Integer, String> linkFroms = analyseProperty(_parameter, "LinkFrom", _offset); final Map<Integer, String> classif = analyseProperty(_parameter, "Classification", _offset); final Map<Integer, String> expands = analyseProperty(_parameter, "ExpandChildTypes", _offset); boolean first = true; boolean multiple = false; final List<Type> excludes = new ArrayList<>(); for (final Entry<Integer, String> typeEntry : types.entrySet()) { final Type type; String typeStr = typeEntry.getValue(); boolean negate = false; if (typeStr.startsWith("!")) { typeStr = typeStr.substring(1); negate = true; } if (isUUID(typeEntry.getValue())) { type = Type.get(UUID.fromString(typeStr)); } else { type = Type.get(typeStr); } if (type == null) { final AbstractUserInterfaceObject command = (AbstractUserInterfaceObject) _parameter .get(ParameterValues.UIOBJECT); AbstractCommon_Base.LOG.error("Type Definition invalid. Object: {}, Index: {}", command == null ? "UNKNOWN" : command.getName(), typeEntry.getKey()); } else { if (negate) { excludes.add(type); } else { if (first) { ret = new QueryBuilder(type); if (linkFroms.size() == 1 && linkFroms.containsKey(typeEntry.getKey())) { ret.addWhereAttrEqValue(linkFroms.get(typeEntry.getKey()), getInstance4LinkFrom(_parameter)); } // in case of a simple query set the includechilds here if (types.size() == 1 && expands.size() == 1) { ret.setIncludeChildTypes(!"false".equalsIgnoreCase(expands.get(typeEntry.getKey()))); } else if (expands.size() > 1 && "true".equalsIgnoreCase(expands.get(typeEntry.getKey()))) { final Set<Type> typeList = getTypeList(_parameter, type); ret.addType(typeList.toArray(new Type[typeList.size()])); } first = false; } else { ret.addType(type); if (expands.size() > 1 && "true".equalsIgnoreCase(expands.get(typeEntry.getKey()))) { final Set<Type> typeList = getTypeList(_parameter, type); ret.addType(typeList.toArray(new Type[typeList.size()])); } multiple = true; } } } } if (ret != null) { if (!excludes.isEmpty()) { final List<Long> typeIds = new ArrayList<>(); for (final Type type : excludes) { for (final Type exType : getTypeList(_parameter, type)) { typeIds.add(exType.getId()); } } ret.addWhereAttrNotEqValue(ret.getType().getTypeAttribute(), typeIds.toArray()); } final Set<Classification> clazzes = new HashSet<>(); for (final String classStr : classif.values()) { final Classification clazz; if (isUUID(classStr)) { clazz = Classification.get(UUID.fromString(classStr)); } else { clazz = Classification.get(classStr); } if (clazz == null) { final AbstractUserInterfaceObject command = (AbstractUserInterfaceObject) _parameter .get(ParameterValues.UIOBJECT); AbstractCommon_Base.LOG.error("Classification Definition invalid. Object: {}, Value: {}", command == null ? "UNKNOWN" : command.getName(), classStr); } else { clazzes.add(clazz); } } if (!clazzes.isEmpty()) { ret.addWhereClassification(clazzes.toArray(new Classification[clazzes.size()])); } final List<Status> statusList = getStatusListFromProperties(_parameter, _offset); if (!statusList.isEmpty()) { Type tempType = ret.getType(); while (!tempType.isCheckStatus() && tempType.getParentType() != null) { tempType = tempType.getParentType(); } ret.addWhereAttrEqValue(tempType.getStatusAttribute(), statusList.toArray()); } // in case of multiple, the linkfrom must be evaluated if (multiple && linkFroms.size() > 1) { final QueryBuilder attrQueryBldr = new QueryBuilder(ret.getType()); attrQueryBldr.setOr(true); final Set<List<String>> added = new HashSet<>(); for (final Entry<Integer, String> entry : linkFroms.entrySet()) { if (types.containsKey(entry.getKey())) { final String typeStr = types.get(entry.getKey()); final Type type; if (isUUID(typeStr)) { type = Type.get(UUID.fromString(typeStr)); } else { type = Type.get(typeStr); } if (type != null) { final List<String> colNames = type.getAttribute(entry.getValue()).getSqlColNames(); for (final Attribute attr : ret.getType().getAttributes().values()) { if (CollectionUtils.isEqualCollection(colNames, attr.getSqlColNames())) { if (!added.contains(colNames)) { attrQueryBldr.addWhereAttrEqValue(attr, getInstance4LinkFrom(_parameter)); added.add(colNames); } break; } } } } } if (!added.isEmpty()) { ret.addWhereAttrInQuery("ID", attrQueryBldr.getAttributeQuery("ID")); } } } return ret; }
From source file:org.exoplatform.commons.notification.NotificationUtilsTest.java
public void testNotificationInfoClone() { ////from ww w . j a va2 s . com new IdGenerator(new IDGeneratorServiceImpl()); Map<String, String> ownerParameter = new HashMap<String, String>(); ownerParameter.put("test", "value test"); NotificationInfo info = NotificationInfo.instance(); info.setFrom("demo").key("notifiId").setOrder(1).setOwnerParameter(ownerParameter) .setSendToDaily(new String[] { "plugin1", "plugin2" }) .setSendToWeekly(new String[] { "plugin2", "plugin3" }).setTo("root"); NotificationInfo clone = info.clone(); assertEquals(info.getId(), clone.getId()); assertEquals(info.getId(), clone.getId()); assertEquals(info.getFrom(), clone.getFrom()); assertEquals(info.getTo(), clone.getTo()); // assertTrue(Arrays.equals(info.getSendToDaily(), clone.getSendToDaily())); assertTrue(Arrays.equals(info.getSendToWeekly(), clone.getSendToWeekly())); assertTrue(CollectionUtils.isEqualCollection(info.getOwnerParameter().keySet(), clone.getOwnerParameter().keySet())); assertTrue(CollectionUtils.isEqualCollection(info.getOwnerParameter().values(), clone.getOwnerParameter().values())); assertEquals(info.getValueOwnerParameter("test"), clone.getValueOwnerParameter("test")); // clone.getSendToDaily()[0] = "plugin4"; clone.getOwnerParameter().put("test", "value clone"); // assertFalse(Arrays.equals(info.getSendToDaily(), clone.getSendToDaily())); assertFalse(CollectionUtils.isEqualCollection(info.getOwnerParameter().values(), clone.getOwnerParameter().values())); // assertFalse(info.getValueOwnerParameter("test").equals(clone.getValueOwnerParameter("test"))); // clone = info.clone(true); assertFalse(info.getId().equals(clone.getId())); }
From source file:org.exoplatform.forum.rendering.TestRenderHelper.java
public void testGetCodeSupportedLangs() { List<String> expected = Arrays.asList("Bash", "AppleScript", "Diff", "JavaFX", "Perl", "Java", "AS3", "Erlang", "Scala", "Cpp", "Python", "JScript", "CSharp", "Sass", "Ruby", "ColdFusion", "Sql", "PowerShell", "Php", "Delphi", "Xml", "Vb", "Haxe", "TypeScript", "Plain", "Groovy", "Css"); assertTrue(CollectionUtils.isEqualCollection(expected, BuildRendering.getCodeSupportedLangs().keySet())); }
From source file:org.fao.fenix.data.CSVBasicValidator.java
private Boolean validateCSVHeaders(List<String> expectedHeaders, List<String> csvHeaders, StringBuilder errorStringBuilder) { Boolean isValidated = false;//from w ww .ja v a 2s . c o m String expectedHeadersSt = getHeaderString(expectedHeaders); String inputHeadersSt = getHeaderString(csvHeaders); boolean headersIsEqual = CollectionUtils.isEqualCollection(expectedHeaders, csvHeaders); if (headersIsEqual) { isValidated = true; } else { LOGGER.error("The headers in the FTP CSV file do not match what was expected. The CSV contains " + csvHeaders.size() + " headers (i.e. " + inputHeadersSt + "). However, the following " + expectedHeaders.size() + " headers were expected: " + expectedHeadersSt + ". Please correct the CSV file. [THE ERROR EMAIL WILL BE SENT TO USER]"); errorStringBuilder .append("** The headers in the FTP CSV file do not match what was expected. \nThe CSV contains " + csvHeaders.size() + " headers (i.e. " + inputHeadersSt + "). However, the following " + expectedHeaders.size() + " headers were expected: " + expectedHeadersSt + ". Please correct the CSV file. \n\n"); // throw new FenixException("The headers in the FTP CSV file do not match what was expected. The CSV contains "+csvHeaders.size()+" headers (i.e. "+sbh.toString()+"). However, the following "+expectedHeaders.size()+" headers were expected: "+sbd.toString()+". Please correct the CSV file."); } System.out.println(" validateCSVHeaders " + errorStringBuilder.toString()); return isValidated; }
From source file:org.finra.herd.service.impl.RelationalTableRegistrationServiceImpl.java
/** * Updates relational table schema, if changes are detected, for an already existing relational table registration. * * @param storageUnitKey the storage unit key for relational table registration * * @return the information for the newly created business object data, if schema was updated; null otherwise *///from w w w . ja v a 2 s. c om BusinessObjectData processRelationalTableRegistrationForSchemaUpdateImpl( BusinessObjectDataStorageUnitKey storageUnitKey) { // Validate database entities per specified relational table registration create request. // This method also gets storage attributes required to perform relation table registration. RelationalTableRegistrationDto relationalTableRegistrationDto = relationalTableRegistrationHelperService .prepareForRelationalTableSchemaUpdate(storageUnitKey); // Retrieve a list of actual schema columns for the specified relational table. // This method uses actual JDBC connection to retrieve a description of table columns. List<SchemaColumn> schemaColumns = relationalTableRegistrationHelperService.retrieveRelationalTableColumns( relationalTableRegistrationDto.getRelationalStorageAttributes(), relationalTableRegistrationDto.getRelationalSchemaName(), relationalTableRegistrationDto.getRelationalTableName()); // Check if we need to update the relational table schema. if (!CollectionUtils.isEqualCollection(schemaColumns, relationalTableRegistrationDto.getBusinessObjectFormat().getSchema().getColumns())) { return relationalTableRegistrationHelperService .updateRelationalTableSchema(relationalTableRegistrationDto, schemaColumns); } else { return null; } }
From source file:org.fosstrak.ale.server.readers.CompositeReader.java
/** * this method changes the specification of a reader. * @param aspec an LRSpec containing the changes for the reader * @throws ImplementationException whenever an internal error occurs *///from www . j a v a 2 s. c om @Override public synchronized void update(LRSpec aspec) throws ImplementationException { // get a lock on the logicalReaders synchronized (logicalReaders) { // test whether we need to update the reader or just the properties // this can be done by comparing the readers with the readers in the new LRSpec List<String> readers = aspec.getReaders().getReader(); // set the new spec setLRSpec(aspec); if (!CollectionUtils.isEqualCollection(readers, logicalReaders.keySet())) { // as there are changes in the readers, we // need to stop this compositeReader, update the // components and then restart again LOG.debug("updating readers in CompositeReader " + readerName); // stop the reader stop(); // remove all readers first for (LogicalReader reader : logicalReaders.values()) { reader.deleteObserver(this); } logicalReaders.clear(); // fill in the new readers for (String reader : readers) { LogicalReader logicalReader = logicalReaderManager.getLogicalReader(reader); logicalReader.addObserver(this); logicalReaders.put(reader, logicalReader); } start(); } // update the LRProperties LOG.debug("updating LRProperties in CompositeReader " + readerName); notifyAll(); } }