Class WidgetFactory<T extends HasWidgets,​W extends Widget>

    • Constructor Detail

      • WidgetFactory

        public WidgetFactory()
    • Method Detail

      • type

        public abstract Class<T> type()
        The type of object this factory cares about. Declared separately, rather than by having createFor(T) do a check-cast, so that method bodies are not loaded until actually needed.
        the type of WidgetFactory
      • widgetType

        public abstract Class<W> widgetType()
        A supertype of any widgets this factory might produce. Defined so that factories which produce irrelevant widgets need not be consulted. If your implementation was returning multiple disparate kinds of widgets, it is best to split it into two factories.

        If an API defines an abstract Widget subtype, and you are providing a concrete implementation, you may return the API type here to delay class loading.

        a bound for the result of createFor(T)
      • createFor

        public abstract Collection<W> createFor​(@NonNull
                                                T target)
        Creates widgets for a given object. This may be called frequently for the same object, so if your implementation is expensive, do your own caching.
        target - a widgetable object
        a possible empty set of widgets (typically either using Set.of()).