Gloop models
Gloop models are used by Gloop to store application data in memory1 while your applications are running. They are very good at reading and writing themselves to and from XML, JSON, YAML, common flat file formats2, SQL databases via SQL services, and others more. They are also great at automatically converting various types of Java objects into the type the Gloop object itself expects3.
Gloop models, like Java objects, contain properties4.
They are analogous to JavaBeans in that they are basically objects comprised of properties such as
String
s, Integer
s, Date
s,
Boolean
s, and so on. However, Gloop model properties are also Gloop objects. Gloop
objects contain extra functionality and a common set of properties to make configuring Gloop objects easier. Below is a
list of the types of Gloop objects available in alphabetical order and their counterparts in Java:
Gloop object type | Wrapped Java equivalent |
---|---|
BigDecimal |
java.math.BigDecimal |
BigInteger |
java.math.BigInteger |
Boolean |
java.lang.Boolean |
Byte |
java.lang.Byte |
ByteArray |
byte [] |
Character |
java.lang.Character |
Date |
java.util.Date |
Double |
java.lang.Double |
Float |
java.lang.Float |
Integer |
java.lang.Integer |
Long |
java.lang.Long |
Model |
N/A |
Object |
java.lang.Object |
Short |
java.lang.Short |
String |
java.lang.String |
Gloop + Groovy = ❤️
Gloop models are also very easy to manipulate using Groovy code. The code you would write to work with JavaBeans and Gloop models is the same. For example, the code below works for JavaBeans and Gloop models:
1 2 3 4 5 6 7 | // Say you have a JavaBean with a property called stringProperty // or a Gloop model with a property called stringProperty myJavaBeanOrGloopModel.stringProperty = 'World!' println "Hello, ${myJavaBeanOrGloopModel.stringProperty}!" // Add an entry to a Gloop model or JavaBean array property: myJavaBeanOrGloopModel.myStringArray << 'Earth!' |
You can also dynamically add new properties to a Gloop model. To do this,
Allow Extra Properties
must be set to true
. For example:
1 2 3 4 5 | // Enable extra properties in 'myGloopModel' myGloopModel.setAllowExtraProperties(true) // Add a new property called 'extraProperty' to 'myGloopModel' myGloopModel.extraProperty = 'Hello, world!' |
Gloop models can also easily be manipulated using any of the supported languages in GraalVM.
-
Like Java objects. ↩
-
Such as CSV and fixed width text files with the help of Gloop services. ↩
-
Such as
File
toInputStream
,String
toInteger
, etc. ↩ -
or in OOP, member variables ↩