001package io.jstach.opt.dropwizard;
002
003import java.nio.charset.Charset;
004import java.nio.charset.StandardCharsets;
005
006import io.dropwizard.views.common.View;
007
008/**
009 * An interface to mark JStachio dropwizard views
010 *
011 * @author agentgt
012 *
013 */
014public interface JStachioView {
015
016        /**
017         * The JStache annotated instance
018         * @return model
019         */
020        public Object model();
021
022        /**
023         * Creates a dropwizard view from a model object
024         * @param model JStache annotated model
025         * @return dropwizard view
026         */
027        @SuppressWarnings("exports")
028        public static View of(Object model) {
029                return new DefaultJStachioView(model);
030        }
031
032        /**
033         * The charset never null
034         * @return utf-8 by default
035         */
036        default Charset charset() {
037                return StandardCharsets.UTF_8;
038        }
039
040}