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.commons.template;
018
019import java.util.function.*;
020
021import org.apache.juneau.commons.svl.*;
022
023/**
024 * Renders a {@link Structure} (a list, block or table produced by <c>ul</c>, <c>ol</c>, <c>block</c> or <c>table</c>) for
025 * one destination.
026 *
027 * <p>
028 * The renderer owns the encoding of its content: it must encode every item and cell it writes and must not encode the
029 * markup it adds.  The value encoder of the render is <em>not</em> applied to a {@link Structure}.  A nested
030 * {@link Structure} item is rendered by calling this renderer again.
031 */
032@FunctionalInterface
033public interface StructureRenderer {
034
035   /**
036    * Renders a structure.
037    *
038    * @param structure The structure.  Never <jk>null</jk>.
039    * @param toText Converts one item or cell value to text using the resolver's value formatter (before encoding).
040    * @return The rendered text.  Never <jk>null</jk>.
041    */
042   String render(Structure structure, Function<Object,String> toText);
043}