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

io.imunity.vaadin.elements.MenuComponent Maven / Gradle / Ivy

/*
 * Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
 * See LICENCE.txt file for licensing information.
 */
package io.imunity.vaadin.elements;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.icon.VaadinIcon;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class MenuComponent
{
	public final Class component;
	public final String tabName;
	public final VaadinIcon icon;
	public final List> subViews;
	public final List subTabs;

	private MenuComponent(Class menuComponent, String tabName, VaadinIcon icon,
						  List> subViews,
						  List subTabs)
	{
		this.component = menuComponent;
		this.tabName = tabName;
		this.icon = icon;
		this.subViews = List.copyOf(subViews);
		this.subTabs = List.copyOf(subTabs);
	}

	public static Builder builder(Class component)
	{
		return new Builder(component);
	}

	public static Builder builder(MenuComponent... subTabs)
	{
		return new Builder(subTabs);
	}

	public static final class Builder
	{
		private Class component;
		private List> subViews = Collections.emptyList();
		private String tabName;
		private VaadinIcon icon;
		private List subTabs = Collections.emptyList();

		private Builder(Class component)
		{
			this.component = component;
		}

		private Builder(MenuComponent... subTabs)
		{
			subTabs(subTabs);
		}

		public Builder menu(Class component)
		{
			this.component = component;
			return this;
		}

		public Builder tabName(String tabName)
		{
			this.tabName = tabName;
			return this;
		}

		public Builder icon(VaadinIcon icon)
		{
			this.icon = icon;
			return this;
		}

		@SafeVarargs
		public final Builder subViews(Class... subViews)
		{
			this.subViews = Arrays.asList(subViews);
			return this;
		}

		public Builder subTabs(MenuComponent... subTabs)
		{
			this.subTabs = Arrays.asList(subTabs);
			return this;
		}

		public MenuComponent build()
		{
			return new MenuComponent(component, tabName, icon, subViews, subTabs);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy