Commit b1d017ee6f8d4d2e8f31dfaf0784de5fb4e49f2c
1 parent
da9f1827
Exists in
master
Corrigido bug do extrator de ENUM onde valores não informados causavam
NullPointerException ao invés de usar o valor padrão.
Showing
1 changed file
with
11 additions
and
6 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ConfigurationEnumValueExtractor.java
... | ... | @@ -55,20 +55,25 @@ public class ConfigurationEnumValueExtractor implements ConfigurationValueExtrac |
55 | 55 | public Object getValue(String prefix, String key, Field field, Configuration configuration) throws Exception { |
56 | 56 | String value = configuration.getString(prefix + key); |
57 | 57 | |
58 | - Object enums[] = field.getDeclaringClass().getEnumConstants(); | |
59 | - | |
60 | - for (int i=0; i<enums.length; i++){ | |
61 | - if (enums[i].getClass().getSimpleName().equalsIgnoreCase(value)){ | |
62 | - return enums[i]; | |
58 | + if (value!=null){ | |
59 | + Object enums[] = field.getDeclaringClass().getEnumConstants(); | |
60 | + | |
61 | + for (int i=0; i<enums.length; i++){ | |
62 | + if (enums[i].getClass().getSimpleName().equalsIgnoreCase(value)){ | |
63 | + return enums[i]; | |
64 | + } | |
63 | 65 | } |
64 | 66 | } |
67 | + else{ | |
68 | + return null; | |
69 | + } | |
65 | 70 | |
66 | 71 | throw new ConversionException(getBundle().getString("configuration-not-conversion",value,field.getDeclaringClass().getCanonicalName())); |
67 | 72 | } |
68 | 73 | |
69 | 74 | @Override |
70 | 75 | public boolean isSupported(Field field) { |
71 | - return field.getDeclaringClass().isEnum(); | |
76 | + return field.getType().isEnum(); | |
72 | 77 | } |
73 | 78 | |
74 | 79 | private ResourceBundle getBundle(){ | ... | ... |