| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 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 | |
|
| 28 | |
|
| 29 | |
|
| 30 | 36 | public class NamedEntityCollectionReflector extends |
| 31 | |
BaseEntityCollectionReflector implements BeanReflector { |
| 32 | 6 | private static final Class<?>[] REFLECTABLE_CLASSES = { NamedEntityCollection.class }; |
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
@Override |
| 38 | |
protected Class<?>[] getReflectableClassesImpl() throws Exception { |
| 39 | 30 | return REFLECTABLE_CLASSES; |
| 40 | |
} |
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 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 | |
|
| 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 | |
|
| 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 | |
} |