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