Skip to content

Home

Introduction

Development

IDEs

Services

Service manager

API Explorer

Gloop object types

Gloop models are like JavaBeans in that they have fields (or in Java-speak, properties). This page describes the types of properties you can add to a Gloop model, and what types of objects or values they can store.

A Gloop object is an instance of any of those types. Gloop objects of all types have extra properties of their own, which we will call meta-properties. These meta-properties assist Gloop in reading and writing to XML, JSON, and YAML; help enrich the user interfaces of Coder; and help better describe Gloop APIs when they're exposed as REST and SOAP web services.

Available object types

Below is a table that shows the types of properties that a model can store (in alphabetical order). Also in this list is an Object type. This means that a Gloop object isn't limited to having a basic type; you could use a Gloop Object object1 to reference a Java or Groovy object (via setting its class name).

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

Meta-properties

This section describes all of the meta-properties and lists which objects support them. The meta-properties below will help your Gloop objects and Gloop models perform self-validation, as well as help you when reading and writing Gloop data in various formats.

Some meta-properties are only present in certain Gloop object types. Refer to the table below to know which types support which meta-properties (X's indicate support):

Gloop object type Name Alias Comments Default Value Required Allow Null Array Minimum Array Size Maximum Array Size Validation Expression Output Expression Namespace URI Choices Allow Other Values Minimum Maximum XML Attribute Date Formats XML Type Allow Extra Properties Reference Object Class Name Minimum Length Maximum Length
BigDecimal X X X X X X X X X X X X X X X X X
BigInteger X X X X X X X X X X X X X X X X X
Boolean X X X X X X X X X X X X X
Byte X X X X X X X X X X X X X X X X X
ByteArray X X X X X X X X X X X X
Character X X X X X X X X X X X X X X X X X
Date X X X X X X X X X X X X X X X
Double X X X X X X X X X X X X X X X X X
Float X X X X X X X X X X X X X X X X X
Integer X X X X X X X X X X X X X X X X X
Long X X X X X X X X X X X X X X X X X
Model X X X X X X X X X X X X X
Object X X X X X X X X X X X X X
Short X X X X X X X X X X X X X X X X X X
String X X X X X X X X X X X X X X X X X

Name

The name of the Gloop object. This is what you will see in the Coder UI, and is normally used to access the property in your Groovy code. Think of this as the name of your variable.

If the name is a reserved Java or Groovy keyword, or an invalid Java or Gloop variable name, then the meta-property Alias will contain the original name value (which is used when serializing to XML, JSON, YAML, and others). The new name will be prefixed with an underscore, and should be used when manipulating Gloop objects in Groovy code.

Alias

This is the value that's used as the variable's name (name in JSON/YAML, attribute/element name in XML) when serialising as JSON, XML, YAML, flat files, etc. Normally the name is okay, but if the name contains characters or a sequence that renders it invalid for Gloop, then the name is sanitised for use in Gloop code and the alias is used when serialising.

When your Gloop property name requires an alias, the alias will be shown after the name in brackets in Coder. Below is a screenshot of a property in Coder, and its representation in JSON and XML. To access the property in the screenshot below in Groovy code, myModel._1invalidProperty would be used. However when the property is read and written, 1invalidProperty would be used.

Coder showing a Gloop property with its XML and JSON in Coder

Coder showing a Gloop property with its XML and JSON in Coder

Comments

You can add comments to document any extra information about a Gloop object. When your a Gloop model property has a comment, they appear after the name and // in Coder.

Gloop model property comments, as shown in Coder

Gloop model property comments, as shown in Coder

Comments that are added to properties automatically end up in your Gloop API files.

Gloop model property comments shown in generated Swagger definition

Gloop model property comments shown in generated Swagger definition

Default Value

If the Gloop object has no actual value (value == null), then the configured Default Value is used. This is the same as initialising a field in Java, for example:

1
Integer myNumber = 4;

All Gloop object types, except Gloop models, can have default values.

Required

This is used to determine whether to show the variable in XML, JSON, or YAML; regardless if the value is null. If this variable has a null value and Required is set to false, then it will not be serialised. If Required is true, then it will be serialised as follows:

JSON

1
"myGloopProperty": null

XML

1
<myGloopProperty />

YAML

1
myGloopProperty:

Allow Null

This will determine whether the Gloop object allows null values or not. Gloop validates the objects' Allow Null property before invoking Gloop services or Groovy services. At runtime, if a property has an Allow Null value of false and its value is null, an exception will be thrown.

In the screenshot below, you will notice that while coding, when a property has a false Allow Null value, it will be shown in bold in the Mapper view. Coder will also show an error next to the step in your Gloop service while you're coding your integrations if the value appears to be null.

Coder showing a Gloop property with `Allow Null` == `false`

Coder showing a Gloop property with `Allow Null` == `false`

Array

This tells Gloop whether the property should be treated as an array or not. Array properties can be mapped to Gloop cursors. When a property is marked as an array, Gloop holds the values in a java.util.List. Also, if you look closely, your property will appear with array brackets on the bottom right corner of its icon.

Coder showing the Gloop array badge

Coder showing the Gloop array badge

Array ninja[]

Gloop allows you to map arrays to non-arrays and vice versa. When mapping an array to a non-array, the first element in the array will be mapped. When mapping a non-array to an array, the array will be cleared, and the mapped value will be the first entry in the newly-cleared array.

You also have three ways in which to toggle whether a Gloop object is an array or not. Via the (1) Convert To context menu (which is activated when right-clicking on a property), (2) Properties table, or (3) by pressing .

Gloop array toggles

Gloop array toggles

Minimum Array Size

This property tells Gloop what the minimum size of the array must be. If the property is empty, then it will not perform this validation. Gloop validates the objects' Minimum Array Size property before invoking Gloop Services. If a property has an array whose size is less than the Minimum Array Size value, an Exception will be thrown.

Maximum Array Size

This property tells Gloop what the maximum size of the array must be. If the property is empty, then it will not perform this validation. Gloop validates the objects' Maximum Array Size property before invoking Gloop services. If a property has an array whose size is greater than the Maximum Array Size value, an Exception will be thrown.

Validation Expression

This property is used by Gloop to validate the value of the object. The expression must be written in Groovy. If the property is an array, then Gloop will evaluate the expression for every value in the array. Gloop expects the expression to return a boolean. When the expression returns true, Gloop will assume the value is valid. When the expression is executed, Gloop will provide up to four variables:

  • gloopObject

    The actual Gloop object.

  • val

    This is the actual value to check.

  • index

    If the property is an array, this variable will be the index of the value in the array; otherwise, it will be null.

  • collection

    If the property is an array, this variable will be the actual java.util.List; otherwise, it will be null.

Examples

To ensure that the year of a certain date property is the current year, you could do something like:

1
new Date().getYear() == val.getYear()

To ensure that a number property is even, you could do:

1
val % 2 == 0

Output Expression

This is used by Gloop when objects are being written to flat files, XML, JSON, and YAML. This property is particularly useful for formatting Gloop object values, like formatting numbers such as 1234567 to $1,234,567 or formatting date objects to any format you like. If the property is an array, then Gloop will evaluate the expression for every value in the array. The Output Expression could be a simple expression that does something with the given value val, or the expression can return another variable for the given serialization type.

For example:

1
2
3
4
5
6
7
8
def expressions = [
    xml : val.toString().toLowerCase(),
    json : val.toString().toUpperCase(),
    csv : val.toString().trim(),
    txt : "Hello $val",
    xls : "Excel says $val"
    ]
return expressions[ type ]

Using the code above as the value of Output Expression, the value will be written to JSON as upper case, lower case for XML, trimmed for CSV files, prefixed with Hello for fixed-width flat file values, and prefixed with Excel says for Excel spreadsheets. Alternatively, the expression can ignore the type and be:

1
val.toString().toLowerCase()

This will then write the value as lower case for all output format types. When the expression is executed, Gloop will provide up to five variables:

  • gloopObject

    The actual Gloop object.

  • val

    This is the actual value to format.

  • index

    If the property is an array, this variable will be the index of the value in the array; otherwise, it will be null.

  • collection

    If the property is an array, this variable will be the actual java.util.List; otherwise, it will be null.

  • type

    This variable tells you what format the variable will be written to. The values are either txt (for fixed-width file output cursors), csv (for delimited file output cursors), xml, json, or yaml.

Call Groovy classes in your output expressions

Since Output Expressions are written in Groovy, you could place all of your output code in one place (a Groovy file), and invoke it from your Output Expression.

Namespace URI

Gloop uses this when converting Gloop objects to XML, by declaring namespaces when necessary.

Choices

This property can be used to make an object behave like an enum which restricts the values that this Gloop object will accept. Coder also uses this property when setting variables by displaying the list choices instead of a text area.

Coder showing set Gloop property choices

Coder showing set Gloop property choices

Allow Other Values

This tells Gloop whether the object will allow other values outside of the choices. If this is false and the value of the object is set to something that is not in the choices list, an Exception will be thrown. If this is true, Coder will display the choices when setting the value of the property but also display a text field which in case you want to set the value to something that isn't in the list of choices.

Coder showing set Gloop property choices with textbox for entering a different value

Coder showing set Gloop property choices with textbox for entering a different value

Coder Cloud doesn't display the text field used to enter a different value

In Coder Cloud v1.2, you cannot set a property to a value which is not included in the list of choices because in this version, Coder Cloud does not display the textbox. This issue was patched up in v1.3.

Minimum

This is the lowest value this object is allowed to have. At runtime, if the value of this object is less than the Minimum, an Exception will be thrown.

Maximum

This is the highest value this object is allowed to have. At runtime, if the value of this object is greater than the Maximum, an Exception will be thrown.

XML Attribute

This property tells Gloop whether to marshall this Gloop object as an XML attribute or not. When set to true, a small attribute badge appears on the top left corner of the object's icon in Coder.

Coder showing the `XML Attribute` badge

Coder showing the `XML Attribute` badge

Date Formats

If you set the value of a Gloop Date to an object that is an instance of java.lang.CharSequence, the Gloop Date will iterate through the list of Java DateFormat patterns until it finds one that it is able to parse it to a Date object.

XML Type

This property tells Gloop how to write the Date or String value when being written as XML.

For Dates, values of this property should be any of the following:

  • null
  • dateTime
  • date
  • duration
  • time
  • gYearMonth
  • gMonthDay
  • gYear
  • gMonth
  • gDay

For Strings, possible values are:

Allow Extra Properties

When this property is set to true, the Gloop model will allow new properties to be added to it at runtime. Many languages refer to classes like these as an Expando class.

Reference

This property is used when you would like a model to inherit properties from another model. In Gloop terms, this means that the model will reference another one (or extend, in Java terms). Having this populated with Allow Extra Properties set to false is the same as having a final Java class.

Object Class Name

Only Object types have this meta-property. This is the class name of the value that the Gloop Object will store. Use this when you want to store an object that none of the other Gloop object types are compatible with.

Minimum Length

Only String types have this meta-property. This property determines the minimum allowable length of a String value.

Maximum Length

Only String types have this meta-property. This property determines the maximum allowable length of a String value.


  1. A Gloop object whose type is Object as opposed to the general term Gloop object, in which the type is unspecified.