com.yammer.dropwizard.views.View Maven / Gradle / Ivy
package com.yammer.dropwizard.views;
import com.yammer.metrics.Metrics;
import com.yammer.metrics.core.Timer;
import org.codehaus.jackson.annotate.JsonIgnore;
public abstract class View {
private final String templateName;
private final Timer renderingTimer;
protected View(String templateName) {
this.templateName = resolveName(templateName);
this.renderingTimer = Metrics.newTimer(getClass(), "rendering");
}
private String resolveName(String templateName) {
if (templateName.startsWith("/")) {
return templateName;
}
final String packagePath = getClass().getPackage().getName().replace('.', '/');
return String.format("/%s/%s", packagePath, templateName);
}
@JsonIgnore
public String getTemplateName() {
return templateName;
}
@JsonIgnore
Timer getRenderingTimer() {
return renderingTimer;
}
}