Java Code Examples for org.springframework.util.ObjectUtils#nullSafeToString()
The following examples show how to use
org.springframework.util.ObjectUtils#nullSafeToString() .
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: AbstractFactoryBean.java From blog_demos with Apache License 2.0 | 6 votes |
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (ReflectionUtils.isEqualsMethod(method)) { // Only consider equal when proxies are identical. return (proxy == args[0]); } else if (ReflectionUtils.isHashCodeMethod(method)) { // Use hashCode of reference proxy. return System.identityHashCode(proxy); } else if (!initialized && ReflectionUtils.isToStringMethod(method)) { return "Early singleton proxy for interfaces " + ObjectUtils.nullSafeToString(getEarlySingletonInterfaces()); } try { return method.invoke(getSingletonInstance(), args); } catch (InvocationTargetException ex) { throw ex.getTargetException(); } }
Example 2
Source File: DefaultPersistenceUnitManager.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public PersistenceUnitInfo obtainDefaultPersistenceUnitInfo() { if (this.persistenceUnitInfoNames.isEmpty()) { throw new IllegalStateException("No persistence units parsed from " + ObjectUtils.nullSafeToString(this.persistenceXmlLocations)); } if (this.persistenceUnitInfos.isEmpty()) { throw new IllegalStateException("All persistence units from " + ObjectUtils.nullSafeToString(this.persistenceXmlLocations) + " already obtained"); } if (this.persistenceUnitInfos.size() > 1) { return obtainPersistenceUnitInfo(this.defaultPersistenceUnitName); } PersistenceUnitInfo pui = this.persistenceUnitInfos.values().iterator().next(); this.persistenceUnitInfos.clear(); return pui; }
Example 3
Source File: DefaultPersistenceUnitManager.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public PersistenceUnitInfo obtainDefaultPersistenceUnitInfo() { if (this.persistenceUnitInfoNames.isEmpty()) { throw new IllegalStateException("No persistence units parsed from " + ObjectUtils.nullSafeToString(this.persistenceXmlLocations)); } if (this.persistenceUnitInfos.isEmpty()) { throw new IllegalStateException("All persistence units from " + ObjectUtils.nullSafeToString(this.persistenceXmlLocations) + " already obtained"); } if (this.persistenceUnitInfos.size() > 1) { return obtainPersistenceUnitInfo(this.defaultPersistenceUnitName); } PersistenceUnitInfo pui = this.persistenceUnitInfos.values().iterator().next(); this.persistenceUnitInfos.clear(); return pui; }
Example 4
Source File: DefaultPersistenceUnitManager.java From java-technology-stack with MIT License | 6 votes |
@Override public PersistenceUnitInfo obtainDefaultPersistenceUnitInfo() { if (this.persistenceUnitInfoNames.isEmpty()) { throw new IllegalStateException("No persistence units parsed from " + ObjectUtils.nullSafeToString(this.persistenceXmlLocations)); } if (this.persistenceUnitInfos.isEmpty()) { throw new IllegalStateException("All persistence units from " + ObjectUtils.nullSafeToString(this.persistenceXmlLocations) + " already obtained"); } if (this.persistenceUnitInfos.size() > 1 && this.defaultPersistenceUnitName != null) { return obtainPersistenceUnitInfo(this.defaultPersistenceUnitName); } PersistenceUnitInfo pui = this.persistenceUnitInfos.values().iterator().next(); this.persistenceUnitInfos.clear(); return pui; }
Example 5
Source File: AbstractFactoryBean.java From spring-analysis-note with MIT License | 6 votes |
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (ReflectionUtils.isEqualsMethod(method)) { // Only consider equal when proxies are identical. return (proxy == args[0]); } else if (ReflectionUtils.isHashCodeMethod(method)) { // Use hashCode of reference proxy. return System.identityHashCode(proxy); } else if (!initialized && ReflectionUtils.isToStringMethod(method)) { return "Early singleton proxy for interfaces " + ObjectUtils.nullSafeToString(getEarlySingletonInterfaces()); } try { return method.invoke(getSingletonInstance(), args); } catch (InvocationTargetException ex) { throw ex.getTargetException(); } }
Example 6
Source File: ApplicationMetricsProperties.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
private Map<String, Object> buildExportProperties() { Map<String, Object> props = new HashMap<>(); if (!ObjectUtils.isEmpty(this.properties)) { Map<String, String> target = bindProperties(); BeanExpressionResolver beanExpressionResolver = ((ConfigurableApplicationContext) this.applicationContext) .getBeanFactory().getBeanExpressionResolver(); BeanExpressionContext expressionContext = new BeanExpressionContext( ((ConfigurableApplicationContext) this.applicationContext) .getBeanFactory(), null); for (Entry<String, String> entry : target.entrySet()) { if (isMatch(entry.getKey(), this.properties, null)) { String stringValue = ObjectUtils.nullSafeToString(entry.getValue()); Object exportedValue = null; if (stringValue != null) { exportedValue = stringValue.startsWith("#{") ? beanExpressionResolver.evaluate( this.environment.resolvePlaceholders(stringValue), expressionContext) : this.environment.resolvePlaceholders(stringValue); } props.put(entry.getKey(), exportedValue); } } } return props; }
Example 7
Source File: DefaultListableBeanFactory.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Raise a NoSuchBeanDefinitionException for an unresolvable dependency. */ private void raiseNoSuchBeanDefinitionException( Class<?> type, String dependencyDescription, DependencyDescriptor descriptor) throws NoSuchBeanDefinitionException { throw new NoSuchBeanDefinitionException(type, dependencyDescription, "expected at least 1 bean which qualifies as autowire candidate for this dependency. " + "Dependency annotations: " + ObjectUtils.nullSafeToString(descriptor.getAnnotations())); }
Example 8
Source File: ConversionFailedException.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a new conversion exception. * @param sourceType the value's original type * @param targetType the value's target type * @param value the value we tried to convert * @param cause the cause of the conversion failure */ public ConversionFailedException(TypeDescriptor sourceType, TypeDescriptor targetType, Object value, Throwable cause) { super("Failed to convert from type [" + sourceType + "] to type [" + targetType + "] for value '" + ObjectUtils.nullSafeToString(value) + "'", cause); this.sourceType = sourceType; this.targetType = targetType; this.value = value; }
Example 9
Source File: SimpleStatsResult.java From dubbox with Apache License 2.0 | 4 votes |
@Override public String getMinAsString() { return ObjectUtils.nullSafeToString(min); }
Example 10
Source File: RegexpMethodPointcutAdvisor.java From java-technology-stack with MIT License | 4 votes |
@Override public String toString() { return getClass().getName() + ": advice [" + getAdvice() + "], pointcut patterns " + ObjectUtils.nullSafeToString(this.patterns); }
Example 11
Source File: RegexpMethodPointcutAdvisor.java From spring-analysis-note with MIT License | 4 votes |
@Override public String toString() { return getClass().getName() + ": advice [" + getAdvice() + "], pointcut patterns " + ObjectUtils.nullSafeToString(this.patterns); }
Example 12
Source File: FieldError.java From java-technology-stack with MIT License | 4 votes |
@Override public String toString() { return "Field error in object '" + getObjectName() + "' on field '" + this.field + "': rejected value [" + ObjectUtils.nullSafeToString(this.rejectedValue) + "]; " + resolvableToString(); }
Example 13
Source File: RegexpMethodPointcutAdvisor.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public String toString() { return getClass().getName() + ": advice [" + getAdvice() + "], pointcut patterns " + ObjectUtils.nullSafeToString(this.patterns); }
Example 14
Source File: SimpleStatsResult.java From dubbox with Apache License 2.0 | 4 votes |
@Override public String getMaxAsString() { return ObjectUtils.nullSafeToString(max); }
Example 15
Source File: RegexpMethodPointcutAdvisor.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public String toString() { return getClass().getName() + ": advice [" + getAdvice() + "], pointcut patterns " + ObjectUtils.nullSafeToString(this.patterns); }
Example 16
Source File: Inventor.java From spring4-understanding with Apache License 2.0 | 4 votes |
public String printDoubles(double[] d) { return ObjectUtils.nullSafeToString(d); }
Example 17
Source File: AbstractSpringContextTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
private final String contextKey(String... locations) { return ObjectUtils.nullSafeToString(locations); }
Example 18
Source File: AbstractRegexpMethodPointcut.java From spring-analysis-note with MIT License | 4 votes |
@Override public String toString() { return getClass().getName() + ": patterns " + ObjectUtils.nullSafeToString(this.patterns) + ", excluded patterns " + ObjectUtils.nullSafeToString(this.excludedPatterns); }
Example 19
Source File: AssertionErrors.java From spring-analysis-note with MIT License | 3 votes |
/** * Assert two objects are not equal and raise an {@link AssertionError} otherwise. * <p>For example: * <pre class="code"> * assertNotEquals("Response header [" + name + "]", expected, actual); * </pre> * @param message describes the value being checked * @param expected the expected value * @param actual the actual value */ public static void assertNotEquals(String message, @Nullable Object expected, @Nullable Object actual) { if (ObjectUtils.nullSafeEquals(expected, actual)) { throw new AssertionError(message + " was not expected to be:" + "<" + ObjectUtils.nullSafeToString(actual) + ">"); } }
Example 20
Source File: AssertionErrors.java From java-technology-stack with MIT License | 3 votes |
/** * Assert two objects are not equal and raise an {@link AssertionError} otherwise. * <p>For example: * <pre class="code"> * assertNotEquals("Response header [" + name + "]", expected, actual); * </pre> * @param message describes the value being checked * @param expected the expected value * @param actual the actual value */ public static void assertNotEquals(String message, @Nullable Object expected, @Nullable Object actual) { if (ObjectUtils.nullSafeEquals(expected, actual)) { throw new AssertionError(message + " was not expected to be:" + "<" + ObjectUtils.nullSafeToString(actual) + ">"); } }