    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     * Constructs a new instance.
    035     */
    036    public ConvertUtilsBean2() {
    037        // empty
    038    }
    039
    040    /**
    041     * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)}
    042     * method.
    043     *
    044     * @param value Value to be converted (may be null)
    045     * @return The converted String value or null if value is null
    046     * @see ConvertUtilsBean#convert(String[], Class)
    047     */
    048    @Override
    049    public String convert(final Object value) {
    050        return (String)convert(value, String.class);
    051    }
    052
    053    /**
    054     * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)}
    055     * method.
    056     *
    057     * @param value Value to be converted (may be null)
    058     * @param clazz Java class to be converted to (must not be null)
    059     * @return The converted value or null if value is null
    060     * @see ConvertUtilsBean#convert(String[], Class)
    061     */
    062    @Override
    063    public Object convert(final String value, final Class<?> clazz) {
    064        return convert((Object)value, clazz);
    065    }
    066
    067    /**
    068     * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)}
    069     * method.
    070     *
    071     * @param value Array of values to be converted
    072     * @param clazz Java array or element class to be converted to (must not be null)
    073     * @return The converted value
    074     * @see ConvertUtilsBean#convert(String[], Class)
    075     */
    076    @Override
    077    public Object convert(final String[] value, final Class<?> clazz) {
    078        return convert((Object)value, clazz);
    079    }
    080
    081}