Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions src/main/java/org/apache/commons/beanutils2/BeanUtilsBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
import org.apache.commons.logging.LogFactory;

/**
* <p>JavaBean property population methods.</p>
* <p>JavaBean property population methods, delegating
* conversions to {@link ConvertUtilsBean#convert(Object, Class)}.</p>
*
* <p>This class provides implementations for the utility methods in
* {@link BeanUtils}.
Expand Down Expand Up @@ -214,23 +215,12 @@ public Object cloneBean(final Object bean)
* <p>Converts the value to an object of the specified class (if
* possible).</p>
*
* @param <R> The desired return type
* @param value Value to be converted (may be null)
* @param type Class of the value to be converted to
* @return The converted value
*
* @throws ConversionException if thrown by an underlying Converter
* @since 1.8.0
*/
protected <R> Object convert(final Object value, final Class<R> type) {
final Converter<R> converter = getConvertUtils().lookup(type);
if (converter != null) {
if (LOG.isTraceEnabled()) {
LOG.trace(" USING CONVERTER " + converter);
}
return converter.convert(type, value);
}
return value;
return getConvertUtils().convert(value, type);
}

/**
Expand Down
75 changes: 0 additions & 75 deletions src/main/java/org/apache/commons/beanutils2/BeanUtilsBean2.java

This file was deleted.

26 changes: 6 additions & 20 deletions src/main/java/org/apache/commons/beanutils2/ConvertUtilsBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
* <li>java.time.ZoneId (no default value)</li>
* <li>java.time.ZoneOffset (no default value)</li>
* </ul>
* <p>Every other convert method will be delegated to {@link ConvertUtilsBean#convert(Object, Class)}.</p>
*
* <p>For backwards compatibility, the standard Converters for primitive
* types (and the corresponding wrapper classes) return a defined
Expand Down Expand Up @@ -307,32 +308,17 @@ public <T> Object convert(final Object value, final Class<T> targetType) {
}

/**
* Convert the specified value to an object of the specified class (if
* possible). Otherwise, return a {@link String} representation of the value.
* Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)}
* method.
*
* @param <T> The <em>desired</em> return type
* @param value Value to be converted (may be null)
* @param clazz Java class to be converted to (must not be null)
* @return The converted value
* @return The converted value or null if value is null
*
* @throws ConversionException if thrown by an underlying Converter
* @see ConvertUtilsBean#convert(String[], Class)
*/
public <T> Object convert(final String value, final Class<T> clazz) {
if (LOG.isDebugEnabled()) {
LOG.debug("Convert string '" + value + "' to class '" + clazz.getName() + "'");
}
final Converter<T> converter = lookup(clazz);
if (converter == null) {
final Converter<String> sConverter = lookup(String.class);
if (LOG.isTraceEnabled()) {
LOG.trace(" Using converter " + converter);
}
return sConverter.convert(String.class, value);
}
if (LOG.isTraceEnabled()) {
LOG.trace(" Using converter " + converter);
}
return converter.convert(clazz, value);
return convert((Object) value, clazz);
}

/**
Expand Down
77 changes: 0 additions & 77 deletions src/main/java/org/apache/commons/beanutils2/ConvertUtilsBean2.java

This file was deleted.

Loading