private Set<Property> getPropertiesForClass( Class<?> clazz ) {
Map<String, Property> properties = new HashMap<String, Property>();
Access access = clazz.getAnnotation( Access.class );
AccessMode mode = access == null ? configuration.getDefaultAccessMode() : access.value();
for ( Field item : clazz.getDeclaredFields() ) {
Property property = PropertyFactory.createProperty( item, mode );
if ( property != null ) {
properties.put( property.getName(), property );
}
}
for ( Method item : clazz.getDeclaredMethods() ) {
Property property = PropertyFactory.createProperty( item, mode );
if ( property != null ) {
if ( properties.containsKey( property.getName() ) ) {
Property current = properties.get( property.getName() );
if ( current.isExplicit() && property.isExplicit() ) {
throw new InvalidPropertyException(
property.getName(),
property.getDeclaringClass(),
"Property %s (in %s) is explicitly defined with @Property as both field and method properties; Moo expects no more than one annotation per property name per class." );
} else if ( !current.isExplicit() && property.isExplicit() ) {
properties.put( property.getName(), property );
}
} else {
properties.put( property.getName(), property );
}