com.sodius.mdw.core.model
Interface MDWSet<E>

All Superinterfaces:
Collection<E>, Iterable<E>, MDWCollection<E>, Set<E>
All Known Implementing Classes:
DefaultMDWSet

public interface MDWSet<E>
extends Set<E>, MDWCollection<E>

Provides facilities to invoke scripts on each MDWObject element of this Set. MDWSet enables to:

This interface is not intended to be implemented by clients.

Since:
MDWorkbench 3.0.0

See Also:
DefaultMDWSet

Method Summary
<T> MDWList<T>
collect(EStructuralFeature feature)
          Evaluates the specified feature on each MDWObject of this Set, and concatenates the results into a new list.
<T> MDWList<T>
collect(String scriptName)
          Evaluates the specified script on each MDWObject of this Set, and concatenates the results into a new list.
<T> MDWList<T>
collect(String scriptName, List<?> arguments)
          Evaluates the specified script on each MDWObject of this Set, and concatenates the results into a new list.
 String concat(EStructuralFeature feature)
          Evaluates the specified feature on each MDWObject of this Set, and concatenates the results into a String.
 String concat(EStructuralFeature feature, String separator)
          Evaluates the specified feature on each MDWObject of this Set, and concatenates the results into a String.
 String concat(String scriptName)
          Evaluates the specified script on each MDWObject of this Set, and concatenates the results into a String.
 String concat(String scriptName, List<?> arguments)
          Evaluates the specified script on each MDWObject of this Set, and concatenates the results into a String.
 String concat(String scriptName, List<?> arguments, String separator)
          Evaluates the specified script on each MDWObject of this Set, and concatenates the results into a String.
 String concat(String scriptName, String separator)
          Evaluates the specified script on each MDWObject of this Set, and concatenates the results into a String.
 MDWSet<E> copy()
          Copies all of the elements of the receiver Set to a newly created one.
<T extends MDWObject>
T
detect(EStructuralFeature feature, Object value)
          Returns the first MDWObject of this Set whose feature matches the specified value.
<T extends MDWObject>
T
detect(String scriptName, List<?> arguments, Object value)
          Returns the first MDWObject of this Set whose script evaluation result matches the specified value.
<T extends MDWObject>
T
detect(String scriptName, Object value)
          Returns the first MDWObject of this Set whose script evaluation result matches the specified value.
<T extends E>
MDWSet<T>
getInstances(EClass type)
          Selects MDWObject instances of this Set of the specified type.
<T extends E>
MDWSet<T>
getInstances(EClass type, boolean includeSubTypes)
          Selects MDWObject instances of this Set of the specified type, or one of its sub types.
<T extends E>
MDWSet<T>
getInstances(String typeName)
          Selects MDWObject instances of this Set of the specified type.
<T extends E>
MDWSet<T>
getInstances(String typeName, boolean includeSubTypes)
          Selects MDWObject instances of this Set of the specified type, or one of its sub types.
<T extends E>
MDWSet<T>
getProfiledInstances(EClass type, String profileName)
          Selects MDWObject instances of this Set of the specified type, which match the specified profile name.
<T extends E>
MDWSet<T>
getProfiledInstances(EClass type, String profileName, boolean includeSubTypes)
          Selects MDWObject instances of this Set of the specified type, or one of its sub types, which match the specified profile name.
<T extends E>
MDWSet<T>
getProfiledInstances(String typeName, String profileName)
          Selects MDWObject instances of this Set of the specified type, which match the specified profile name.
<T extends E>
MDWSet<T>
getProfiledInstances(String typeName, String profileName, boolean includeSubTypes)
          Selects MDWObject instances of this Set of the specified type, or one of its sub types, which match the specified profile name.
 MDWSet<E> reject(EStructuralFeature feature, Object value)
          Rejects MDWObject instances of this Set whose feature does not match the specified value.
 MDWSet<E> reject(String scriptName, List<?> arguments, Object value)
          Rejects MDWObject instances of this Set whose script evaluation result does not match the specified value.
 MDWSet<E> reject(String scriptName, Object value)
          Rejects MDWObject instances of this Set whose script evaluation result does not match the specified value.
 MDWSet<E> select(EStructuralFeature feature, Object value)
          Selects MDWObject instances of this Set whose feature matches the specified value.
 MDWSet<E> select(String scriptName, List<?> arguments, Object value)
          Selects MDWObject instances of this Set whose script evaluation result matches the specified value.
 MDWSet<E> select(String scriptName, Object value)
          Selects MDWObject instances of this Set whose script evaluation result matches the specified value.
 MDWList<E> sort(EStructuralFeature feature)
          Returns a sorted list into ascending order induced by the specified feature.
 MDWList<E> sort(String scriptName)
          Returns a sorted list into ascending order induced by the specified script.
 MDWList<E> sort(String scriptName, List<?> arguments)
          Returns a sorted list into ascending order induced by the specified script.
 MDWList<E> toList()
          Converts this Set to a new modifiable MDWList.
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

copy

MDWSet<E> copy()
Copies all of the elements of the receiver Set to a newly created one.

This method is useful when you want to traverse a Set and modify its contents: you can create a copy of the original Set, loop on its elements, and change the contents of the original Set without throwing ConcurrentModificationExceptions.

Returns:
a new Set containining all receiver's elements.

concat

String concat(String scriptName)
Evaluates the specified script on each MDWObject of this Set, and concatenates the results into a String.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Specified by:
concat in interface MDWCollection<E>
Parameters:
scriptName - the name of the script to evaluate on each MDWObject. This script must not expect any parameter.
Returns:
the concatenation the of script results.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.

concat

String concat(String scriptName,
              String separator)
Evaluates the specified script on each MDWObject of this Set, and concatenates the results into a String.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

The separator is inserted between each concatenated (non empty) script result.

Specified by:
concat in interface MDWCollection<E>
Parameters:
scriptName - the name of the script to evaluate on each MDWObject. This script must not expect any parameter.
separator - a separator to insert between each concatenated script result
Returns:
the concatenation the of script results.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.

concat

String concat(String scriptName,
              List<?> arguments)
Evaluates the specified script on each MDWObject of this Set, and concatenates the results into a String.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

The number and type of arguments must match the parameters of the script.

Specified by:
concat in interface MDWCollection<E>
Parameters:
scriptName - the name of the script to evaluate on each MDWObject.
arguments - the script arguments.
Returns:
the concatenation the of script results.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.

concat

String concat(String scriptName,
              List<?> arguments,
              String separator)
Evaluates the specified script on each MDWObject of this Set, and concatenates the results into a String.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

The number and type of arguments must match the parameters of the script.

The separator is inserted between each concatenated (non empty) script result.

Specified by:
concat in interface MDWCollection<E>
Parameters:
scriptName - the name of the script to evaluate on each MDWObject.
arguments - the script arguments.
Returns:
the concatenation the of script results.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.

concat

String concat(EStructuralFeature feature)
Evaluates the specified feature on each MDWObject of this Set, and concatenates the results into a String.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Specified by:
concat in interface MDWCollection<E>
Parameters:
feature - the feature to evaluate on each MDWObject.
Returns:
the concatenation the of feature results.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.

concat

String concat(EStructuralFeature feature,
              String separator)
Evaluates the specified feature on each MDWObject of this Set, and concatenates the results into a String.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

The separator is inserted between each concatenated (non empty) feature result.

Specified by:
concat in interface MDWCollection<E>
Parameters:
feature - the feature to evaluate on each MDWObject.
separator - a separator to insert between each concatenated script result
Returns:
the concatenation the of feature results.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.

select

MDWSet<E> select(String scriptName,
                 Object value)
Selects MDWObject instances of this Set whose script evaluation result matches the specified value.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Parameters:
scriptName - the name of the script to evaluate on each MDWObject. This script must not expect any parameter.
value - the comparison criterium (can be null).
Returns:
a modifiable Set containing MDWObject instances whose script result matches the specified value.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.
See Also:
detect(String, Object), reject(String, Object)

select

MDWSet<E> select(String scriptName,
                 List<?> arguments,
                 Object value)
Selects MDWObject instances of this Set whose script evaluation result matches the specified value.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate on each MDWObject.
arguments - the script arguments.
value - the comparison criterium (can be null).
Returns:
a modifiable Set containing MDWObject instances whose script result matches the specified value.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.
See Also:
detect(String, List, Object), reject(String, List, Object)

select

MDWSet<E> select(EStructuralFeature feature,
                 Object value)
Selects MDWObject instances of this Set whose feature matches the specified value.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Parameters:
feature - the feature to evaluate on each MDWObject.
value - the comparison criterium (can be null).
Returns:
a modifiable Set containing MDWObject instances whose feature matches the specified value.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.
See Also:
detect(EStructuralFeature, Object), reject(EStructuralFeature, Object)

reject

MDWSet<E> reject(String scriptName,
                 Object value)
Rejects MDWObject instances of this Set whose script evaluation result does not match the specified value.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Parameters:
scriptName - the name of the script to evaluate on each MDWObject. This script must not expect any parameter.
value - the comparison criterium (can be null).
Returns:
a modifiable Set containing MDWObject instances whose does not match the specified value.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.
See Also:
select(String, Object)

reject

MDWSet<E> reject(String scriptName,
                 List<?> arguments,
                 Object value)
Rejects MDWObject instances of this Set whose script evaluation result does not match the specified value.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

The number and type of arguments must match the parameters of the script.

Parameters:
scriptName - the name of the script to evaluate on each MDWObject.
arguments - the script arguments.
Returns:
a modifiable Set containing MDWObject instances whose does not match the specified value.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.
See Also:
select(String, List, Object)

reject

MDWSet<E> reject(EStructuralFeature feature,
                 Object value)
Rejects MDWObject instances of this Set whose feature does not match the specified value.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Parameters:
feature - the feature to evaluate on each MDWObject.
value - the comparison criterium (can be null).
Returns:
a modifiable Set containing MDWObject instances whose feature does not match the specified value.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.
See Also:
select(EStructuralFeature, Object)

detect

<T extends MDWObject> T detect(String scriptName,
                               Object value)
Returns the first MDWObject of this Set whose script evaluation result matches the specified value.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Specified by:
detect in interface MDWCollection<E>
Parameters:
scriptName - the name of the script to evaluate on each MDWObject. This script must not expect any parameter.
value - the comparison criterium (can be null).
Returns:
the first MDWObject instances whose script result matches the specified value, null if no instance matches the value.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.
See Also:
select(String, Object)

detect

<T extends MDWObject> T detect(String scriptName,
                               List<?> arguments,
                               Object value)
Returns the first MDWObject of this Set whose script evaluation result matches the specified value.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

The number and type of arguments must match the parameters of the script.

Specified by:
detect in interface MDWCollection<E>
Parameters:
scriptName - the name of the script to evaluate on each MDWObject.
arguments - the script arguments.
Returns:
the first MDWObject instances whose script result matches the specified value, null if no instance matches the value.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.
See Also:
select(String, List, Object)

detect

<T extends MDWObject> T detect(EStructuralFeature feature,
                               Object value)
Returns the first MDWObject of this Set whose feature matches the specified value.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Specified by:
detect in interface MDWCollection<E>
Parameters:
feature - the feature to evaluate on each MDWObject.
value - the comparison criterium (can be null).
Returns:
the first MDWObject instances whose feature matches the specified value, null if no instance matches the value.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.

collect

<T> MDWList<T> collect(String scriptName)
Evaluates the specified script on each MDWObject of this Set, and concatenates the results into a new list.

The returned list is always flattened: if a script result is a collection (Collection, Map, Iterator or array), we iterate on this collection and add each element into the returned list.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Specified by:
collect in interface MDWCollection<E>
Parameters:
scriptName - the name of the script to evaluate on each MDWObject. This script must not expect any parameter.
Returns:
a modifiable list containing each script result.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.

collect

<T> MDWList<T> collect(String scriptName,
                       List<?> arguments)
Evaluates the specified script on each MDWObject of this Set, and concatenates the results into a new list.

The returned list is always flattened: if a script result is a collection (Collection, Map, Iterator or array), we iterate on this collection and add each element into the returned list.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

The number and type of arguments must match the parameters of the script.

Specified by:
collect in interface MDWCollection<E>
Parameters:
scriptName - the name of the script to evaluate on each MDWObject.
arguments - the script arguments.
Returns:
a modifiable list containing each script result.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.

collect

<T> MDWList<T> collect(EStructuralFeature feature)
Evaluates the specified feature on each MDWObject of this Set, and concatenates the results into a new list.

The returned list is always flattened: if a feature is a collection, we iterate on this collection and add each element into the returned list.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Specified by:
collect in interface MDWCollection<E>
Parameters:
feature - the feature to evaluate on each MDWObject.
Returns:
a modifiable list containing each feature result.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.

sort

MDWList<E> sort(String scriptName)
Returns a sorted list into ascending order induced by the specified script.

The script is evaluated on each MDWObject of this Set, the script results are then used to compare elements. This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Specified by:
sort in interface MDWCollection<E>
Parameters:
scriptName - the name of the script to evaluate on each MDWObject. This script must not expect any parameter.
Returns:
a modifiable list containing each script result.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances, or if the script results that are not mutually comparable (for example, strings and integers).

sort

MDWList<E> sort(String scriptName,
                List<?> arguments)
Returns a sorted list into ascending order induced by the specified script.

The script is evaluated on each MDWObject of this Set, the script results are then used to compare elements. This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

The number and type of arguments must match the parameters of the script.

Specified by:
sort in interface MDWCollection<E>
Parameters:
scriptName - the name of the script to evaluate on each MDWObject.
arguments - the script arguments.
Returns:
a modifiable list containing each script result.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances, or if the script results that are not mutually comparable (for example, strings and integers).

sort

MDWList<E> sort(EStructuralFeature feature)
Returns a sorted list into ascending order induced by the specified feature.

The feature is evaluated on each MDWObject of this Set, the feature results are then used to compare elements. This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Specified by:
sort in interface MDWCollection<E>
Parameters:
feature - the feature to evaluate on each MDWObject.
Returns:
a modifiable list containing each feature result.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.

toList

MDWList<E> toList()
Converts this Set to a new modifiable MDWList.

Returns:
a modifiable MDWList containing each element of this Set.

getInstances

<T extends E> MDWSet<T> getInstances(String typeName)
Selects MDWObject instances of this Set of the specified type.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Class" for example), or a simple name ("Class"), if this name is unique in the metamodel.

Parameters:
typeName - the type name of model elements to retrieve.
Returns:
a modifiable Set of MDWObject that matches the specified type.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.
See Also:
getInstances(String, boolean)

getInstances

<T extends E> MDWSet<T> getInstances(String typeName,
                                     boolean includeSubTypes)
Selects MDWObject instances of this Set of the specified type, or one of its sub types.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Class" for example), or a simple name ("Class"), if this name is unique in the metamodel.

Parameters:
typeName - the type name of model elements to retrieve.
includeSubTypes - determines wheter to retrieve elements based on sub types.
Returns:
a modifiable Set of MDWObject that matches the specified type, or one of its sub types.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.
See Also:
getInstances(String)

getInstances

<T extends E> MDWSet<T> getInstances(EClass type)
Selects MDWObject instances of this Set of the specified type.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Parameters:
type - the type of model elements to retrieve.
Returns:
a modifiable Set of MDWObject that matches the specified type.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.
See Also:
getInstances(EClass, boolean)

getInstances

<T extends E> MDWSet<T> getInstances(EClass type,
                                     boolean includeSubTypes)
Selects MDWObject instances of this Set of the specified type, or one of its sub types.

This Set is expected to contain only MDWObject instances. A ClassCastException is thrown if any other kind of element is found (null values are silently ignored).

Parameters:
type - the type of model elements to retrieve.
includeSubTypes - determines wheter to retrieve elements based on sub types.
Returns:
a modifiable Set of MDWObject that matches the specified type, or one of its sub types.
Throws:
ClassCastException - if the Set contains anything else than MDWObject instances.
See Also:
getInstances(EClass)

getProfiledInstances

<T extends E> MDWSet<T> getProfiledInstances(String typeName,
                                             String profileName)
Selects MDWObject instances of this Set of the specified type, which match the specified profile name. This method does not consider sub types of the specified type.

The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Class" for example), or a simple name ("Class"), if this name is unique in the metamodel.

Parameters:
typeName - the type name of model elements to retrieve.
profileName - the name of the profile type the instances must match.
Returns:
a modifiable Set of MDWObject that matches the specified type.
Throws:
InvalidCallException - if this API is not called during an MDWorkbench evaluation.
See Also:
getProfiledInstances(String, String, boolean)

getProfiledInstances

<T extends E> MDWSet<T> getProfiledInstances(String typeName,
                                             String profileName,
                                             boolean includeSubTypes)
Selects MDWObject instances of this Set of the specified type, or one of its sub types, which match the specified profile name.

The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Classifier" for example), or a simple name ("Classifier"), if this name is unique in the metamodel.

Parameters:
typeName - the type name of model elements to retrieve.
profileName - the name of the profile type the instances must match.
includeSubTypes - determines wheter to retrieve elements based on sub types.
Returns:
a modifiable Set of MDWObject that matches the specified type, or one of its sub types.
Throws:
InvalidCallException - if this API is not called during an MDWorkbench evaluation.
See Also:
getProfiledInstances(String, String)

getProfiledInstances

<T extends E> MDWSet<T> getProfiledInstances(EClass type,
                                             String profileName)
Selects MDWObject instances of this Set of the specified type, which match the specified profile name. This method does not consider sub types of the specified type.

Parameters:
type - the type of model elements to retrieve.
profileName - the name of the profile type the instances must match.
Returns:
a modifiable Set of MDWObject that matches the specified type.
Throws:
InvalidCallException - if this API is not called during an MDWorkbench evaluation.
See Also:
getProfiledInstances(EClass, String, boolean)

getProfiledInstances

<T extends E> MDWSet<T> getProfiledInstances(EClass type,
                                             String profileName,
                                             boolean includeSubTypes)
Selects MDWObject instances of this Set of the specified type, or one of its sub types, which match the specified profile name.

Parameters:
type - the type of model elements to retrieve.
profileName - the name of the profile type the instances must match.
includeSubTypes - determines wheter to retrieve elements based on sub types.
Returns:
a modifiable Set of MDWObject that matches the specified type, or one of its sub types.
Throws:
InvalidCallException - if this API is not called during an MDWorkbench evaluation.
See Also:
getProfiledInstances(EClass, String)