From: Niki Roo Date: Wed, 30 Oct 2019 07:41:20 +0000 (+0100) Subject: Merge branch 'subtree' X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=commitdiff_plain;h=75efdb7e651001aa1141c3080a80dd92544cc08f;hp=-c Merge branch 'subtree' --- 75efdb7e651001aa1141c3080a80dd92544cc08f diff --combined src/be/nikiroo/utils/resources/Bundle.java index 0c57bf9,c757e2b..c757e2b --- a/src/be/nikiroo/utils/resources/Bundle.java +++ b/src/be/nikiroo/utils/resources/Bundle.java @@@ -95,8 -95,8 +95,8 @@@ public class Bundle> * @param name * the id of the setting to check * @param includeDefaultValue - * TRUE to only return false when the setting is not set AND - * there is no default value + * TRUE to only return false when the setting is explicitly set + * to NULL (and not just "no set") in the change maps * * @return TRUE if the setting is set */ @@@ -160,13 -160,7 +160,7 @@@ public String getString(E id, String def, int item) { String rep = getString(id.name(), null); if (rep == null) { - try { - Meta meta = type.getDeclaredField(id.name()).getAnnotation( - Meta.class); - rep = meta.def(); - } catch (NoSuchFieldException e) { - } catch (SecurityException e) { - } + rep = getMetaDef(id.name()); } if (rep == null || rep.isEmpty()) { @@@ -937,9 -931,35 +931,35 @@@ return changeMap.containsKey(key) || map.containsKey(key); } + /** + * The default {@link MetaInfo.def} value for the given enumeration name. + * + * @param id + * the enumeration name (the "id") + * + * @return the def value in the {@link MetaInfo} or "" if none (never NULL) + */ + protected String getMetaDef(String id) { + String rep = ""; + try { + Meta meta = type.getDeclaredField(id).getAnnotation(Meta.class); + rep = meta.def(); + } catch (NoSuchFieldException e) { + } catch (SecurityException e) { + } + + if (rep == null) { + rep = ""; + } + + return rep; + } + /** * Get the value for the given key if it exists in the internal map, or * def if not. + *

+ * DO NOT get the default meta value (MetaInfo.def()). * * @param key * the key to check for diff --combined src/be/nikiroo/utils/resources/MetaInfo.java index f7598f1,917c210..917c210 --- a/src/be/nikiroo/utils/resources/MetaInfo.java +++ b/src/be/nikiroo/utils/resources/MetaInfo.java @@@ -649,6 -649,15 +649,15 @@@ public class MetaInfo return children; } + /** + * The number of sub-items, if any. + * + * @return the number or 0 + */ + public int size() { + return children.size(); + } + @Override public Iterator> iterator() { return children.iterator(); diff --combined src/be/nikiroo/utils/resources/TransBundle.java index 28fa280,7b2edb1..7b2edb1 --- a/src/be/nikiroo/utils/resources/TransBundle.java +++ b/src/be/nikiroo/utils/resources/TransBundle.java @@@ -138,6 -138,9 +138,9 @@@ public class TransBundle