Here you can find the source of cast(Set> set)
public static <T> Set<T> cast(Set<?> set)
//package com.java2s; /*!// w w w.j a va 2s. c o m * mifmi-commons4j * https://github.com/mifmi/mifmi-commons4j * * Copyright (c) 2015 mifmi.org and other contributors * Released under the MIT license * https://opensource.org/licenses/MIT */ import java.util.List; import java.util.Set; public class Main { public static <T> List<T> cast(List<?> list) { @SuppressWarnings("unchecked") List<T> castList = (List<T>) list; return castList; } public static <T> Set<T> cast(Set<?> set) { @SuppressWarnings("unchecked") Set<T> castSet = (Set<T>) set; return castSet; } }