Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.google.sitebricks.rendering.control;
 
 
 import java.util.List;

Author(s):
Dhanji R. Prasanna (dhanji@gmail.com)
class ProceedingWidgetChain implements WidgetChain {
    private final List<Renderablewidgets = new ArrayList<Renderable>();
    public void render(Object boundRespond respond) {
        for (Renderable widget : ) {
            widget.render(boundrespond);
        }
    }
    public synchronized WidgetChain addWidget(Renderable renderable) {
        .add(renderable);
        return this;
    }

    
This is an expensive method, never use it when live (used best at startup).

Parameters:
clazz A class implementing Renderable.
Returns:
Returns a set of widgets that match the given type in this widget chain.
    public synchronized <T extends RenderableSet<T> collect(Class<T> clazz) {
        Set<T> matches = new HashSet<T>();
        for (Renderable widget : ) {
            //add any matching classes to the set
            if (clazz.isInstance(widget))
                //noinspection unchecked
                matches.add((T) widget);
            //traverse down widget chains
            if (widget instanceof WidgetChain)
                matches.addAll(widget.collect(clazz));
        }
        return matches;
    }
New to GrepCode? Check out our FAQ X