org.decisiondeck.xmcda_oo.structure.category
Class Assignments

java.lang.Object
  extended by org.decisiondeck.xmcda_oo.structure.category.Assignments

public class Assignments
extends Object

This object holds assignments of alternatives to categories. Two such objects are equal iff they contain the same set of alternatives, each assigned to the same categories.


Constructor Summary
Assignments()
           
Assignments(Assignments assignments)
           
Assignments(IAssignmentsToMultipleRead assignments)
           
 
Method Summary
 boolean addAssignment(Alternative alternative, ICategory destination)
          Assigns the given alternative to the given category.
 boolean equals(Object obj)
           
 Set<ICategory> getAllCategories()
           
 Set<Alternative> getAlternatives(ICategory category)
           
 Set<Alternative> getAssignedAlternatives()
           
 Set<ICategory> getCategories(Alternative alternative)
           
 ICategory getCategory(Alternative alternative)
          May use it only if this object is not multi-categories (see isMultiCats()).
 int hashCode()
           
 boolean isMultiCats()
           
 void removeAssignment(Alternative alternative, ICategory destination)
           The designated assignment must exist in this object.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Assignments

public Assignments(Assignments assignments)

Assignments

public Assignments()

Assignments

public Assignments(IAssignmentsToMultipleRead assignments)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

addAssignment

public boolean addAssignment(Alternative alternative,
                             ICategory destination)
Assigns the given alternative to the given category. If the alternative is already associated with one or more categories, the given destination category is added to the set of categories this alternative is assigned to.

Parameters:
alternative - an alternative, not null.
destination - the category where to assign this alternative.
Returns:
true if this assignment has been added, i.e. it did not exist already.

getAlternatives

public Set<Alternative> getAlternatives(ICategory category)
Parameters:
category - the category of interest. Not null.
Returns:
a read-only view of the set of alternatives assigned to the given category. Not null, but may be empty (if the category has no assignments inside, i.e. it is not one of the categories returned by getAllCategories()).

getCategories

public Set<ICategory> getCategories(Alternative alternative)
Parameters:
alternative - the alternative of interest. Not null.
Returns:
a read-only view of the set of categories to which this alternative is assigned. Not null, but may be empty.

getAllCategories

public Set<ICategory> getAllCategories()
Returns:
a read-only view of the set of categories to which at least one alternative is assigned. Not null, empty iff this object holds no assignments.

getAssignedAlternatives

public Set<Alternative> getAssignedAlternatives()
Returns:
a read-only view of the set of alternatives for which assignment information is provided. Not null, empty iff this object holds no assignments.

removeAssignment

public void removeAssignment(Alternative alternative,
                             ICategory destination)

The designated assignment must exist in this object.

Removes an assignment. If the given alternative is assigned to more than one categories, the other categories to which this alternative is assigned are left untouched.

Parameters:
alternative - the alternative to remove from the given category.
destination - the category from which to remove the alternative.

isMultiCats

public boolean isMultiCats()
Returns:
true iff at least one alternative is assigned to more than one category.

getCategory

public ICategory getCategory(Alternative alternative)
May use it only if this object is not multi-categories (see isMultiCats()).

Parameters:
alternative - not null.
Returns:
null iff the given alternative is not assigned.


Copyright © 2011. All Rights Reserved.