Representation of a library.
Root element of the library metamodel.
Extends: EObject
Attributes:
- name :
EString
- Name of the library. The documentation supports both HTML formatting tags and doc comment style
formatting
.
- Name of the library. The documentation supports both HTML formatting tags and doc comment style
- address :
EString
References:
- books [0..*]: Book
- Books stored in the library.
- Containment: contains
- Opposite: Book.
library
- authors [0..*]: Writer
- Authors known in the library.
- Containment: contains
- Opposite: Writer.
library
Operations:
- getBook(title :
EString
) : Book- Returns a book known by the given title. Returns
null
if no book is known with the given title.
- Returns a book known by the given title. Returns
@GenModel(documentation="Representation of a library.\n\nRoot element of the library metamodel.")
class Library {
@GenModel(documentation="Name of the library. The documentation supports both <b>HTML</b> <i>formatting</i> tags and doc comment style {@code formatting}.")
String name
@GenModel(documentation="Address of the library. Linking to other elements is possible: {@link Library} or {@link Library like this}.")
String address
@GenModel(documentation="Books stored in the library.")
contains Book[0..*] books opposite library
@GenModel(documentation="Authors known in the library.")
contains Writer[0..*] authors opposite library
@GenModel(documentation="Returns a book known by the given title. Returns {@code null} if no book is known with the given title.")
op Book getBook(String title) {
for (Book book : books) {
if (title == book.title) return book
}
return null
}
}
Representation of a physical instance of a book, located in a library.
Extends: EObject
Attributes:
- title :
EString
- Title of the book.
- bookCategory : BookCategory
- Category of the book. Exactly one of the defined book categories.
- pages :
EInt
- Number of pages. Expected to be positive.
- copyright : Date
- Date of release.
References:
- library : Library
- The library containing this book instance.
- Containment: container
- Opposite: Library.
books
- authors [1..*]: Writer
-
Writers of the book.
The referred writers are expected to be contained by
this.library
. -
Containment: refers
-
Opposite: Writer.
books
-
@GenModel(documentation="Representation of a physical instance of a <b>book</b>, located in a <i>library</i>.")
class Book {
@GenModel(documentation="Title of the book.")
String title
@GenModel(documentation="Category of the book. Exactly one of the defined {@link BookCategory book categories}.")
BookCategory bookCategory
@GenModel(documentation="Number of pages. Expected to be positive.")
int pages
@GenModel(documentation="Date of release.")
Date copyright
@GenModel(documentation="The library containing this book instance.")
container Library library opposite books
@GenModel(documentation="Writers of the book.\n\nThe referred writers are expected to be contained by `this.library`.")
refers Writer[1..*] authors opposite books
}
Extends: EObject
Attributes:
- name :
EString
- lastName :
EString
- Modifiers: Derived
References:
- library : Library
- Containment: container
- Opposite: Library.
authors
- books [0..*]: Book
- Containment: refers
- Opposite: Book.
authors
class Writer {
String name
container Library library opposite authors
refers Book[] books opposite authors
derived String lastName get {
if (name !== null) {
val int index = name.lastIndexOf(' ')
if (index != -1) name.substring(index+1) else name
}
}
}
Known book categories.
Literals:
Mistery
(M): Mistery books. It includes fairy tales too.ScienceFiction
(S): Science-fiction books.Biography
(B): Biography books.
@GenModel(documentation="Known book categories.")
enum BookCategory {
@GenModel(documentation="Mistery books. It includes fairy tales too.")
Mistery as "M"
@GenModel(documentation="Science-fiction books.")
ScienceFiction as "S"
@GenModel(documentation="Biography books.")
Biography as "B"
}
Date (year, month, day) representation.
- Wraps:
java.util.Date