* @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
*/
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()) {
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
* <tt>def</tt> if not.
+ * <p>
+ * DO NOT get the default meta value (MetaInfo.def()).
*
* @param key
* the key to check for
return children;
}
+ /**
+ * The number of sub-items, if any.
+ *
+ * @return the number or 0
+ */
+ public int size() {
+ return children.size();
+ }
+
@Override
public Iterator<MetaInfo<E>> iterator() {
return children.iterator();
result = "[" + key.toLowerCase() + "]";
} else if (containsKey(key)) {
result = getString(key, null);
+ if (result == null) {
+ result = getMetaDef(id.name());
+ }
} else {
result = null;
}
String name = id.name() + "_NOUTF";
if (containsKey(name)) {
String value = getString(name, null);
+ if (value == null) {
+ value = getMetaDef(id.name());
+ }
boolean set = isSet(id, false);
writeValue(writer, name, value, set);
}