list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

User Manual    [Previous]   [Next]   

W141 Value Type Mismatch

Umple syntactic warning reported when an attempt is made to initiate an attribute with a value that does not match the type of the attribute

Numbers must be initialized with numbers, strings with strings in double quotes, and Booleans with true or false. For Dates the value format is a string "yyyy-mm-dd"; for Times the format is "hh:mm:ss".

Note that for an initialization value with no type specified will result in the attribute having its type inferred from the value. This is demonstrated in the third example.

Example

// The following will generate
// this warning on every line of the class
class X {
  Date d = "20130708";
  Integer i = "abc";
  String s = 123;
  Boolean b = 1;
  Time t = "120000";
}

      

Load the above code into UmpleOnline

 

Solution to The Above So the Message No Longer Appears

// The following shows how to solve the above problem
class X {
  Date d = "2013-07-08";
  Integer i = 7;
  String s = "123";
  Boolean b = true;
  Time t = "12:00:00";
}
      

Load the above code into UmpleOnline

 

Solution to The Above So the Message No Longer Appears

// The following shows how to solve
// the above problem not even showing the type at all
class X {
  d = "2013-07-08";
  i = 7;
  s = "123";
  b = true;
  t = "12:00:00";
  m = 2.3;
}
      

Load the above code into UmpleOnline