Abstract
Map and function types are of high utility in software specification and design, for example, maps can be used to represent configurations or caches, whilst function values can be used to enable genericity and reuse in a specification, and to support mechanisms such as callbacks or closures in an implementation. Map and function types have been incorporated into the leading programming languages, including Java, C++, Swift and Python.
The Object Constraint Language (OCL) specification notation lacks such types, and in this paper we make a proposal for a consistent extension of OCL with map and function types, and we identify modifications to OCL semantics to include these types. We also describe how map and function types are implemented using the Eclipse AgileUML toolset.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
Used in the ATL extension of OCL.
References
AgileUML repository (2020). https://github.com/eclipse/agileuml/
Belaunde, M.: Evolution of the OCL OMG specification, OCL (2010)
Sánchez Cuadrado, J., Jouault, F., García Molina, J., Bézivin, J.: Optimization patterns for OCL-based model transformations. In: Chaudron, M.R.V. (ed.) MODELS 2008. LNCS, vol. 5421, pp. 273–284. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-01648-6_29
Ciesielski, K.: Set Theory for the Working Mathematician. Cambridge University Press, Cambridge (1997)
Cook, S., Kleppe, A., Mitchell, R., Rumpe, B., Warmer, J., Wills, A.: The Amsterdam manifesto on OCL. In: Clark, T., Warmer, J. (eds.) Object Modeling with the OCL. LNCS, vol. 2263, pp. 115–149. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45669-4_7
Eclipse, ATL user guide, eclipse.org (2019)
Eclipse AgileUML project (2020). https://projects.eclipse.org/projects/modeling.agileuml
Eclipse OCL Version 6.4.0 (2021). https://projects.eclipse.org/projects/modeling.mdt.ocl
The Epsilon Object Language (2020). https://www.eclipse.org/epsilon/doc/eol
Hennicker, R., Hussmann, H., Bidoit, M.: On the precise meaning of OCL constraints. In: Clark, T., Warmer, J. (eds.) Object Modeling with the OCL. LNCS, vol. 2263, pp. 69–84. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45669-4_5
Kleppe, A., Warmer, J., Cook, S.: Informal formality? The object constraint language and its application in the UML metamodel. In: Bézivin, J., Muller, P.-A. (eds.) UML 1998. LNCS, vol. 1618, pp. 148–161. Springer, Heidelberg (1999). https://doi.org/10.1007/978-3-540-48480-6_12
Kleppe, A.: Object constraint language: metamodelling semantics (Chap. 7). In: UML 2 Semantics and Applications. Wiley (2009)
Lano, K.: The B Language and Method. Springer, Heidelberg (1996). https://doi.org/10.1007/978-1-4471-1494-9
Lano, K.: A compositional semantics of UML-RSDS. Softw. Syst. Model. 8(1), 85–116 (2009). https://doi.org/10.1007/s10270-007-0064-x
Lano, K., Clark, T., Kolahdouz-Rahimi, S.: A framework for model transformation verification. Form. Asp. Comput. 27(1), 193–235 (2014). https://doi.org/10.1007/s00165-014-0313-z
Lano, K.: Agile Model-Based Development Using UML-RSDS. CRC Press, Boca Raton (2016)
Lano, K.: Map type support in OCL?, November 2018. https://www.eclipse.org/forums/index.php/t/1096077/
OMG, Object Constraint Language 2.4 Specification (2014)
OMG, MOF2 Query/View/Transformation v1.3 (2016)
OMG (2020). https://issues.omg.org/issues/spec/OCL/2.4
Richters, M., Gogolla, M.: On formalizing the UML object constraint language OCL. In: Ling, T.-W., Ram, S., Li Lee, M. (eds.) ER 1998. LNCS, vol. 1507, pp. 449–464. Springer, Heidelberg (1998). https://doi.org/10.1007/978-3-540-49524-6_35
Spivey, J.: The Z Notation. Prentice Hall, Hoboken (1989)
Willink, E.: OCL omissions and contradictions, OMG ADTF (2012)
Willink, E.: Reflections on OCL 2. J. Object Technol. 19(3), 1–16 (2020)
Willink, E.: An OCL map type. In: OCL 2019 (2019)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
A Additional Map Type Operators
A Additional Map Type Operators
The following map operators can also be formalised in our proposed extension of OCL.
size() : Integer
This is equal to \(self{\rightarrow }keys(){\rightarrow }size()\).
includesValue(object : T) : Boolean True if the object is an element of the map range, false otherwise:
Similarly for \({\rightarrow }includesKey()\), \({\rightarrow }excludesValue()\), \({\rightarrow }excludesKey()\).
count(object : T) : Integer The number of times the object occurs as an element of the map range (a bag):
includesAll(c2 : Map(K,T)) : Boolean True if c2 is a map, and the set of pairs of self contains all those of c2, false otherwise:
Similarly for \({\rightarrow }excludesAll()\).
isEmpty() : Boolean, notEmpty() : Boolean Defined based on \(self{\rightarrow }asSet()\).
max() : T, min() : T, sum() : T Defined as the corresponding operations on \(self{\rightarrow }values()\).
asSet() : Set(Tuple(key : K, value : T)) The set of pairs of elements in the map. Since duplicate keys are not permitted, this has the same size as \(self{\rightarrow }keys()\).
restrict(ks : Set(K)) : Map(K,T) Domain restriction . The map restricted to the keys in ks. Its elements are the pairs of self whose key is in ks:
Range restriction is provided via the \({\rightarrow }select\) operator.
-(m: Map(K,T)) : Map(K,T) Map subtraction: the elements of self that are not in m.
union(m : Map(K,T)) : Map(K,T) Map override, the operation \(self \oplus m\) or \(self~{{<}{+}}~m\) in mathematical notation. This consists of the pairs of self which do not conflict with pairs of m, together with all pairs of m:
This is the same as putAll in EOL [9]. Unlike set union, it is not commutative.
intersection(m : Map(K,T)) : Map(K,T) The pairs of self which are also in m:
This is associative and commutative.
including(k : K, v : T) : Map(K,T) The pairs of self, with the additional/overriding mapping of k to v:
We also use the abbreviated notation \(m[k] = v\) for \(m = m{\text{@ }pre}{\rightarrow }including(k,v)\).
excluding(k : K, v : T) : Map(K,T) The pairs of self, with any mapping of k to v removed:
any Defined as
Likewise for forAll, exists, one.
select The map formed by restricting to range elements which satisfy the select condition:
Similarly for reject.
Rights and permissions
Copyright information
© 2021 IFIP International Federation for Information Processing
About this paper
Cite this paper
Lano, K., Kolahdouz-Rahimi, S. (2021). Extending OCL with Map and Function Types. In: Hojjat, H., Massink, M. (eds) Fundamentals of Software Engineering. FSEN 2021. Lecture Notes in Computer Science(), vol 12818. Springer, Cham. https://doi.org/10.1007/978-3-030-89247-0_8
Download citation
DOI: https://doi.org/10.1007/978-3-030-89247-0_8
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-89246-3
Online ISBN: 978-3-030-89247-0
eBook Packages: Computer ScienceComputer Science (R0)