All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.varmateo.yawg.breadcrumbs.Breadcrumbs Maven / Gradle / Ivy

/**************************************************************************
 *
 * Copyright (c) 2016-2020 Yawg project contributors.
 *
 **************************************************************************/

package com.varmateo.yawg.breadcrumbs;

import io.vavr.collection.List;


/**
 *
 */
public final class Breadcrumbs {


    // We really need to use a j.u.List because this POJO is used as
    // part of a Freemarker model.
    private final java.util.List _items;


    /**
     *
     */
    /* default */ Breadcrumbs(final Builder builder) {

        _items = builder._items.toJavaList();
    }


    /**
     *
     */
    public static Breadcrumbs empty() {

        return builder().build();
    }


    /**
     * Creates a new builder with no initializations.
     *
     * @return A newly created Builder instance.
     */
    public static Builder builder() {

        return new Builder();
    }


    /**
     * Creates a new builder initialized with the data from the given
     * Breadcrumbs.
     *
     * @param data Used for initializing the builder state.
     *
     * @return A newly created Builder instance.
     */
    public static Builder builder(final Breadcrumbs data) {

        return new Builder(data);
    }


    /**
     *
     */
    public java.util.List getItems() {

        return _items;
    }


    /**
     *
     */
    public static final class Builder {


        private List _items;


        /**
         *
         */
        /* default */ Builder() {

            _items = List.of();
        }


        /**
         *
         */
        /* default */ Builder(final Breadcrumbs data) {

            _items = List.ofAll(data._items);
        }


        /**
         *
         */
        public Builder addBreadcrumbItem(final BreadcrumbItem item) {

            _items = _items.append(item);

            return this;
        }


        /**
         *
         */
        public Breadcrumbs build() {

            return new Breadcrumbs(this);
        }


    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy