001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.html.annotation; 014 015import org.apache.juneau.*; 016import org.apache.juneau.html.*; 017import org.apache.juneau.reflect.*; 018import org.apache.juneau.svl.*; 019 020/** 021 * Utility classes and methods for the {@link HtmlDocConfig @HtmlDocConfig} annotation. 022 * 023 * <h5 class='section'>See Also:</h5><ul> 024 * <li class='link'><a class="doclink" href="../../../../../index.html#jm.HtmlDetails">HTML Details</a> 025 * </ul> 026 */ 027public class HtmlDocConfigAnnotation { 028 029 /** 030 * Applies {@link HtmlDocConfig} annotations to a {@link org.apache.juneau.html.HtmlDocSerializer.Builder}. 031 */ 032 public static class SerializerApply extends AnnotationApplier<HtmlDocConfig,HtmlDocSerializer.Builder> { 033 034 /** 035 * Constructor. 036 * 037 * @param vr The resolver for resolving values in annotations. 038 */ 039 public SerializerApply(VarResolverSession vr) { 040 super(HtmlDocConfig.class, HtmlDocSerializer.Builder.class, vr); 041 } 042 043 @SuppressWarnings("unchecked") 044 @Override 045 public void apply(AnnotationInfo<HtmlDocConfig> ai, HtmlDocSerializer.Builder b) { 046 HtmlDocConfig a = ai.inner(); 047 048 strings(a.aside()).ifPresent(x -> b.aside(x)); 049 strings(a.footer()).ifPresent(x -> b.footer(x)); 050 strings(a.head()).ifPresent(x -> b.head(x)); 051 strings(a.header()).ifPresent(x -> b.header(x)); 052 strings(a.nav()).ifPresent(x -> b.nav(x)); 053 strings(a.navlinks()).ifPresent(x -> b.navlinks(x)); 054 strings(a.script()).ifPresent(x -> b.script(x)); 055 strings(a.style()).ifPresent(x -> b.style(x)); 056 strings(a.stylesheet()).ifPresent(x -> b.stylesheet(x)); 057 string(a.asideFloat()).filter(x -> ! "DEFAULT".equalsIgnoreCase(x)).map(AsideFloat::valueOf).ifPresent(x -> b.asideFloat(x)); 058 string(a.noResultsMessage()).ifPresent(x -> b.noResultsMessage(x)); 059 bool(a.nowrap()).ifPresent(x -> b.nowrap(x)); 060 bool(a.resolveBodyVars()).ifPresent(x -> b.resolveBodyVars(x)); 061 type(a.template()).ifPresent(x -> b.template(x)); 062 classes(a.widgets()).ifPresent(x -> b.widgets((Class<? extends HtmlWidget>[]) x)); 063 } 064 } 065}