@ImplementedBy(className = "org.jboss.arquillian.graphene.angular.findby.ByActionImpl") public static class ByAction extends ByAngular implements Serializable { public ByAction(String action) { this.implementation = instantiate(ByAction.class, action); } }
/** * Instantiates a class by given implementation name * * @param className * @return */ @SuppressWarnings("unchecked") public static <T> T instantiate(String className) { return (T) instantiate(resolveType(className)); }
/** * Resolves implementation type based on given type, while it reflects annotation {@link ImplementedBy} in order to * determine final implementation of given type. * * @param type the type to be resolved * @return the implementation class for given type */ @SuppressWarnings("unchecked") public static <T> Class<? extends T> resolveType(Class<T> type) { ImplementedBy implementedBy = type.getAnnotation(ImplementedBy.class); if (implementedBy != null) { if (implementedBy.value() != ImplementedBy.class) { return (Class<? extends T>) resolveType(implementedBy.value()); } else if (!"".equals(implementedBy.className())) { return (Class<? extends T>) resolveType(implementedBy.className()); } else { throw new IllegalStateException( String.format( "Cannot instantiate an instance of '%s' as its %s is incomplete - it doesn't specify implementation class", type.getName(), implementedBy)); } } else { return type; } }
/** * Instantiates class by given type, while it reflects annotation {@link ImplementedBy} in order to determine final * implementation of given type. * * @param type the type of the instantiated instance, which can be either final implementation type or type annotated by * {@link ImplementedBy} in order to determine final implementation of given type. * @return instance of given type */ public static <T> T instantiate(Class<T> type) { try { Class<? extends T> resolvedType = resolveType(type); return SecurityActions.newInstance(resolvedType.getName(), new Class<?>[] {}, new Object[] {}, type); } catch (Exception e) { throw new IllegalStateException(String.format("Cannot instantiate an instance of class '%s': %s", type.getName(), e.getMessage()), e); } }
protected By instantiate(Class<? extends By> type, String lookup) { try { Class<? extends By> clazz = TypeResolver.resolveType(type); Constructor<? extends By> constructor = clazz.getConstructor(String.class); return constructor.newInstance(lookup); } catch (Exception e) { throw new IllegalStateException("Cannot instantiate " + type, e); } }
private ExecutionResolver createResolver(JavaScript annotation) { try { return TypeResolver.instantiate(annotation.executionResolver()); } catch (Exception e) { throw new IllegalStateException("resolver " + annotation.executionResolver() + " can't be instantied", e); } }
/** * Instantiates a class by given implementation name * * @param className * @return */ @SuppressWarnings("unchecked") public static <T> T instantiate(String className) { return (T) instantiate(resolveType(className)); }
/** * Resolves implementation type based on given type, while it reflects annotation {@link ImplementedBy} in order to * determine final implementation of given type. * * @param type the type to be resolved * @return the implementation class for given type */ @SuppressWarnings("unchecked") public static <T> Class<? extends T> resolveType(Class<T> type) { ImplementedBy implementedBy = type.getAnnotation(ImplementedBy.class); if (implementedBy != null) { if (implementedBy.value() != ImplementedBy.class) { return (Class<? extends T>) resolveType(implementedBy.value()); } else if (!"".equals(implementedBy.className())) { return (Class<? extends T>) resolveType(implementedBy.className()); } else { throw new IllegalStateException( String.format( "Cannot instantiate an instance of '%s' as its %s is incomplete - it doesn't specify implementation class", type.getName(), implementedBy)); } } else { return type; } }
/** * Instantiates class by given type, while it reflects annotation {@link ImplementedBy} in order to determine final * implementation of given type. * * @param type the type of the instantiated instance, which can be either final implementation type or type annotated by * {@link ImplementedBy} in order to determine final implementation of given type. * @return instance of given type */ public static <T> T instantiate(Class<T> type) { try { Class<? extends T> resolvedType = resolveType(type); return SecurityActions.newInstance(resolvedType.getName(), new Class<?>[] {}, new Object[] {}, type); } catch (Exception e) { throw new IllegalStateException(String.format("Cannot instantiate an instance of class '%s': %s", type.getName(), e.getMessage()), e); } }
private static By instantiate(String selector) { try { Class<? extends By> clazz = (Class<? extends By>) TypeResolver.resolveType(ByJQuery.class); Constructor<? extends By> constructor = clazz.getConstructor(String.class); return constructor.newInstance(selector); } catch (Exception e) { e.printStackTrace(); throw new IllegalStateException("Cannot instantiate ByJQuery", e); } }
@ImplementedBy(className = "org.jboss.arquillian.graphene.angular.findby.ByRepeatImpl") public static class ByRepeat extends ByAngular implements Serializable { public ByRepeat(String repeaterText) { this.implementation = instantiate(ByRepeat.class, repeaterText); } } }
private ExecutionResolver createResolver(JavaScript annotation) { try { return TypeResolver.instantiate(annotation.executionResolver()); } catch (Exception e) { throw new IllegalStateException("resolver " + annotation.executionResolver() + " can't be instantied", e); } }
private static By instantiate(String selector) { try { Class<? extends By> clazz = (Class<? extends By>) TypeResolver.resolveType(ByJQuery.class); Constructor<? extends By> constructor = clazz.getConstructor(String.class); return constructor.newInstance(selector); } catch (Exception e) { e.printStackTrace(); throw new IllegalStateException("Cannot instantiate ByJQuery", e); } }
@ImplementedBy(className = "org.jboss.arquillian.graphene.angular.findby.ByModelImpl") public static class ByModel extends ByAngular implements Serializable { public ByModel(String modelName) { this.implementation = instantiate(ByModel.class, modelName); } }
@ImplementedBy(className = "org.jboss.arquillian.graphene.javascript.DefaultExecutionResolver") interface DefaultExecutionResolver extends ExecutionResolver { } }
@ImplementedBy(className = "org.jboss.arquillian.graphene.javascript.DefaultExecutionResolver") interface DefaultExecutionResolver extends ExecutionResolver { } }
@ImplementedBy(className = "org.jboss.arquillian.graphene.GrapheneElementImpl") public interface GrapheneElement extends WebElement, Locatable, WrapsElement, GrapheneElementAction {
@ImplementedBy(className = "org.jboss.arquillian.graphene.GrapheneElementImpl") public interface GrapheneElement extends WebElement, Locatable, WrapsElement, GrapheneElementAction {
@ImplementedBy(className = "org.jboss.arquillian.graphene.findby.ByJQueryImpl") public class ByJQuery extends By {
@ImplementedBy(className = "org.jboss.arquillian.graphene.findby.ByJQueryImpl") public class ByJQuery extends By {