| # HG changeset patch |
| # Parent 698e9f1d6348fc1066ceaac7d264cbbf63bdcd21 |
| diff --git a/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java b/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java |
| --- a/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java |
| +++ b/src/main/java/org/yaml/snakeyaml/introspector/PropertyUtils.java |
| @@ -15,11 +15,7 @@ |
| */ |
| package org.yaml.snakeyaml.introspector; |
| |
| -import java.beans.IntrospectionException; |
| -import java.beans.Introspector; |
| -import java.beans.PropertyDescriptor; |
| import java.lang.reflect.Field; |
| -import java.lang.reflect.Method; |
| import java.lang.reflect.Modifier; |
| import java.util.Collection; |
| import java.util.HashMap; |
| @@ -37,64 +33,31 @@ |
| private BeanAccess beanAccess = BeanAccess.DEFAULT; |
| private boolean allowReadOnlyProperties = false; |
| |
| - protected Map<String, Property> getPropertiesMap(Class<?> type, BeanAccess bAccess) |
| - throws IntrospectionException { |
| + protected Map<String, Property> getPropertiesMap(Class<?> type, BeanAccess bAccess) { |
| if (propertiesCache.containsKey(type)) { |
| return propertiesCache.get(type); |
| } |
| |
| Map<String, Property> properties = new LinkedHashMap<String, Property>(); |
| - boolean inaccessableFieldsExist = false; |
| - switch (bAccess) { |
| - case FIELD: |
| - for (Class<?> c = type; c != null; c = c.getSuperclass()) { |
| - for (Field field : c.getDeclaredFields()) { |
| - int modifiers = field.getModifiers(); |
| - if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers) |
| - && !properties.containsKey(field.getName())) { |
| - properties.put(field.getName(), new FieldProperty(field)); |
| - } |
| + for (Class<?> c = type; c != null; c = c.getSuperclass()) { |
| + for (Field field : c.getDeclaredFields()) { |
| + int modifiers = field.getModifiers(); |
| + if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers) |
| + && !properties.containsKey(field.getName())) { |
| + properties.put(field.getName(), new FieldProperty(field)); |
| } |
| } |
| - break; |
| - default: |
| - // add JavaBean properties |
| - for (PropertyDescriptor property : Introspector.getBeanInfo(type) |
| - .getPropertyDescriptors()) { |
| - Method readMethod = property.getReadMethod(); |
| - if (readMethod == null || !readMethod.getName().equals("getClass")) { |
| - properties.put(property.getName(), new MethodProperty(property)); |
| - } |
| - } |
| + } |
| |
| - // add public fields |
| - for (Class<?> c = type; c != null; c = c.getSuperclass()) { |
| - for (Field field : c.getDeclaredFields()) { |
| - int modifiers = field.getModifiers(); |
| - if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)) { |
| - if (Modifier.isPublic(modifiers)) { |
| - properties.put(field.getName(), new FieldProperty(field)); |
| - } else { |
| - inaccessableFieldsExist = true; |
| - } |
| - } |
| - } |
| - } |
| - break; |
| - } |
| - if (properties.isEmpty() && inaccessableFieldsExist) { |
| - throw new YAMLException("No JavaBean properties found in " + type.getName()); |
| - } |
| propertiesCache.put(type, properties); |
| return properties; |
| } |
| |
| - public Set<Property> getProperties(Class<? extends Object> type) throws IntrospectionException { |
| + public Set<Property> getProperties(Class<? extends Object> type) { |
| return getProperties(type, beanAccess); |
| } |
| |
| - public Set<Property> getProperties(Class<? extends Object> type, BeanAccess bAccess) |
| - throws IntrospectionException { |
| + public Set<Property> getProperties(Class<? extends Object> type, BeanAccess bAccess) { |
| if (readableProperties.containsKey(type)) { |
| return readableProperties.get(type); |
| } |
| @@ -103,8 +66,7 @@ |
| return properties; |
| } |
| |
| - protected Set<Property> createPropertySet(Class<? extends Object> type, BeanAccess bAccess) |
| - throws IntrospectionException { |
| + protected Set<Property> createPropertySet(Class<? extends Object> type, BeanAccess bAccess) { |
| Set<Property> properties = new TreeSet<Property>(); |
| Collection<Property> props = getPropertiesMap(type, bAccess).values(); |
| for (Property property : props) { |
| @@ -115,13 +77,11 @@ |
| return properties; |
| } |
| |
| - public Property getProperty(Class<? extends Object> type, String name) |
| - throws IntrospectionException { |
| + public Property getProperty(Class<? extends Object> type, String name) { |
| return getProperty(type, name, beanAccess); |
| } |
| |
| - public Property getProperty(Class<? extends Object> type, String name, BeanAccess bAccess) |
| - throws IntrospectionException { |
| + public Property getProperty(Class<? extends Object> type, String name, BeanAccess bAccess) { |
| Map<String, Property> properties = getPropertiesMap(type, bAccess); |
| Property property = properties.get(name); |
| if (property == null || !property.isWritable()) { |