|
E013 Non Immutable Association
[Previous]  [Next] 
|
![]() |
User Manual [Previous]  [Next] E013 Non Immutable AssociationUmple semantic error reported when an immutable class is defined as having an association to a non-immutable class.By definition, an immutable class can't change state, so it can't have an association that can change state or an association to a class that can change state. Example
// The following example generates
// the error message
class X {
Integer x;
}
class Y {
String s;
immutable;
0..1 -> 0..1 X;
}
Load the above code into UmpleOnline Solution to The Above So the Message No Longer Appears
// One way to solve this is to make
// the association point to
// another immutable class
// But note that this only works for
// one-way associations
class X {
Integer x;
immutable;
}
class Y {
immutable;
String s;
0..1 -> 0..1 X;
}
Load the above code into UmpleOnline Another Solution to The Above So the Message No Longer Appears
// Another solution is to not require
// the association to be immutable,
// just the attributes. But this may
// not match the intended semantics.
class X {
immutable Integer x;
}
class Y {
immutable String s;
0..1 -- 0..1 X;
}
Load the above code into UmpleOnline |