Let's say I have a tuple (1, 2). I want to create a stream, that gives me all possible combinations of that tuples' values. So I want to create a stream that looks like this:
[(1, 1), (1, 2), (2, 1), (2, 2)]
This is my class for my tuples:
public class Tuple<T> {
    private final T first;
    private final T second;
    public Tuple(T first, T second) {
        assert first != null;
        assert second != null;
        this.first = first;
        this.second = second;
    }
    public T getFirst() {
        return first;
    }
    public T getSecond() {
        return second;
    }
    @Override
    ...
This is my class for my tuple-set:
public class TupleSet<T> implements Set<Tuple<T>> {
    private Set<T> set;
    public TupleSet(Set<T> set) {
        this.set = set;
        //This is where I want to create my tuple-set
    }
   
    public Stream<Tuple<T>> getElements() {
    return; //This is where I want to return a stream of that tuple-set
}
How can I get my desired tuple-set using permutation?
I am aware, that there are multiple example for creating permutations, but I am struggeling with the Tuple<T>-type I have to return it in.
Tuples always have 2 elements. Although they can be created out of sets with different lenghts. If I insert the set [0, 1, 2, 3] I want to get that tuple list: [(0,0),(1,1),(2,2),(3,3),(0,1),(0,2)(0,3),(1,0),(1,2),(1,3),(2,0),(2,1),(2,3),(3,0)(3,1),(3,2)] so 16 tuple values in total.
 
    