List of usage examples for org.springframework.util ObjectUtils nullSafeEquals
public static boolean nullSafeEquals(@Nullable Object o1, @Nullable Object o2)
From source file:com.developmentsprint.spring.breaker.interceptor.NameMatchCircuitBreakerAttributeSource.java
@Override public boolean equals(Object other) { if (this == other) { return true; }//from www . j a v a 2s . co m if (!(other instanceof NameMatchCircuitBreakerAttributeSource)) { return false; } NameMatchCircuitBreakerAttributeSource otherTas = (NameMatchCircuitBreakerAttributeSource) other; return ObjectUtils.nullSafeEquals(this.nameMap, otherTas.nameMap); }
From source file:com.wavemaker.commons.io.local.LocalResourceStore.java
@Override public boolean equals(Object obj) { if (obj == this) { return true; }//ww w. j ava2s. c o m if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } LocalResourceStore other = (LocalResourceStore) obj; return ObjectUtils.nullSafeEquals(getFile(), other.getFile()); }
From source file:org.brekka.stillingar.spring.pc.CustomBeanDefinitionVisitor.java
@Override protected void visitIndexedArgumentValues(Map<Integer, ValueHolder> ias) { Set<Entry<Integer, ValueHolder>> entrySet = ias.entrySet(); for (Entry<Integer, ValueHolder> entry : entrySet) { ValueHolder valueHolder = entry.getValue(); currentConstructorValue = valueHolder; currentConstructorIndex = entry.getKey(); Object newVal = resolveValue(valueHolder.getValue()); if (!ObjectUtils.nullSafeEquals(newVal, valueHolder.getValue())) { valueHolder.setValue(newVal); }/*from w w w . j a v a2s . c o m*/ currentConstructorValue = null; currentConstructorIndex = null; } }
From source file:org.brekka.stillingar.spring.pc.ConstructorArgDefChangeListener.java
@Override protected void onChange(String newValue) { ConfigurableListableBeanFactory beanFactory = beanFactoryRef.get(); if (beanFactory == null) { return;/* w w w.j a v a 2 s . c o m*/ } BeanDefinition beanDef = beanFactory.getMergedBeanDefinition(beanName); ConstructorArgumentValues mutableConstructorValues = beanDef.getConstructorArgumentValues(); ValueHolder valueHolder = null; List<ValueHolder> genericArgumentValues = mutableConstructorValues.getGenericArgumentValues(); if (constructorArgIndex != null) { valueHolder = mutableConstructorValues.getIndexedArgumentValues().get(constructorArgIndex); if (valueHolder == null) { throw new IllegalStateException( String.format("Failed to find constructor arg at index %d", constructorArgIndex)); } } else if (genericArgumentValues.size() == 1) { valueHolder = genericArgumentValues.get(0); } else { for (ValueHolder vh : genericArgumentValues) { if (vh.getType().equals(constructorArgType)) { valueHolder = vh; } } if (valueHolder == null) { throw new IllegalStateException( String.format("Failed to find constructor arg with type '%s'", constructorArgType)); } } if (!ObjectUtils.nullSafeEquals(newValue, valueHolder.getValue())) { valueHolder.setValue(newValue); try { /* * Spring implements caching of constructor values, which can be reset by clearing the package-private * field 'resolvedConstructorOrFactoryMethod' on RootBeanDefinition. Naturally this will fail if a * security manager is present but there doesn't seem to be any other way to do it. Make sure to warn * about this in the documentation! */ Field field = beanDef.getClass().getDeclaredField("resolvedConstructorOrFactoryMethod"); field.setAccessible(true); field.set(beanDef, null); } catch (Exception e) { throw new ConfigurationException(String.format( "Unable to update value for constructor argument '%s'. " + "Failed to reset the cached constructor state for bean '%s'", (constructorArgIndex != null ? constructorArgIndex.toString() : constructorArgType), beanName), e); } } }
From source file:example.app.model.Person.java
@Override public boolean equals(Object obj) { if (obj == this) { return true; }//w ww .ja va 2s . com if (!(obj instanceof Person)) { return false; } Person that = (Person) obj; return ObjectUtils.nullSafeEquals(this.getBirthDate(), that.getBirthDate()) && ObjectUtils.nullSafeEquals(this.getFirstName(), that.getFirstName()) && ObjectUtils.nullSafeEquals(this.getLastName(), that.getLastName()); }
From source file:com.springsource.hq.plugin.tcserver.serverconfig.configuration.jvm.JvmOptions.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }/*from ww w. ja v a 2 s. co m*/ if (!(obj instanceof JvmOptions)) { return false; } JvmOptions jvmOptions = (JvmOptions) obj; return ObjectUtils.nullSafeEquals(this.getAdvanced(), jvmOptions.getAdvanced()) && ObjectUtils.nullSafeEquals(this.getDebug(), jvmOptions.getDebug()) && ObjectUtils.nullSafeEquals(this.getGarbageCollection(), jvmOptions.getGarbageCollection()) && ObjectUtils.nullSafeEquals(this.getGeneral(), jvmOptions.getGeneral()) && ObjectUtils.nullSafeEquals(this.getMemory(), jvmOptions.getMemory()); }
From source file:com.unioncast.mv.spring.ResponseEntity.java
@Override public boolean equals(Object other) { if (this == other) { return true; }// www .j a v a 2 s. c o m if (!(other instanceof ResponseEntity)) { return false; } ResponseEntity<?> otherEntity = (ResponseEntity<?>) other; return (ObjectUtils.nullSafeEquals(this.statusCode, otherEntity.statusCode) && super.equals(other)); }
From source file:com.wavemaker.commons.io.ResourcePath.java
@Override public boolean equals(Object obj) { if (obj == null) { return false; }/*from w w w.j a va 2 s. co m*/ if (obj == this) { return true; } if (obj instanceof ResourcePath) { ResourcePath other = (ResourcePath) obj; return ObjectUtils.nullSafeEquals(getParent(), other.getParent()) && this.name.equals(other.name); } return false; }
From source file:com.springsource.hq.plugin.tcserver.serverconfig.services.Service.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }/* w w w .j a v a 2 s .c om*/ if (!(obj instanceof Service)) { return false; } Service service = (Service) obj; return ObjectUtils.nullSafeEquals(this.getConnectors(), service.getConnectors()) && ObjectUtils.nullSafeEquals(this.getEngine(), service.getEngine()) && ObjectUtils.nullSafeEquals(this.getName(), service.getName()); }
From source file:com.googlecode.flyway.core.migration.sql.SqlScript.java
/** * Turns these lines in a series of statements. * * @param lines The lines to analyse.// w ww . j av a2s .c o m * * @return The statements contained in these lines (in order). */ /* private -> for testing */ List<SqlStatement> linesToStatements(List<String> lines) { List<SqlStatement> statements = new ArrayList<SqlStatement>(); int statementLineNumber = 0; String statementSql = ""; String delimiter = DEFAULT_STATEMENT_DELIMITER; for (int lineNumber = 1; lineNumber <= lines.size(); lineNumber++) { String line = lines.get(lineNumber - 1); if (!StringUtils.hasText(line)) { continue; } if (!StringUtils.hasText(statementSql)) { statementLineNumber = lineNumber; } else { statementSql += "\n"; } statementSql += line; String statementSqlWithoutLineBreaks = statementSql.replaceAll("\n", " ").replaceAll("\r", " "); if (endsWithOpenMultilineStringLiteral(statementSqlWithoutLineBreaks)) { continue; } String oldDelimiter = delimiter; delimiter = changeDelimiterIfNecessary(statementSqlWithoutLineBreaks, line, delimiter); if (!ObjectUtils.nullSafeEquals(delimiter, oldDelimiter)) { if (isDelimiterChangeExplicit()) { statementSql = ""; continue; } } if ((delimiter != null) && line.toUpperCase().endsWith(delimiter.toUpperCase())) { String noDelimiterStatementSql = stripDelimiter(statementSql, delimiter); statements.add(new SqlStatement(statementLineNumber, noDelimiterStatementSql)); LOG.debug("Found statement at line " + statementLineNumber + ": " + statementSql); if (!isDelimiterChangeExplicit()) { delimiter = DEFAULT_STATEMENT_DELIMITER; } statementSql = ""; } } // Catch any statements not followed by delimiter. if (StringUtils.hasText(statementSql)) { statements.add(new SqlStatement(statementLineNumber, statementSql)); } return statements; }