org.apache.isis.commons.collections.ImmutableEnumSet Maven / Gradle / Ivy
Go to download
Apache Isis Commons is a library with utilities, that are shared with the entire Apache Isis ecosystem.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.isis.commons.collections;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.stream.Stream;
/**
* Immutable variant of {@link EnumSet}
*
* @since 2.0
*/
public final class ImmutableEnumSet>
implements Iterable, java.io.Serializable {
private static final long serialVersionUID = 1L;
private final EnumSet delegate;
private ImmutableEnumSet(final EnumSet delegate) {
this.delegate = delegate;
}
public static > ImmutableEnumSet from(final EnumSet delegate) {
return new ImmutableEnumSet<>(delegate);
}
public static > ImmutableEnumSet noneOf(final Class enumType) {
return from(EnumSet.noneOf(enumType));
}
public static > ImmutableEnumSet of(final E e1) {
return from(EnumSet.of(e1));
}
public static > ImmutableEnumSet of(final E e1, final E e2) {
return from(EnumSet.of(e1, e2));
}
public static > ImmutableEnumSet of(final E e1, final E e2, final E e3) {
return from(EnumSet.of(e1, e2, e3));
}
public static > ImmutableEnumSet of(final E e1, final E e2, final E e3, final E e4) {
return from(EnumSet.of(e1, e2, e3, e4));
}
public static > ImmutableEnumSet complementOf(final ImmutableEnumSet other) {
return from(EnumSet.complementOf(other.delegate));
}
public static > ImmutableEnumSet allOf(final Class enumType) {
return from(EnumSet.allOf(enumType));
}
public boolean contains(final E element) {
return delegate.contains(element);
}
public EnumSet toEnumSet() {
return delegate.clone();
}
@Override
public Iterator iterator() {
return delegate.iterator();
}
public Stream stream() {
return delegate.stream();
}
public boolean isEmpty() {
return delegate.isEmpty();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy