Java Reference
In-Depth Information
The
oclIsKindOf()
operation is used frequently, and you can substitute
the unary
#
operator for it. Typing
#Topic
is equivalent to typing
oclIsKindOf(Topic)
. This shorthand notation is not currently
supported.
❍
The
oclIsTypeOf()
operation is also commonly used, and you can sub-
stitute the unary
##
operator for it. Typing
##Topic
is equivalent to
typing
oclIsTypeOf(Topic)
. This shorthand notation is not currently
supported.
❍
You can substitute the unary
*
operator for the
stereotypedBy()
operation. Typing
*aStereotype
is equivalent to typing
stereotypedBy("aStereotype")
. The multiplication operator brings
up no ambiguity because of the type involved (String vs. Float/Integer).
This shorthand notation is not currently supported.
❍
You can substitute the unary
%
operator for the
format()
operation.
Typing
'the name is %s\n' % name
is the equivalent to typing
'the name is %s\n'.format(name)
. Again, ambiguity is eliminated
because of the type involved. This shorthand notation is not currently
supported.
❍
Instead of using the single equals sign (
=
) equality operator, you can use
the more familiar double equals sign (
==
) for comparison operations.
* This shorthand notation is not currently supported.
❍
You can replace the not-equal operator
<>
with the familiar
!=
operator.
* This shorthand notation is not currently supported.
❍
You can use the binary operator
+
for String concatenation, thereby
replacing
'append'.concat('me')
with
'append' + 'me'
. Again,
ambiguity is eliminated by the type involved (String vs. Integer/Float).
❍
When adding to lists, you can replace the
add()
operation with the
binary operator
+=
—for example,
allSubtopics +=
topic.subtopics()
.
❍
* Note that using
==
and
!=
shorthand notation requires a directive com-
ment at the top of the source file. This makes the traditional OCL operators
=
and
<>
illegal within the file. Following is an example directive comment
(although it seems that use-contemporary-syntax would be a more fitting name):
-- directive: use-traditional-comparison-syntax
Search WWH ::
Custom Search