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