Java tutorial
//package com.java2s; import java.util.Collection; import com.google.common.collect.Sets; public class Main { public static <T> boolean isNotEmptyAndElementsInCollectionTheSame(Collection<T> colllection) { return !colllection.isEmpty() && (Sets.newHashSet(colllection).size() == 1); } }