net.sf.opendse.model
Class Mappings<T extends Task,R extends Resource>

java.lang.Object
  extended by net.sf.opendse.model.Mappings<T,R>
Type Parameters:
T - the type of tasks
R - the type of resources
All Implemented Interfaces:
java.lang.Iterable<Mapping<T,R>>

public class Mappings<T extends Task,R extends Resource>
extends java.lang.Object
implements java.lang.Iterable<Mapping<T,R>>

The Mappings represent a set of Mapping elements.


Field Summary
protected  java.util.Set<Mapping<T,R>> mappings
           
protected  java.util.Map<R,java.util.Set<Mapping<T,R>>> resourceMappings
           
protected  java.util.Map<R,org.apache.commons.collections15.Bag<T>> sources
           
protected  java.util.Map<T,org.apache.commons.collections15.Bag<R>> targets
           
protected  java.util.Map<T,java.util.Set<Mapping<T,R>>> taskMappings
           
 
Constructor Summary
Mappings()
           
 
Method Summary
 void add(Mapping<T,R> mapping)
          Adds a mapping.
 java.util.Set<Mapping<T,R>> get(R target)
          Returns all mappings with the specified target.
 java.util.Set<Mapping<T,R>> get(T source)
          Returns all mappings with the specified source.
 java.util.Set<Mapping<T,R>> get(T source, R target)
          Returns all mappings with the specified source and target.
 java.util.Set<Mapping<T,R>> getAll()
          Returns all mappings as a set.
 java.util.Set<T> getSources(R target)
          Returns all sources for a target.
 java.util.Set<R> getTargets(T source)
          Returns all targets for a source.
 java.util.Iterator<Mapping<T,R>> iterator()
           
 boolean remove(Mapping<T,R> mapping)
          Removes a mapping
 boolean removeAll(java.util.Collection<Mapping<T,R>> mappings)
           
 int size()
          Returns the number of mappings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mappings

protected java.util.Set<Mapping<T extends Task,R extends Resource>> mappings

taskMappings

protected java.util.Map<T extends Task,java.util.Set<Mapping<T extends Task,R extends Resource>>> taskMappings

resourceMappings

protected java.util.Map<R extends Resource,java.util.Set<Mapping<T extends Task,R extends Resource>>> resourceMappings

targets

protected java.util.Map<T extends Task,org.apache.commons.collections15.Bag<R extends Resource>> targets

sources

protected java.util.Map<R extends Resource,org.apache.commons.collections15.Bag<T extends Task>> sources
Constructor Detail

Mappings

public Mappings()
Method Detail

add

public void add(Mapping<T,R> mapping)
Adds a mapping.

Parameters:
mapping - the mapping to be added

remove

public boolean remove(Mapping<T,R> mapping)
Removes a mapping

Parameters:
mapping - the mapping to be removed
Returns:
true if the mapping was removed

removeAll

public boolean removeAll(java.util.Collection<Mapping<T,R>> mappings)

iterator

public java.util.Iterator<Mapping<T,R>> iterator()
Specified by:
iterator in interface java.lang.Iterable<Mapping<T extends Task,R extends Resource>>

size

public int size()
Returns the number of mappings.

Returns:
the number of mappings

get

public java.util.Set<Mapping<T,R>> get(T source)
Returns all mappings with the specified source.

Parameters:
source - the source
Returns:
all mappings with the specified source

getTargets

public java.util.Set<R> getTargets(T source)
Returns all targets for a source.

Parameters:
source - the source
Returns:
all targets

get

public java.util.Set<Mapping<T,R>> get(R target)
Returns all mappings with the specified target.

Parameters:
target - the target
Returns:
all mappings with the specified target

getSources

public java.util.Set<T> getSources(R target)
Returns all sources for a target.

Parameters:
target - the target
Returns:
all sources

get

public java.util.Set<Mapping<T,R>> get(T source,
                                       R target)
Returns all mappings with the specified source and target.

Parameters:
source - the source
target - the target
Returns:
the mappings with the specified source and target

getAll

public java.util.Set<Mapping<T,R>> getAll()
Returns all mappings as a set.

Returns:
all mappings as a set