Coverage Report - net.sf.ezmorph.object.AbstractObjectMorpher
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractObjectMorpher
100%
11/11
100%
2/2
1
 
 1  
 /*
 2  
  * Copyright 2006-2007 the original author or authors.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package net.sf.ezmorph.object;
 18  
 
 19  
 import net.sf.ezmorph.ObjectMorpher;
 20  
 
 21  
 /**
 22  
  * Base class for ObjectMorpher implementations.
 23  
  *
 24  
  * @author Andres Almiray <aalmiray@users.sourceforge.net>
 25  
  */
 26  
 public abstract class AbstractObjectMorpher implements ObjectMorpher
 27  
 {
 28  
    private boolean useDefault;
 29  
 
 30  744
    public AbstractObjectMorpher()
 31  248
    {
 32  
 
 33  992
    }
 34  
 
 35  
    /**
 36  
     * @param useDefault if morph() should return a default value if the value to
 37  
     *        be morphed is null
 38  
     */
 39  9588
    public AbstractObjectMorpher( boolean useDefault )
 40  3136
    {
 41  12724
       this.useDefault = useDefault;
 42  12724
    }
 43  
 
 44  
    /**
 45  
     * Returns if this morpher will use a default value.
 46  
     */
 47  
    public boolean isUseDefault()
 48  
    {
 49  990
       return useDefault;
 50  
    }
 51  
 
 52  
    /**
 53  
     * Sets if this morpher will use a default value.
 54  
     */
 55  
    public void setUseDefault( boolean useDefault )
 56  
    {
 57  36
       this.useDefault = useDefault;
 58  36
    }
 59  
 
 60  
    /**
 61  
     * Returns true if the Morpher supports conversion from this Class.<br>
 62  
     * Supports any type that is not an Array.
 63  
     *
 64  
     * @param clazz the source Class
 65  
     * @return true if clazz is supported by this morpher, false otherwise.
 66  
     */
 67  
    public boolean supports( Class clazz )
 68  
    {
 69  454
       return !clazz.isArray();
 70  
    }
 71  
 }