All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.selophane.elements.factory.internal.ImplementedByProcessor Maven / Gradle / Ivy

There is a newer version: 0.12
Show newest version
package org.selophane.elements.factory.internal;

import org.selophane.elements.base.Element;
import org.selophane.elements.base.ImplementedBy;

/**
 * Processes the iface type into a useful class reference for wrapping
 * WebElements.
 */
public final class ImplementedByProcessor {
    private ImplementedByProcessor() {
    }

    /**
     * Gets the wrapper class (descended from ElementImpl) for the annotation
     * ImplementedBy.
     *
     * @param iface iface to process for annotations
     * @param  type of the wrapped class.
     * @return The class name of the class in question
     */
    public static  Class getWrapperClass(Class iface) {
        if (iface.isAnnotationPresent(ImplementedBy.class)) {
            ImplementedBy annotation = iface.getAnnotation(ImplementedBy.class);
            Class clazz = annotation.value();
            if (Element.class.isAssignableFrom(clazz)) {
                return annotation.value();
            }
        }
        throw new UnsupportedOperationException(
                "Apply @ImplementedBy interface to your Interface "
                        + iface.getCanonicalName() + " if you want to extend ");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy