12.05.2013 Views

Modelado de Software con UML2.0 - Universidad Autónoma de ...

Modelado de Software con UML2.0 - Universidad Autónoma de ...

Modelado de Software con UML2.0 - Universidad Autónoma de ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Ejemplos Ejemplos. Colecciones.<br />

Colecciones<br />

collect(expr): <strong>de</strong>vuelve la colección que resulta <strong>de</strong> evaluar expr<br />

para cada elemento <strong>de</strong> la colección fuente.<br />

self self.employee->collect( employee >collect( birthDate ) )->asSet() >asSet()<br />

forAll(expr): <strong>de</strong>vuelve verda<strong>de</strong>ro si expr es verda<strong>de</strong>ro en cada<br />

elemento <strong>de</strong> la colección.<br />

coleccion->forAll( expresion-logica )<br />

coleccion->forAll( v | expresion-logica-<strong>con</strong>-v )<br />

coleccion->forAll( v : Type | expresion-logica-<strong>con</strong>-v )<br />

<strong>con</strong>text Company<br />

inv: self.employee->forAll( isUnemployed = False )<br />

inv: self.employee->forAll( p | p.isUnemployed = False )<br />

iinv: self.employee->forAll( lf l >f All( p : Person P | p.isUnemployed i U l d = FFalse l )<br />

Colecciones Colecciones. Otras Operaciones<br />

Operaciones.<br />

Otras operaciones p <strong>de</strong> bucle:<br />

source->any(iterator|body)<br />

source->select(iterator|body)->asSequence()->first()<br />

source->collectNested(iterators|body)<br />

source collectNested(iterators|body)<br />

Bag <strong>de</strong> elementos que resultan <strong>de</strong> aplicar body a cada elemento <strong>de</strong><br />

source.<br />

source->isUnique(iterators|body)<br />

( | y)<br />

True si body se evalua a un valor diferente para cada elemento <strong>de</strong><br />

source.<br />

source->one(expr)<br />

Devuelve true si existe exactamente un elemento <strong>de</strong> source que cumple<br />

la <strong>con</strong>dición.<br />

source->reject(expr)<br />

Devuelve una colección <strong>con</strong> los elementos <strong>de</strong> source que no cumplen la<br />

<strong>con</strong>dición.<br />

source->sortedBy(expr)<br />

Or<strong>de</strong>na source, source resulta en un Or<strong>de</strong>redSet<br />

121<br />

123<br />

Ejemplos Ejemplos. Colecciones.<br />

Colecciones<br />

exists(expr): <strong>de</strong>vuelve true si al menos hay un elemento en la<br />

colección para el que expr es verda<strong>de</strong>ra verda<strong>de</strong>ra.<br />

coleccion->exists( expresion-logica )<br />

coleccion->exists( v | expresion-logica-<strong>con</strong>-v )<br />

coleccion->exists( v : Type | expresion-logica-<strong>con</strong>-v )<br />

<strong>con</strong>text Company<br />

inv: self.employee->exists( age > 50 )<br />

inv: self.employee->exists( p | p.age > 50 )<br />

inv: self.employee->exists( p : Person | p.age > 50 )<br />

iterate(…): itera sobre todos los elementos <strong>de</strong> una colección.<br />

coleccion->iterate( elem : Type; acc : Type = | expresion-logica-<br />

<strong>con</strong>-elem-y-acc l )<br />

collection->collect(x : T | x.property)<br />

collection->iterate(x ( : T; ; acc : T2 = Bag{} g{} | acc->including(x.property))<br />

g( p p y))<br />

Indice<br />

Introducción.<br />

Diagramas <strong>de</strong> Clases y Objetos.<br />

Otros Diagramas. g<br />

OCL.<br />

Acción Acción Semántica.<br />

Perfiles.<br />

Bibliografía g<br />

Lecturas sugeridas/ejercicios.<br />

aña<strong>de</strong> un elemento a una colección<br />

122<br />

124

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!