001package io.jstach.opt.dropwizard;
002
003import io.dropwizard.views.common.View;
004
005/**
006 * Have JStache models implement this mixin interface for easier support to generate views
007 * from models.
008 * <p>
009 * To enforce all models implement this interface configurure JStachio like:
010 * <pre><code class="language-java">
011 * &#64;JStacheConfig(interfacing = &#64;JStacheInterfaces(modelImplements = JStacheViewSupport.class))
012 * &#47;&#47; some class, package-info, module-info
013 * </code> </pre>
014 * <p>
015 * If using this mixin interface is not desirable one can create view manually from a
016 * model with {@link JStachioView#of(Object)}.
017 *
018 * @author agentgt
019 */
020public interface JStacheViewSupport {
021
022        /**
023         * Creates Dropwizard view from this model
024         * @return dropwizard view
025         */
026        @SuppressWarnings("exports")
027        default View toView() {
028                return JStachioView.of(this);
029        }
030
031}