Java EnumSet Mask mask(EnumSet theSet, E mask)

Here you can find the source of mask(EnumSet theSet, E mask)

Description

mask

License

Open Source License

Declaration

public static <E extends Enum<E>> EnumSet<E> mask(EnumSet<E> theSet, E mask) 

Method Source Code


//package com.java2s;
/*//from   w w w. j  a  v  a2  s  . c  o 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>> EnumSet<E> mask(EnumSet<E> theSet, E mask) {
        EnumSet<E> retval = EnumSet.copyOf(theSet);
        EnumSet<E> theMask = EnumSet.of(mask);
        retval.retainAll(theMask);
        return retval;
    }

    public static <E extends Enum<E>> EnumSet<E> mask(EnumSet<E> theSet, EnumSet<E> mask) {
        EnumSet<E> retval = EnumSet.copyOf(theSet);
        retval.retainAll(mask);
        return retval;
    }
}

Related

  1. mask(EnumSet map, T key, boolean enabled)