org.decisiondeck.jmcda.structure.sorting.assignment
Class Assignments

java.lang.Object
  extended by org.decisiondeck.jmcda.structure.sorting.assignment.Assignments
All Implemented Interfaces:
IAssignments, IAssignmentsRead, IAssignmentsToMultipleRead

public class Assignments
extends Object
implements IAssignments


Constructor Summary
Assignments()
           
 
Method Summary
 boolean clear()
           
 boolean equals(Object obj)
           Indicates whether the given object is equal to this one.
 Set<Alternative> getAlternatives()
          Retrieves a read-only view of the assigned alternatives.
 Set<Alternative> getAlternatives(Category category)
           Retrieves a read-only view, or copy, of the alternatives that are assigned to the given category, or to a set of categories including the given category.
 Set<Category> getCategories()
           Retrieves a (possibly read-only) copy of a set containing at least all the categories to which at least one alternative is assigned.
 Set<Category> getCategories(Alternative alternative)
          Retrieves, if it exists, the category to which an alternative is assigned as a singleton set.
 Category getCategory(Alternative alternative)
           
 int hashCode()
           
 boolean setCategory(Alternative alternative, Category category)
          Sets, replaces, or removes the assignment of an alternative.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Assignments

public Assignments()
Method Detail

getCategories

public Set<Category> getCategories()
Description copied from interface: IAssignmentsToMultipleRead

Retrieves a (possibly read-only) copy of a set containing at least all the categories to which at least one alternative is assigned. Depending on the implementing object, the returned set may be larger than this. It may for example contain all the categories that are available in some context, even when the alternatives assignments do not cover the whole set of possibilities.

The returned set is a copy: if the assignment related to the given alternative later change, this change is not reflected to the object this method returns.

Specified by:
getCategories in interface IAssignmentsToMultipleRead
Returns:
a set, not null, empty iff no alternatives are assigned.

getAlternatives

public Set<Alternative> getAlternatives(Category category)
Description copied from interface: IAssignmentsToMultipleRead

Retrieves a read-only view, or copy, of the alternatives that are assigned to the given category, or to a set of categories including the given category.

If the given category is not in the set returned by IAssignmentsToMultipleRead.getCategories(), the returned set is empty.

Specified by:
getAlternatives in interface IAssignmentsToMultipleRead
Parameters:
category - not null.
Returns:
not null.

getAlternatives

public Set<Alternative> getAlternatives()
Description copied from interface: IAssignmentsToMultipleRead
Retrieves a read-only view of the assigned alternatives.

Specified by:
getAlternatives in interface IAssignmentsToMultipleRead
Returns:
not null.

getCategory

public Category getCategory(Alternative alternative)
Specified by:
getCategory in interface IAssignmentsRead
Parameters:
alternative - not null.
Returns:
the category to which this alternative is assigned, or null iff this alternative is not assigned.

clear

public boolean clear()
Specified by:
clear in interface IAssignments

setCategory

public boolean setCategory(Alternative alternative,
                           Category category)
Description copied from interface: IAssignments
Sets, replaces, or removes the assignment of an alternative.

Specified by:
setCategory in interface IAssignments
Parameters:
alternative - not null.
category - null to remove the assignment.
Returns:
true iff the call changed the assignments, i.e. true iff the given alternative was assigned and the assignment has been removed, or was assigned to a different category, or was not assigned and has been assigned to a category.

equals

public boolean equals(Object obj)
Description copied from interface: IAssignmentsToMultipleRead

Indicates whether the given object is equal to this one. Supposing this object does not implement IAssignmentsWithCredibilitiesRead nor IOrderedAssignmentsToMultipleRead, this is true iff the given object is a IAssignmentsToMultipleRead, does not implement any of these mentioned interfaces either, and contains the same alternatives assigned to the same categories and the same set of overall categories as this object.

Other cases are more subtle. Objects implementing IAssignmentsToMultipleRead may be categorized, according to their capabilities, into four classes: objects having no credibilities and no ordered assignments, objects having credibilities but no ordered assignments, objects having ordered assignments but no credibilities, and objects having both credibilities and ordered assignments. It is meaningless to compare objects belonging to different classes of capabilities and the equality test between objects which are non homogeneous in that sense return false. If this object and the compared object both have credibilities, a supplementary condition is added for the objects to be equal, namely that the assignments must be associated with the same credibilities to the same categories. If this object and the compared object both are ordered, the added condition is that the set of categories contained in the objects must have the same order. Both supplementary conditions are required if the objects being tested for equality are ordered and have credibilities.

Specified by:
equals in interface IAssignmentsToMultipleRead
Overrides:
equals in class Object
Parameters:
obj - may be null.
Returns:
true iff both objects are considered equal.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getCategories

public Set<Category> getCategories(Alternative alternative)
Description copied from interface: IAssignmentsRead
Retrieves, if it exists, the category to which an alternative is assigned as a singleton set. This method provides compatibility with the IAssignmentsToMultipleRead interface. The method IAssignmentsRead.getCategory(Alternative) is functionally equivalent and should be preferred over this one as it is clearer.

Specified by:
getCategories in interface IAssignmentsRead
Specified by:
getCategories in interface IAssignmentsToMultipleRead
Parameters:
alternative - not null.
Returns:
a set containing exactly one element, namely the category to which the given alternative is assigned, or null iff the alternative is not assigned.


Copyright © 2011. All Rights Reserved.