Thymeleaf utility methods for Maps

January 04, 2020 No comments Thymeleaf Utility Maps

1. Introduction

Thymeleaf is the template engine for Java-based applications. In this article, we will present utility methods for Maps. The implementation of Maps utility methods can be found in the official Thymeleaf GitHub Repository.

2. Available utility methods for Maps

Thymeleaf comes with several utility methods for Maps.

Method Purpose Description
${#maps.size(map)}

Compute size
${#maps.isEmpty(map)}

Check whether map is empty
${#maps.containsKey(map, key)}
${#maps.containsAllKeys(map, keys)}
${#maps.containsValue(map, value)}
${#maps.containsAllValues(map, value)}

Check if key/s or value/s are contained in maps

3. Conclusion

In this article, we presented Thymeleaf utility methods for Java Map objects. The utility should be useful to find out what is the size of a Map or check if it contains specified keys or values.

{{ message }}

{{ 'Comments are closed.' | trans }}