Coverage Report - org.apache.commons.flatfile.morph.NamedEntityCollectionReflector
 
Classes in this File Line Coverage Branch Coverage Complexity
NamedEntityCollectionReflector
100%
8/8
N/A
0
 
 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.flatfile.morph;
 18  
 
 19  
 import java.util.Arrays;
 20  
 import java.util.HashSet;
 21  
 
 22  
 import net.sf.morph.reflect.BeanReflector;
 23  
 import net.sf.morph.util.ContainerUtils;
 24  
 
 25  
 import org.apache.commons.flatfile.Entity;
 26  
 import org.apache.commons.flatfile.NamedEntityCollection;
 27  
 
 28  
 /**
 29  
  * NamedEntityCollection Reflector.
 30  
  * @version $Revision: 757266 $ $Date: 2009-03-22 17:12:27 -0500 (Sun, 22 Mar 2009) $
 31  
  */
 32  6
 public class NamedEntityCollectionReflector extends
 33  
         BaseEntityCollectionReflector implements BeanReflector {
 34  1
     private static final Class<?>[] REFLECTABLE_CLASSES = { NamedEntityCollection.class };
 35  
 
 36  
     /**
 37  
      * {@inheritDoc}
 38  
      */
 39  
     protected Class<?>[] getReflectableClassesImpl() throws Exception {
 40  5
         return REFLECTABLE_CLASSES;
 41  
     }
 42  
 
 43  
     /**
 44  
      * {@inheritDoc}
 45  
      */
 46  
     protected boolean isEntity(Object bean, String propertyName)
 47  
             throws Exception {
 48  658
         return ContainerUtils.contains(((NamedEntityCollection) bean)
 49  
                 .getChildNames(), propertyName);
 50  
     }
 51  
 
 52  
     /**
 53  
      * {@inheritDoc}
 54  
      */
 55  
     protected Entity getEntity(Object bean, String propertyName)
 56  
             throws Exception {
 57  199
         return ((NamedEntityCollection) bean).getChild(propertyName);
 58  
     }
 59  
 
 60  
     /**
 61  
      * {@inheritDoc}
 62  
      */
 63  
     protected String[] getPropertyNamesImpl(Object bean) throws Exception {
 64  273
         HashSet<String> result = new HashSet<String>(Arrays.asList(super
 65  
                 .getPropertyNamesImpl(bean)));
 66  273
         result.addAll(Arrays.asList(((NamedEntityCollection) bean)
 67  
                 .getChildNames()));
 68  273
         return result.toArray(new String[result.size()]);
 69  
     }
 70  
 
 71  
 }