All the models in Mat|r script define a new data type that may be instantiated and referenced from the declaration of other data types such as Array and Map.

Example:

Model Person {
	String name
	Double height
	Integer age
}

Model Class {
  Array <Person> students
}

//....

Rule instantiateModels {
  Person p = Person(name: "John", height: 1.80)
  Class a = Class()
  a.students = []
  a.students.add(p)
}

CONSTRUCTORS

Model ModelName(atributo1: TipoAtributo1, atributo2: TipoAtributo2, …)

The constructors are generated with the name of the model to be instantiated followed by the parameters (optional) to be initialized.

PUBLIC METHODS

Model clone()

It returns a new instance of the model, returning a true copy of each of its attributes.

Return  
Model new instance of the model.

Bool isEqualTo(Any valor)

It compares by value against the argument valor of any type. It returns true if the value matches with the model instance. Otherwise, it returns false. Comparison of values of different type always returns false.

Arguments  
value value to compare.
Return  
Bool True is the value matches the model instance. Otherwise, it is false.

Models Integrated in Mat|R Script

The following data types are models already included in the language. Therefore, they respond to the same methods.

Location

It is used for the representation of a geolocation point. This data type may be instantiated by its builder or as a return of a request of the services that have access to the gps of the device within the namespace location.

CONSTRUCTOR

Location(latitude: Double, longitude: Double)

Arguments  
latitude Double: latitude.
longitude Double: longitude.

Marker

It is used by the visual componentMapView that may be part of an experience. It enables the user to configure the information and interaction of a geolocation point in the map.

CONSTRUCTOR

Marker(location: Location, title: String, description: String, tintColor: String, showBubble: Boolean, leftIcon: String)

Arguments  
location Location: geolocation where we want to show the marker.
title String: title of the information bubble of the marker.
description String: description of the information bubble of the marker.
tintColor String: Hex color code of the marker.
showBubble Boolean: activates or deactivates the information bubble of the marker.
leftIcon String: url with an image of the marker.

OAuth

This data type is used along with the broker.oauth.* service that enables the authorization using
OAuth2 protocol. In this data type, all the necessary fields that are part in the steps of Oauth2 protocol are configured.

CONSTRUCTOR

OAuth(clientID: String, secret: String, authorizationURL: String, tokenURL: String, redirectURL: String, accountName: String)

Arguments  
clientID String: Client ID.
secret String: password.
authorizationURL String: authorization URL.
tokenURL String: token reception URL.
redirectURL String: Redirect URL.
accountName String: name of the account.