List of usage examples for org.apache.commons.lang ObjectUtils notEqual
public static boolean notEqual(Object object1, Object object2)
Compares two objects for inequality, where either one or both objects may be null
.
ObjectUtils.notEqual(null, null) = false ObjectUtils.notEqual(null, "") = true ObjectUtils.notEqual("", null) = true ObjectUtils.notEqual("", "") = false ObjectUtils.notEqual(Boolean.TRUE, null) = true ObjectUtils.notEqual(Boolean.TRUE, "true") = true ObjectUtils.notEqual(Boolean.TRUE, Boolean.TRUE) = false ObjectUtils.notEqual(Boolean.TRUE, Boolean.FALSE) = true
From source file:com.indoqa.solr.spatial.corridor.query.route.AbstractRouteQueryValueSource.java
@Override public boolean equals(Object o) { if (!(o instanceof AbstractRouteQueryValueSource)) { return false; }/*from w w w. j a v a 2 s . co m*/ AbstractRouteQueryValueSource other = (AbstractRouteQueryValueSource) o; if (ObjectUtils.notEqual(other.lineString, this.lineString)) { return false; } if (ObjectUtils.notEqual(other.loctionValueSource, this.loctionValueSource)) { return false; } if (ObjectUtils.notEqual(other.description(), this.description())) { return false; } return true; }
From source file:com.indoqa.solr.spatial.corridor.query.points.AbstractPointsQueryCorridorValueSource.java
@Override public boolean equals(Object o) { if (!(o instanceof AbstractPointsQueryCorridorValueSource)) { return false; }// ww w . j a v a2 s .co m AbstractPointsQueryCorridorValueSource other = (AbstractPointsQueryCorridorValueSource) o; if (ObjectUtils.notEqual(other.queryPoints, this.queryPoints)) { return false; } if (ObjectUtils.notEqual(other.routeValueSource, this.routeValueSource)) { return false; } if (ObjectUtils.notEqual(other.description(), this.description())) { return false; } return true; }
From source file:de.tudarmstadt.ukp.clarin.webanno.brat.curation.AgreementUtils.java
private static AgreementResult makeStudy(DiffResult aDiff, Collection<String> aUsers, String aType, String aFeature, Map<String, List<JCas>> aCasMap) { List<ConfigurationSet> completeSets = new ArrayList<>(); List<ConfigurationSet> setsWithDifferences = new ArrayList<>(); List<ConfigurationSet> incompleteSetsByPosition = new ArrayList<>(); List<ConfigurationSet> incompleteSetsByLabel = new ArrayList<>(); CodingAnnotationStudy study = new CodingAnnotationStudy(aUsers.size()); nextPosition: for (Position p : aDiff.getPositions()) { ConfigurationSet cfgSet = aDiff.getConfigurtionSet(p); // Only calculate agreement for the given type if (!cfgSet.getPosition().getType().equals(aType)) { continue; }//from ww w . j a va 2s. c o m Object[] values = new Object[aUsers.size()]; int i = 0; for (String user : aUsers) { // Set has to include all users, otherwise we cannot calculate the agreement for // this configuration set. if (!cfgSet.getCasGroupIds().contains(user)) { incompleteSetsByPosition.add(cfgSet); continue nextPosition; } // Make sure a single user didn't do multiple alternative annotations at a single // position. So there is currently no support for calculating agreement on stacking // annotations. List<Configuration> cfgs = cfgSet.getConfigurations(user); if (cfgs.size() > 1) { throw new IllegalStateException( "Agreement for interpretation plurality not yet supported! User [" + user + "] has [" + cfgs.size() + "] differnet configurations."); } // Only calculate agreement for the given feature FeatureStructure fs = cfgs.get(0).getFs(user, p.getCasId(), aCasMap); values[i] = getFeature(fs, aFeature); // "null" cannot be used in agreement calculations. We treat these as incomplete if (values[i] == null) { incompleteSetsByLabel.add(cfgSet); continue nextPosition; } i++; } if (ObjectUtils.notEqual(values[0], values[1])) { setsWithDifferences.add(cfgSet); } completeSets.add(cfgSet); study.addItemAsArray(values); } return new AgreementResult(aType, aFeature, aDiff, study, completeSets, setsWithDifferences, incompleteSetsByPosition, incompleteSetsByLabel); }
From source file:ee.ria.xroad.common.message.SoapUtils.java
/** * Checks consistency of two SOAP headers. * @param h1 the first SOAP header/*from www. j av a 2 s. c om*/ * @param h2 the second SOAP header */ public static void checkConsistency(SoapHeader h1, SoapHeader h2) { for (Field field : SoapHeader.class.getDeclaredFields()) { if (field.isAnnotationPresent(CheckConsistency.class)) { Object value1 = getFieldValue(field, h1); Object value2 = getFieldValue(field, h2); if (ObjectUtils.notEqual(value1, value2)) { throw new CodedException(X_INCONSISTENT_HEADERS, "Field '%s' does not match in request and response", field.getName()); } } } }
From source file:er.corebusinesslogic.ERCoreUserPreferences.java
public void takeValueForKey(Object value, String key) { // we first make sure there is no cruft left // !! locking is turned off on the value attribute of UserPreference // so that if a user opens two sessions they don't get locking failures // this is OK for display style prefs (how many items, how they are sorted) // but might not be for more behavior-style prefs!! EOEditingContext ec = ERXEC.newEditingContext(); ec.lock();/*from ww w . j av a 2 s.c o m*/ try { EOEnterpriseObject pref = preferenceRecordForKey(key, ec); ERCoreUserInterface u = (ERCoreUserInterface) ERCoreBusinessLogic.actor(ec); if (pref != null) { if (value != null) { String encodedValue = encodedValue(value); if (ObjectUtils.notEqual(encodedValue, pref.valueForKey("value"))) { if (log.isDebugEnabled()) log.debug("Updating preference " + u + ": " + key + "=" + encodedValue); pref.takeValueForKey(encodedValue, "value"); } } else { if (log.isDebugEnabled()) log.debug("Removing preference " + u + ": " + key); ec.deleteObject(pref); } } else if (value != null) { pref = ERXEOControlUtilities.createAndInsertObject(ec, "ERCPreference"); u.newPreference(pref); // done this way to not force you to sub-class our User entity pref.takeValueForKey(ERXEOControlUtilities.primaryKeyObjectForObject((EOEnterpriseObject) u), "userID"); pref.takeValueForKey(key, "key"); pref.takeValueForKey(encodedValue(value), "value"); if (log.isDebugEnabled()) log.debug( "Creating preference " + u + ": " + key + " - " + value + " -- " + encodedValue(value)); } if (ec.hasChanges()) { ec.saveChanges(); } } catch (RuntimeException ex) { log.error("Error while setting preference " + key + ": " + ex); } finally { ec.unlock(); } ec.dispose(); NSNotificationCenter.defaultCenter().postNotification(PreferenceDidChangeNotification, new NSDictionary(value, key)); }
From source file:er.directtoweb.pages.ERD2WPage.java
/** Sets the d2wContext for this page */ @Override/*from ww w . j ava 2s . c o m*/ public void setLocalContext(D2WContext newValue) { if (ObjectUtils.notEqual(newValue, _localContext)) { // HACK ALERT: this next line is made necessary by the // brain-damageness of // D2WComponent.setLocalContext, which holds on to the first non // null value it gets. // I swear if I could get my hands on the person who did that.. :-) _localContext = newValue; log.debug("SetLocalContext: " + newValue); } super.setLocalContext(newValue); if (newValue != null) newValue.takeValueForKey(keyPathsWithValidationExceptions, Keys.keyPathsWithValidationExceptions); else log.warn("D2WContext was null!"); }
From source file:er.directtoweb.pages.ERD2WListPage.java
@Override public void setDataSource(EODataSource eodatasource) { EODatabaseDataSource ds = (eodatasource instanceof EODatabaseDataSource) ? (EODatabaseDataSource) eodatasource : null;/*from w w w.j a v a2 s . c o m*/ Object newDataSourceState = null; if (ds != null) { newDataSourceState = ds.fetchSpecification().toString().replaceAll("\\n", "") + ":" + ds.fetchSpecificationForFetch().toString().replaceAll("\\n", "") + " fetchLimit: " + ds.fetchSpecification().fetchLimit() + ", " + ds.fetchSpecificationForFetch().fetchLimit(); } EODataSource old = displayGroup().dataSource(); super.setDataSource(eodatasource); displayGroup().setDataSource(eodatasource); if (ds == null || (dataSourceState == null) || (dataSourceState != null && !dataSourceState.equals(newDataSourceState)) || alwaysRefetchList()) { log.debug("updating:\n" + dataSourceState + " vs\n" + newDataSourceState); dataSourceState = newDataSourceState; _hasToUpdate = true; // AK: when you use the page in a embedded component and have a few // of them in a tab // page, WO reuses the component for a new dataSource. If this DS // doesn't have the // sort order keys required it leads to a KVC error later on. We fix // this here to re-init // the sort ordering from the rules. if (old != null && eodatasource != null && ObjectUtils .notEqual(eodatasource.classDescriptionForObjects(), old.classDescriptionForObjects())) { setSortOrderingsOnDisplayGroup(sortOrderings(), displayGroup()); } } }
From source file:er.extensions.eof.ERXModelGroup.java
/** * Looks for foreign key attributes that have a different type from the destination attribute. The classic example of this is a * long foreign key pointing to an integer primary key, which has a terrible consequence that is nearly impossible to track down. *///from w w w. j av a 2 s . co m @SuppressWarnings("cast") public void checkForMismatchedJoinTypes() { if (ERXProperties.booleanForKey("er.extensions.ERXModelGroup.ignoreTypeMismatch")) { return; } for (EOModel model : (NSArray<EOModel>) models()) { for (EOEntity entity : (NSArray<EOEntity>) model.entities()) { for (EORelationship relationship : (NSArray<EORelationship>) entity.relationships()) { for (EOJoin join : (NSArray<EOJoin>) relationship.joins()) { EOAttribute sourceAttribute = join.sourceAttribute(); EOAttribute destinationAttribute = join.destinationAttribute(); if (sourceAttribute != null && destinationAttribute != null) { if (ObjectUtils.notEqual(sourceAttribute.className(), destinationAttribute.className()) || ObjectUtils.notEqual(sourceAttribute.valueType(), destinationAttribute.valueType())) { if (!ERXProperties.booleanForKey( "er.extensions.ERXModelGroup." + sourceAttribute.entity().name() + "." + sourceAttribute.name() + ".ignoreTypeMismatch")) { throw new RuntimeException("The attribute " + sourceAttribute.name() + " in " + sourceAttribute.entity().name() + " (" + sourceAttribute.className() + ", " + sourceAttribute.valueType() + ") is a foreign key to " + destinationAttribute.name() + " in " + destinationAttribute.entity().name() + " (" + destinationAttribute.className() + ", " + destinationAttribute.valueType() + ") but their class names or value types do not match. If this is actually OK, you can set er.extensions.ERXModelGroup." + sourceAttribute.entity().name() + "." + sourceAttribute.name() + ".ignoreTypeMismatch=true in your Properties file."); } } } } } } } }
From source file:org.apache.metron.common.dsl.functions.resolver.BaseFunctionResolver.java
/** * Performs the core process of function resolution. *//* w ww. j a v a 2s . c o m*/ protected Map<String, StellarFunctionInfo> resolveFunctions() { // maps a function name to its definition Map<String, StellarFunctionInfo> functions = new HashMap<>(); for (Class<? extends StellarFunction> clazz : resolvables()) { StellarFunctionInfo fn = resolveFunction(clazz); if (fn != null) { // check for duplicate function names StellarFunctionInfo fnSameName = functions.get(fn.getName()); if (fnSameName != null && ObjectUtils.notEqual(fnSameName, fn)) { LOG.warn(format("Namespace conflict: duplicate function names; `%s` implemented by [%s, %s]", fn.getName(), fnSameName.getFunction(), fn.getFunction())); } functions.put(fn.getName(), fn); } } return functions; }
From source file:org.apache.metron.stellar.dsl.functions.resolver.BaseFunctionResolver.java
/** * Performs the core process of function resolution. *//*from ww w .j a v a2 s . c o m*/ protected Map<String, StellarFunctionInfo> resolveFunctions() { // maps a function name to its definition Map<String, StellarFunctionInfo> functions = new HashMap<>(); for (Class<? extends StellarFunction> clazz : resolvables()) { StellarFunctionInfo fn = resolveFunction(clazz); if (fn != null) { // check for duplicate function names StellarFunctionInfo fnSameName = functions.get(fn.getName()); if (fnSameName != null && ObjectUtils.notEqual(fnSameName, fn)) { LOG.warn("Namespace conflict: duplicate function names; `{}` implemented by [{}, {}]", fn.getName(), fnSameName.getFunction(), fn.getFunction()); } functions.put(fn.getName(), fn); } } return functions; }