uOttawaUniversity of Ottawa - Canadas University
list of dots

Umple User Manual    [Previous]   [Next]   

Loading

isA clause

The isA keyword is used to denote an inheritance relationship (generalization) between two classes, or a class and the interfaces it implements, or a class and the traits it includes.

This corresponds to keywords such as 'extends', 'subclass', etc. in other languages. The isA keyword was chosen so as to be independent of other languages, and due to the strong conceptual similarity between interfaces, classes and traits.

Note that it is possible to avoid using the isA keyword for class generatlization, by directly embedding a subclass inside a superclass. Note that this does not create an inner class in the Java sense, but instead creates a subclass. The two examples below give identical results.

The following is how a generalization appears in UML. The corresponding Umple is below. Note that in UmpleOnline, the expected layout for generalizations places superclasses above subclasses.

Generalization with Person as superclass and Student as subclass

Example

// A superclass-subclass relationship defined using the isA keyword
class Person
{
  name;
}

class Student
{
  isA Person;
  Integer number;
}
      

Load the above code into UmpleOnline

 

Another Example

// A superclass-subclass relationship defined
// by embedding the subclass in the superclass
class Person
{
  name;
  
  class Student
  {
    Integer number;
  }
}

      

Load the above code into UmpleOnline

 

Syntax


// Generalization and inheritance isAclause
isA- : [[singleIsA]] | [[multipleIsA]]

singleIsA- : isA [[isAName]] ( , isA [[isAName]] )* ;

multipleIsA- : isA [[isAName]] ( , [[isAName]] )* ;