Skip to content

Commit

Permalink
null safety
Browse files Browse the repository at this point in the history
  • Loading branch information
davydotcom committed Apr 25, 2023
1 parent 6e885fc commit d891da7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ Using gradle one can include the hcl4j dependency like so:

```groovy
dependencies {
compile "com.bertramlabs.plugins:hcl4j:0.6.8"
compile "com.bertramlabs.plugins:hcl4j:0.7.0"
}
```

## What's New

* **0.7.0** Adding some null safety on some of the base functions
* **0.6.9** Fixed some null pointer issues if content on base64encode was null and some exceptions on array traversal
* **0.6.8** Fixed ! (not) operator and added base64encode, base64decode, textdecodebase64, textencodebase64
* **0.6.7** Fixed operators called on variables without spaces
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ext {


group = 'com.bertramlabs.plugins'
version = '0.6.9'
version = '0.7.0'

ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
sourceCompatibility = "1.8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@
public class HCLBaseFunctions {
static void registerBaseFunctions(HCLParser parser) {
parser.registerFunction("upper", (arguments) -> {
if(arguments.size() > 0) {
if(arguments.size() > 0 && arguments.get(0) != null) {
return arguments.get(0).toString().toUpperCase(Locale.ROOT);
}
return null;
});

parser.registerFunction("lower", (arguments) -> {
if(arguments.size() > 0) {
if(arguments.size() > 0 && arguments.get(0) != null) {
return arguments.get(0).toString().toLowerCase(Locale.ROOT);
}
return null;
});

parser.registerFunction("format", (arguments) -> {
if(arguments.size() > 0) {
if(arguments.size() > 0 && arguments.get(0) != null) {
String val = arguments.get(0).toString();
ArrayList<Object> args = new ArrayList<>();
for(int x=1;x<arguments.size();x++) {
Expand All @@ -51,23 +51,23 @@ static void registerBaseFunctions(HCLParser parser) {


parser.registerFunction("trimspace", (arguments) -> {
if(arguments.size() > 0) {
if(arguments.size() > 0 && arguments.get(0) != null) {
return arguments.get(0).toString();
}
return null;
});


parser.registerFunction("trim", (arguments) -> {
if(arguments.size() > 0) {
if(arguments.size() > 0 && arguments.get(0) != null) {
return arguments.get(0).toString();
}
return null;
});


parser.registerFunction("strrev", (arguments) -> {
if(arguments.size() > 0) {
if(arguments.size() > 0 && arguments.get(0) != null) {
String str = arguments.get(0).toString();
String reversed = "";
char ch;
Expand Down

0 comments on commit d891da7

Please sign in to comment.