JavaTuples containsAll() method
The containsAll() method in org.javatuples is used to check whether a collection of values is present in the TupleClass, given as parameters. This method can be used for any tuple class object of the javatuples library. It returns a boolean value that is true or false based on the presence of that collection of values in the TupleClass.
Method Declaration:
public final boolean containsAll(Object... value)
Syntax:
boolean result = TupleClassObject.containsAll(X value1, X value2, ...)
OR
boolean result = TupleClassObject.containsAll(X[] values)
Parameters: This method takes value or values as parameter where:
- X– represents the datatype of values in the parameter.
- TupleClassObject– represents the JavaTuple Class object used like Unit, Quintet, Decade, etc.
Return Value: This method returns true if the parameter value are present in the tuple. Else it returns false
Below programs illustrate the various ways to use containsAll() method:
Program 1: Using containsAll() with Unit class:
// Below is a Java program to use containsAll() method import java.util.*; import org.javatuples.Unit; class GfG { public static void main(String[] args) { // Creating an Unit with one value Unit<String> unit = Unit.with("GeeksforGeeks"); // Using containsAll() method boolean res; // for True result String[] check = { "GeeksforGeeks" }; res = unit.containsAll(check); System.out.println("Is " + Arrays.toString(check) + " present : " + res); // for False result String[] check1 = { "Geeks", "for", "Geeks" }; res = unit.containsAll(check1); System.out.println("Is " + Arrays.toString(check1) + " present : " + res); } } |
Output:
Is [GeeksforGeeks] present : true Is [Geeks, for, Geeks] present : false
Program 2: Using containsAll() with Decade class:
// Below is a Java program to use containsAll() method import java.util.*; import org.javatuples.Decade; class GfG { public static void main(String[] args) { // Creating a Decade with 10 value Decade<String, String, String, String, String, String, String, String, String, String> decade = Decade.with("Geeks", "for", "Geeks", "A", "Computer", "Science", "Portal", "for", "Geeks", "RishabhPrabhu"); // Using containsAll() method boolean res; // for true result String[] check = { "Geeks", "for", "Geeks" }; res = decade.containsAll(check); System.out.println("Is " + Arrays.toString(check) + " present : " + res); // for False result String[] check1 = { "Geeks", "not", "for", "Geeks" }; res = decade.containsAll(check1); System.out.println("Is " + Arrays.toString(check1) + " present : " + res); } } |
Output:
Is [Geeks, for, Geeks] present : true Is [Geeks, not, for, Geeks] present : false
Note: Similarly, it can be used with any other JavaTuple Class.
Recommended Posts:
- Set containsAll() method in Java with Examples
- HashSet containsAll() method in Java with Example
- CopyOnWriteArraySet containsAll() method in Java with Example
- Stack containsAll() method in Java with Example
- AbstractSet containsAll() method in Java with Example
- Vector containsAll() Method in Java
- CopyOnWriteArrayList containsAll() method in Java
- LinkedHashSet containsAll() method in Java with Example
- TreeSet containsAll() method in Java with Example
- AbstractCollection containsAll() Method in Java with Examples
- SortedSet containsAll() method in Java with Examples
- List containsAll() method in Java with Examples
- JavaTuples contains() method
- JavaTuples add() method
- JavaTuples with() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



