/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2014 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * Licensed 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.wildfly.common.ref;

/**
 * An enhanced reference type with a type-safe attachment.
 *
 * @param <T> the reference value type
 * @param <A> the attachment type
 *
 * @see java.lang.ref.Reference
 *
 * @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
 */
public interface Reference<T, A> {

    /**
     * Get the value, or {@code null} if the reference has been cleared.
     *
     * @return the value
     */
    T get();

    /**
     * Get the attachment, if any.
     *
     * @return the attachment
     */
    A getAttachment();

    /**
     * Clear the reference.
     */
    void clear();

    /**
     * Get the type of the reference.
     *
     * @return the type
     */
    Type getType();

    /**
     * A reference type.
     *
     * @apiviz.exclude
     */
    enum Type {

        /**
         * A strong reference.
         */
        STRONG,
        /**
         * A weak reference.
         */
        WEAK,
        /**
         * A phantom reference.
         */
        PHANTOM,
        /**
         * A soft reference.
         */
        SOFT,
        /**
         * A {@code null} reference.
         */
        NULL,
    }
}

@@ -734,16 +734,43 @@
 n.ref;%0A%0A
+import java.util.EnumSet;%0A%0A
 /**%0A * A
@@ -1905,16 +1905,2235 @@
   NULL,%0A
+        ;%0A%0A        private static final int fullSize = values().length;%0A%0A        /**%0A         * Determine whether the given set is fully populated (or %22full%22), meaning it contains all possible values.%0A         *%0A         * @param set the set%0A         *%0A         * @return %7B@code true%7D if the set is full, %7B@code false%7D otherwise%0A         */%0A        public static boolean isFull(final EnumSet%3CType%3E set) %7B%0A            return set != null && set.size() == fullSize;%0A        %7D%0A%0A        /**%0A         * Determine whether this instance is equal to one of the given instances.%0A         *%0A         * @param v1 the first instance%0A         *%0A         * @return %7B@code true%7D if one of the instances matches this one, %7B@code false%7D otherwise%0A         */%0A        public boolean in(final Type v1) %7B%0A            return this == v1;%0A        %7D%0A%0A        /**%0A         * Determine whether this instance is equal to one of the given instances.%0A         *%0A         * @param v1 the first instance%0A         * @param v2 the second instance%0A         *%0A         * @return %7B@code true%7D if one of the instances matches this one, %7B@code false%7D otherwise%0A         */%0A        public boolean in(final Type v1, final Type v2) %7B%0A            return this == v1 %7C%7C this == v2;%0A        %7D%0A%0A        /**%0A         * Determine whether this instance is equal to one of the given instances.%0A         *%0A         * @param v1 the first instance%0A         * @param v2 the second instance%0A         * @param v3 the third instance%0A         *%0A         * @return %7B@code true%7D if one of the instances matches this one, %7B@code false%7D otherwise%0A         */%0A        public boolean in(final Type v1, final Type v2, final Type v3) %7B%0A            return this == v1 %7C%7C this == v2 %7C%7C this == v3;%0A        %7D%0A%0A        /**%0A         * Determine whether this instance is equal to one of the given instances.%0A         *%0A         * @param values the possible values%0A         *%0A         * @return %7B@code true%7D if one of the instances matches this one, %7B@code false%7D otherwise%0A         */%0A        public boolean in(final Type... values) %7B%0A            if (values != null) for (Type value : values) %7B%0A                if (this == value) return true;%0A            %7D%0A            return false;%0A        %7D%0A
     %7D%0A%7D%0A

Add standard enum body