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

com.att.research.xacmlatt.pdp.policy.Bag Maven / Gradle / Ivy

There is a newer version: 4.0.0
Show newest version
/*
 *
 *          Copyright (c) 2013,2019  AT&T Knowledge Ventures
 *                     SPDX-License-Identifier: MIT
 */
package com.att.research.xacmlatt.pdp.policy;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.att.research.xacml.api.AttributeValue;

/**
 * Bag represents a collection of XACML attribute values for the same attribute.
 * 
 * @author car
 * @version $Revision: 1.1 $
 */
public class Bag {
	public static final Bag	EMPTY	= new Bag();
	
	private List> attributeValues	= new ArrayList>();

	/**
	 * Gets the List of AttributeValues for this Bag.
	 * 
	 * @return the List of AttributeValues for this Bag
	 */
	public List> getAttributeValueList() {
		return this.attributeValues;
	}
	
	/**
	 * Creates a new, empty Bag.
	 */
	public Bag() {
	}
	
	/**
	 * Creates a new Bag by copying the {@link com.att.research.xacml.api.AttributeValue}s from the
	 * given Collection.
	 * 
	 * @param attributeValuesIn the Collection of AttributeValues for this Bag.
	 *
	public Bag(Collection> attributeValuesIn) {
		if (attributeValuesIn != null) {
			this.attributeValues.addAll(attributeValuesIn);
		}
	}
	
	public Bag(Iterator> iterAttributeValuesIn) {
		if (iterAttributeValuesIn != null) {
			while (iterAttributeValuesIn.hasNext()) {
				this.attributeValues.add(iterAttributeValuesIn.next());
			}
		}
	}
	*/
	
	/**
	 * Adds an AttributeValue to this Bag>
	 * 
	 * @param attributeValue the AttributeValue to add
	 */
	public void add(AttributeValue attributeValue) {
		this.attributeValues.add(attributeValue);
	}
	
	/**
	 * Gets the number of AttributeValues in this Bag.
	 * 
	 * @return the number of AttributeValues in this Bag.
	 */
	public int size() {
		return this.getAttributeValueList().size();
	}
	
	/**
	 * Gets an Iterator over all of the AttributeValues in this Bag.
	 * 
	 * @return an Iterator over all of the AttributeValues in this Bag.
	 */
	public Iterator> getAttributeValues() {
		return this.getAttributeValueList().iterator();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy