The basics of Gosu language
The Gosu language has basic data types and standard object types. You can also use Java types with the Gosu language.
Basic types in Gosu
Gosu works with the following Java primitive types to make sure it works with code that is already written in Java. You can get to the Java object versions (non-primitives) of the Java primitive types from Gosu. For instance, java.lang. Boolean is an object type that wraps the behavior of the boolean primitive. Primitive types are faster and take up less space than their object versions.
The table below shows the differences between primitive and object types.
Gosu things
The Java class java.lang is the root type for all object types in Gosu. Things. An object holds some data as variables and gives you properties and methods, which are functions that work on the object. Your code uses Object unless a type with the same name is in scope and needs to be disambiguated. This is because java.lang.Object is always in scope.
You can make classes that are based on the root object type Object. When you create a new class, it automatically extends the Object class unless you say that it should extend a different class.
You shouldn’t use the Object type to make objects directly. In some cases, you need to declare a variable with the type Object so that it can work with different types of objects. For instance, you can make a collection that has a variety of object types, all of which are subclasses of the root object type Object.
Creating an object in Gosu
A type is a set of things that are the same. The type system in Gosu lets you see types like classes and other things. A class is a group of methods and data about an object. To instantiate a class means to use the class definition to make a copy of the object in memory with its own data. Other code can change or get properties of the object. Other code can use methods on the object, which are functions that do things with that specific instance of the object.
Entity instances are special objects in PolicyCenter that are defined by the configuration files for the data model. PolicyCenter saves information in a database at certain points in the life cycle of an object.
You can use the Gosu new operator to make an instance from a class definition or another type that can be made into an instance.
Property assignment that causes intermediate objects to be created
If you try to set a property on a variable and that variable is null at run time, Gosu will throw a null pointer exception. But if you use property path syntax that has at least two objects to set a property, you can tell Gosu to automatically create an intermediate object in the path.
Let’s say the following things are true:
• You have two Gosu classes, AClass and BClass.
• The property B in the class AClass holds a reference to an instance of the class BClass.
• The Name property of the BClass class holds a String value. • The variable an in your code holds an instance of type AClass.
If a.B has a reference that isn’t null at run time, you can guess what the code below does:
Gosu first checks a.B, and then it sets the Name property of the result object to “John.”
If the AClass.B property allows for the creation of intermediate objects, the same code will work even if a.B is null at runtime.
If Gosu finds that a.B is null at run time:
1. Gosu makes a new instance of BClass.
2. Gosu sets a.B to the new instance.
3. Gosu sets the a.B.Name property on the new instance of BClass.
new java.util.ArrayList() // Create an instance of an ArrayList. new Integer[5] // Create an array of integers.
new LossCause[3] // Create an array of loss cause typecodes.
Properties that have a foreign key reference support automatic instantiation of intermediate objects for all types of Guidewire entities.
You can add the ability to create intermediate objects to any property in a Gosu class. Add the annotation on the line before the property declaration:

