Here you can find the source of enumFromSet(EnumSet
public static <E extends Enum<E>> E enumFromSet(EnumSet<E> theSet)
//package com.java2s; /*//from w ww .jav a 2s . co m * Copyright (C) 2009 Emweb bvba, Leuven, Belgium. * * See the LICENSE file for terms of use. */ import java.util.EnumSet; public class Main { public static <E extends Enum<E>> E enumFromSet(EnumSet<E> theSet) { if (theSet.isEmpty()) { return null; } else { return theSet.iterator().next(); } } }