From: <iro...@us...> - 2009-08-15 16:50:30
|
Revision: 127 http://pojomatic.svn.sourceforge.net/pojomatic/?rev=127&view=rev Author: iroberts Date: 2009-08-15 16:50:24 +0000 (Sat, 15 Aug 2009) Log Message: ----------- break up long method Modified Paths: -------------- trunk/Pojomatic/src/main/java/org/pojomatic/internal/ClassProperties.java Modified: trunk/Pojomatic/src/main/java/org/pojomatic/internal/ClassProperties.java =================================================================== --- trunk/Pojomatic/src/main/java/org/pojomatic/internal/ClassProperties.java 2009-08-15 16:48:17 UTC (rev 126) +++ trunk/Pojomatic/src/main/java/org/pojomatic/internal/ClassProperties.java 2009-08-15 16:50:24 UTC (rev 127) @@ -62,28 +62,12 @@ final AutoDetectPolicy autoDetectPolicy = (autoProperty != null) ? autoProperty.autoDetect() : null; - for (Field field : clazz.getDeclaredFields()) { - Property property = field.getAnnotation(Property.class); - if (isStatic(field)) { - if (property != null) { - throw new IllegalArgumentException( - "Static field " + clazz.getName() + "." + field.getName() - + " is annotated with @Property"); - } - else { - continue; - } - } - - final PojomaticPolicy propertyPolicy = (property != null) ? property.policy() : null; + extractFields(clazz, classPolicy, autoDetectPolicy); + extractMethods(clazz, classPolicy, autoDetectPolicy); + } - /* add all fields that are explicitly annotated or auto-detected */ - if (propertyPolicy != null || AutoDetectPolicy.FIELD == autoDetectPolicy) { - addPropertyToRoles( - new PropertyField(field, getPropertyName(property)), classPolicy, propertyPolicy); - } - } - + private void extractMethods(Class<?> clazz, final DefaultPojomaticPolicy classPolicy, + final AutoDetectPolicy autoDetectPolicy) { for (Method method : clazz.getDeclaredMethods()) { Property property = method.getAnnotation(Property.class); if (isStatic(method)) { @@ -119,6 +103,31 @@ } } + private void extractFields(Class<?> clazz, final DefaultPojomaticPolicy classPolicy, + final AutoDetectPolicy autoDetectPolicy) { + for (Field field : clazz.getDeclaredFields()) { + Property property = field.getAnnotation(Property.class); + if (isStatic(field)) { + if (property != null) { + throw new IllegalArgumentException( + "Static field " + clazz.getName() + "." + field.getName() + + " is annotated with @Property"); + } + else { + continue; + } + } + + final PojomaticPolicy propertyPolicy = (property != null) ? property.policy() : null; + + /* add all fields that are explicitly annotated or auto-detected */ + if (propertyPolicy != null || AutoDetectPolicy.FIELD == autoDetectPolicy) { + addPropertyToRoles( + new PropertyField(field, getPropertyName(property)), classPolicy, propertyPolicy); + } + } + } + private void addPropertyToRoles( PropertyElement propertyElement, final DefaultPojomaticPolicy classPolicy, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |