Content of file Layout.java.html

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../../jacoco-resources/report.gif" type="image/gif"/><title>Layout.java</title><link rel="stylesheet" href="../../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../../index.html" class="el_report">NorthernWind :: Filesystems :: Basic</a> &gt; <a href="../index.html" class="el_bundle">it-tidalwave-northernwind-core</a> &gt; <a href="index.source.html" class="el_package">it.tidalwave.northernwind.frontend.ui</a> &gt; <span class="el_source">Layout.java</span></div><h1>Layout.java</h1><pre class="source lang-java linenums">/*
 * #%L
 * *********************************************************************************************************************
 *
 * NorthernWind - lightweight CMS
 * http://northernwind.tidalwave.it - git clone https://bitbucket.org/tidalwave/northernwind-src.git
 * %%
 * Copyright (C) 2011 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
 * %%
 * *********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations under the License.
 *
 * *********************************************************************************************************************
 *
 *
 * *********************************************************************************************************************
 * #L%
 */
package it.tidalwave.northernwind.frontend.ui;

import javax.annotation.Nonnull;
import java.util.Optional;
import it.tidalwave.util.As;
import it.tidalwave.util.Id;
import it.tidalwave.util.NotFoundException;
import it.tidalwave.role.Composite;
import it.tidalwave.role.Identifiable;
import it.tidalwave.northernwind.core.model.HttpStatusException;
import it.tidalwave.northernwind.core.model.ModelFactory;
import it.tidalwave.northernwind.core.model.SiteNode;
import it.tidalwave.northernwind.frontend.ui.ViewFactory.ViewAndController;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import lombok.With;

/***********************************************************************************************************************
 *
 * A {@code Layout} contains the description of the visual structure of a {@link SiteNode}.
 *
 * @author  Fabrizio Giudici
 *
 **********************************************************************************************************************/
public interface Layout extends As, Identifiable, Composite&lt;Layout, LayoutFinder&gt;
  {
    /*******************************************************************************************************************
     *
     * A builder of a {@link Layout}.
     *
     ******************************************************************************************************************/
<span class="nc" id="L61">    @AllArgsConstructor(access = AccessLevel.PRIVATE) @RequiredArgsConstructor</span>
<span class="nc" id="L62">    @Getter @ToString(exclude = &quot;callBack&quot;)</span>
    public final class Builder
      {
        // Workaround for a Lombok limitation with Wither and subclasses
        @FunctionalInterface
        public static interface CallBack
          {
            @Nonnull
            public Layout build (@Nonnull Builder builder);
          }

        @Nonnull
<span class="nc" id="L74">        private final ModelFactory modelFactory;</span>

        @Nonnull
<span class="nc" id="L77">        private final CallBack callBack;</span>

<span class="nc bnc" id="L79" title="All 2 branches missed.">        @With</span>
<span class="nc" id="L80">        private Id id;</span>

<span class="nc bnc" id="L82" title="All 2 branches missed.">        @With</span>
<span class="nc" id="L83">        private String type;</span>

        @Nonnull
        public Layout build()
          {
<span class="nc" id="L88">            return callBack.build(this);</span>
          }
      }

    /*******************************************************************************************************************
     *
     * Returns the type URI for this layout.
     *
     * @return  the type URI
     *
     ******************************************************************************************************************/
    @Nonnull
    public String getTypeUri(); // FIXME: perhaps String should be a LayoutType wrapper? Or an Id?

    /*******************************************************************************************************************
     *
     * Creates a clone with another {@code Layout} as a child.
     *
     * @param  child     the child {@code Layout}
     * @return           the clone with the new child
     *
     ******************************************************************************************************************/
    @Nonnull
    public Layout withChild (@Nonnull Layout child);

    /*******************************************************************************************************************
     *
     * Creates a clone with another {@code Layout} overriding some parts.
     *
     * @param  override  the overriding {@code Layout}
     * @return           the clone with the override in effect
     *
     ******************************************************************************************************************/
    @Nonnull
    public Layout withOverride (@Nonnull Layout override);

    /*******************************************************************************************************************
     *
     * Accepts a {@link Visitor} to walk inside the structure and returns the (optional) computation product of the
     * {@code Visitor}.
     *
     * @param  visitor      the {@code Visitor}
     * @return              the {@code Visitor} result
     *
     ******************************************************************************************************************/
    @Nonnull // TODO: push up to Composite
push up to Composite
public &lt;T&gt; Optional&lt;T&gt; accept (@Nonnull Visitor&lt;? super Layout, T&gt; visitor); /******************************************************************************************************************* * * Creates a new {@link View} with its {@link Controller} for the given {@link SiteNode}, typically because * something needs to render it in response of a request. * * @param siteNode the {@code SiteNode} * @return the {@code View} and its {@code Controller} within a {@link ViewAndController} * @throws NotFoundException if no view component is found * @throws HttpStatusException if a component asked to return a specific HTTP status * ******************************************************************************************************************/ @Nonnull public ViewAndController createViewAndController (@Nonnull SiteNode siteNode) throws NotFoundException, HttpStatusException; } </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.9.202303310957</span></div></body></html>