Author: tchemit Date: 2014-04-27 15:34:28 +0200 (Sun, 27 Apr 2014) New Revision: 1347 Url: http://forge.nuiton.org/projects/eugene/repository/revisions/1347 Log: refs #3175: Improve Stereotype and TagValue API Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValues.java Modified: trunk/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValues.java =================================================================== --- trunk/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValues.java 2014-04-27 12:17:19 UTC (rev 1346) +++ trunk/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/TagValues.java 2014-04-27 13:34:28 UTC (rev 1347) @@ -34,11 +34,34 @@ public class TagValues { /** + * Seek for a Boolean tag value. + * <p/> + * Will first the tag value using the method {@link #findTagValue(String, TagValueAble...)}. + * <p/> + * If not found, return {@code null}, otherwise return boolean value (case is ignored). + * <p/> + * <strong>Note:</strong> Order of {@code elements} is important, better then to + * always starts from specialized to more general level (for example from attribute, + * to classifier or model). + * + * @param tagName tag name to find + * @param elements not null elements to test + * @return found boolean tag value or {@code null} if tag value not found. + * @since 2.9 + */ + public static Boolean findNullableBooleanTagValue(String tagName, TagValueAble... elements) { + + String value = findTagValue(tagName, elements); + return value == null ? null : "true".equalsIgnoreCase(value); + + } + + /** * Seek for a boolean tag value. * <p/> * Will first the tag value using the method {@link #findTagValue(String, TagValueAble...)}. * <p/> - * If found, return {@code true}, if the value is not null and is {@code "true"} String value. + * If found, return {@code true}, if the value is not null and is {@code "true"} String value (case is ignored). * <p/> * <strong>Note:</strong> Order of {@code elements} is important, better then to * always starts from specialized to more general level (for example from attribute, @@ -47,13 +70,13 @@ * @param tagName tag name to find * @param elements not null elements to test * @return found boolean tag value or {@code false} if tag value is not found, nor having - * exactly {@code "true"} value. + * {@code "true"} value (case is ignored). * @since 2.9 */ public static boolean findBooleanTagValue(String tagName, TagValueAble... elements) { String value = findTagValue(tagName, elements); - return value != null && "true".equals(value); + return value != null && "true".equalsIgnoreCase(value); } @@ -98,7 +121,7 @@ } } return null; - + } public static String findNotEmptyTagValue(String tagName, TagValueAble element) {