Thymeleaf utility methods for Sets

January 04, 2020 No comments Thymeleaf Utility Sets

1. Introduction

Thymeleaf is created for the Java-based application template engine. The engine has many helper classes and utility methods for processing any kind of a variable. In this article, we will present utility methods for Sets. The implementation of Sets utility methods can be found in the official Thymeleaf GitHub Repository.

2. Available utility methods for Sets

Thymeleaf comes with several utility methods for Sets.

Method Purpose Description
${#sets.toSet(object)}

Converts to set
${#sets.size(set)}

Compute size
${#sets.isEmpty(set)}

Check whether set is empty
${#sets.contains(set, element)}
${#sets.containsAll(set, elements)}

Check if element or elements are contained in set

3. Conclusion

In this article, we presented Thymeleaf utility methods for Set objects. Set is a Java collection of unique elements. Thymeleaf utility methods allow you to check if Set is empty, or contains an element or many elements or check the size of your collection.

{{ message }}

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