001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.beanutils; 018 019/** 020 * {@link ConvertUtilsBean} implementation that delegates <code>convert()</code> 021 * methods to the new {@link ConvertUtilsBean#convert(Object, Class)} method. 022 * 023 * <p> 024 * To configure this implementation for the current context ClassLoader invoke 025 * <code>BeanUtilsBean.setInstance(new BeanUtilsBean2());</code> 026 * </p> 027 * 028 * @see BeanUtilsBean2 029 * @since 1.8.0 030 */ 031public class ConvertUtilsBean2 extends ConvertUtilsBean { 032 033 /** 034 * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)} 035 * method. 036 * 037 * @param value Value to be converted (may be null) 038 * @return The converted String value or null if value is null 039 * @see ConvertUtilsBean#convert(String[], Class) 040 */ 041 @Override 042 public String convert(final Object value) { 043 return (String)convert(value, String.class); 044 } 045 046 /** 047 * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)} 048 * method. 049 * 050 * @param value Value to be converted (may be null) 051 * @param clazz Java class to be converted to (must not be null) 052 * @return The converted value or null if value is null 053 * @see ConvertUtilsBean#convert(String[], Class) 054 */ 055 @Override 056 public Object convert(final String value, final Class<?> clazz) { 057 return convert((Object)value, clazz); 058 } 059 060 /** 061 * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)} 062 * method. 063 * 064 * @param value Array of values to be converted 065 * @param clazz Java array or element class to be converted to (must not be null) 066 * @return The converted value 067 * @see ConvertUtilsBean#convert(String[], Class) 068 */ 069 @Override 070 public Object convert(final String[] value, final Class<?> clazz) { 071 return convert((Object)value, clazz); 072 } 073 074}