Skip to content

Commit

Permalink
add property support methods
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <[email protected]>
  • Loading branch information
ceki committed Mar 16, 2024
1 parent a683616 commit 89e4504
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,47 @@ public Map<String, String> getCopyOfPropertyMap() {
return variableSubstitutionsHelper.getCopyOfPropertyMap();
}

public boolean isNull(String k) {
String val = OptionHelper.propertyLookup(k, this, context);
return (val == null);
}

/**
* Method used in conditional evaluation
*
* @param k a property name
* @return true if the property is defined
* @since 1.5.4
*/
public boolean isDefined(String k) {
String val = OptionHelper.propertyLookup(k, this, context);
return (val != null);
}

/**
* Shorthand for {@link #property(String)}.
*
* @param k a property name
* @return value of property k
* @since 1.5.4
*/
public String p(String k) {
return property(k);
}

/**
* Return the value of the property named k. If the value is null, then the
* empty string is returned to avoid null checks.
*
* @param k property name
* @return the value of the property named k
* @since 1.5.4
*/
public String property(String k) {
String val = OptionHelper.propertyLookup(k, this, context);
if (val != null)
return val;
else
return "";
}
}

0 comments on commit 89e4504

Please sign in to comment.