Committed by
Gerrit Code Review
isBoolean addition
Change-Id: I83d428702314e6cd81f35b8bbbd04eed597cc04d
Showing
1 changed file
with
13 additions
and
1 deletions
... | @@ -459,6 +459,19 @@ public abstract class Config<S> { | ... | @@ -459,6 +459,19 @@ public abstract class Config<S> { |
459 | } | 459 | } |
460 | 460 | ||
461 | /** | 461 | /** |
462 | + * Indicates whether the specified field holds a valid boolean value. | ||
463 | + * | ||
464 | + * @param field JSON field name | ||
465 | + * @param presence specifies if field is optional or mandatory | ||
466 | + * @return true if valid; false otherwise | ||
467 | + * @throws IllegalArgumentException if field is present, but not valid | ||
468 | + */ | ||
469 | + protected boolean isBoolean(String field, FieldPresence presence) { | ||
470 | + JsonNode node = object.path(field); | ||
471 | + return isValid(node, presence, node.isBoolean()); | ||
472 | + } | ||
473 | + | ||
474 | + /** | ||
462 | * Indicates whether the node is present and of correct value or not | 475 | * Indicates whether the node is present and of correct value or not |
463 | * mandatory and absent. | 476 | * mandatory and absent. |
464 | * | 477 | * |
... | @@ -471,5 +484,4 @@ public abstract class Config<S> { | ... | @@ -471,5 +484,4 @@ public abstract class Config<S> { |
471 | boolean isMandatory = presence == FieldPresence.MANDATORY; | 484 | boolean isMandatory = presence == FieldPresence.MANDATORY; |
472 | return isMandatory && correctValue || !isMandatory && !node.isNull() || correctValue; | 485 | return isMandatory && correctValue || !isMandatory && !node.isNull() || correctValue; |
473 | } | 486 | } |
474 | - | ||
475 | } | 487 | } | ... | ... |
-
Please register or login to post a comment