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

io.pelle.mango.client.base.modules.hierarchical.HierarchicalConfigurationVO Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2013 Christian Pelster.
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Christian Pelster - initial API and implementation
 */
package io.pelle.mango.client.base.modules.hierarchical;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HierarchicalConfigurationVO implements Serializable
{

	private static final long serialVersionUID = 2347100754321469227L;

	private Map> dictionaryHierarchy = new HashMap>();

	private String id;

	private String title;

	public HierarchicalConfigurationVO()
	{
		super();
	}

	public HierarchicalConfigurationVO(String id, String title, Map> dictionaryHierarchy)
	{
		super();
		this.id = id;
		this.title = title;
		this.dictionaryHierarchy = dictionaryHierarchy;
	}

	public boolean isRootDictionary(String dictionaryId)
	{
		return this.dictionaryHierarchy.get(dictionaryId).isEmpty();
	}

	public Collection getDictionaryIds()
	{
		return this.dictionaryHierarchy.keySet();
	}

	public List getChildDictionaryIds(String dictionaryId)
	{
		List childDictionaries = new ArrayList();

		for (Map.Entry> hierarchyEntry : this.dictionaryHierarchy.entrySet())
		{
			if (hierarchyEntry.getValue().contains(dictionaryId))
			{
				childDictionaries.add(hierarchyEntry.getKey());
			}
		}

		return childDictionaries;
	}

	public static boolean isRootDictionary(String dictionaryId, List hierarchicalConfigurationVOs)
	{
		for (HierarchicalConfigurationVO hierarchicalConfigurationVO : hierarchicalConfigurationVOs)
		{
			if (hierarchicalConfigurationVO.isRootDictionary(dictionaryId))
			{
				return true;
			}
		}

		return false;
	}

	/**
	 * Returns the hierarchy configuration (Dictionary Name -> List of possible
	 * parents)
	 * 
	 * @return
	 */
	public Map> getDictionaryHierarchy()
	{
		return this.dictionaryHierarchy;
	}

	public String getId()
	{
		return this.id;
	}

	public String getTitle()
	{
		return this.title;
	}

	public void setTitle(String title)
	{
		this.title = title;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy