Coverage Report - org.apache.commons.beanutils.converters.ConverterFacade
 
Classes in this File Line Coverage Branch Coverage Complexity
ConverterFacade
85%
6/7
50%
1/2
1.667
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.commons.beanutils.converters;
 18  
 
 19  
 import org.apache.commons.beanutils.Converter;
 20  
 
 21  
 /**
 22  
  * Provides a facade for {@link Converter} implementations
 23  
  * preventing access to any public API in the implementation,
 24  
  * other than that specified by {@link Converter}.
 25  
  * <p />
 26  
  * This implementation can be used to prevent registered {@link Converter}
 27  
  * implementations that provide configuration options from being
 28  
  * retrieved and modified.
 29  
  *
 30  
  * @version $Revision: 552084 $ $Date: 2007-06-29 23:04:13 -0400 (Fri, 29 Jun 2007) $
 31  
  * @since 1.8.0
 32  
  */
 33  
 public final class ConverterFacade implements Converter {
 34  
 
 35  
     private final Converter converter;
 36  
 
 37  
     /**
 38  
      * Construct a converter which delegates to the specified
 39  
      * {@link Converter} implementation.
 40  
      *
 41  
      * @param converter The converter to delegate to
 42  
      */
 43  19936
     public ConverterFacade(Converter converter) {
 44  19936
         if (converter == null) {
 45  0
             throw new IllegalArgumentException("Converter is missing");
 46  
         }
 47  19936
         this.converter = converter;
 48  19936
     }
 49  
 
 50  
     /**
 51  
      * Convert the input object into an output object of the
 52  
      * specified type by delegating to the underlying {@link Converter}
 53  
      * implementation.
 54  
      *
 55  
      * @param type Data type to which this value should be converted
 56  
      * @param value The input value to be converted
 57  
      * @return The converted value.
 58  
      */
 59  
     public Object convert(Class type, Object value) {
 60  656
         return converter.convert(type, value);
 61  
     }
 62  
 
 63  
     /**
 64  
      * Provide a String representation of this facade implementation
 65  
      * sand the underlying {@link Converter} it delegates to.
 66  
      *
 67  
      * @return A String representation of this facade implementation
 68  
      * sand the underlying {@link Converter} it delegates to
 69  
      */
 70  
     public String toString() {
 71  205
         return "ConverterFacade[" + converter.toString() + "]";
 72  
     }
 73  
 
 74  
 }