Implicit coercions removed

In 9.0, all implicit coercions are eliminated, as well many explicit coercions using the as keyword. Different coercions have different types of replacements. The application automatically upgrades these coercions in your Gosu code as specified in the following table. Unless otherwise specified in the rightmost column, both implicit and explicit coercions are prohibited.

Previous coercion from this type

Previous coercion to this type

Upgrader replaces implicit coercions with this new Gosu code

gw.pl.persistence.core.entity.KeyableBean

gw.pl.persistence.core.Key

value?.ID

entity.ENTITYNAME[]

entity.TQuery

value.asQuery()

String

typekey.TYPELIST

For String literals in which the programming context defines it clearly as a typecode, the replacement is the code literal on the typelist type.

For example, consider a variable declared as the typelist type typekey.ADDRESSTYPE. To assign the typekey code HOME:

  • In 8.0 it was valid to assign the value "HOME". At compile time, Gosu converted it to the full value AddressType.TC_HOME if the programming context was the type ADDRESSTYPE.
  • In 9.0, the new form is typekey.AddressType.TC_HOME or the more concise form TC_HOME.

For non-constant values, the upgrade tool converts the implicit coercion to typekey.TYPELIST.get(value).

String

EncryptedString

new EncryptedString(value)

String

org.apache.commons.lang.enums.Enum

Direct reference to the constant on the enumeration class.

Numeric value

gw.api.financials.CurrencyAmount

gw.api.upgrade.Coercions.makeCurrencyAmountFrom(value)

T[]

java.util.List<T>

value.toList()

T[]

java.util.Set<T>

value.toSet()

java.util.

Collection<T>

T[]

value.toTypedArray()

String

char[]

toCharArray()

String

String[]

new String[] { value }

Object

java.util.Date

gw.api.upgradeCoercions.makeDateFrom(value)

Object

String

Implicit coercion is replaced by an explicit cast: value as String

This is one of the few implicit coercions that can be replaced by an explicit coercion using the as keyword.

Object

java.lang.StringBuffer

new StringBuffer(value as String)

Object

java.lang.StringBuilder

new StringBuilder(value as String)

Numeric values

Numeric values

Replaced by method calls on the class gw.api.upgrade.Coercions. The method names have the form makeTYPEFrom. In some cases there are multiple methods for types that have Object and primitive versions. For example:

  • For java.lang.Integer, the method is makeIntFrom.
  • For the Gosu primitive int, the method name is makePIntFrom.

This is one of the few implicit coercions that can be replaced by an explicit coercion using the as keyword. However, the behavior of as is different in rare edge cases. Thus, the upgrade tool uses a safer but more verbose upgrade transformation.

PolicyCenter business data coercions

Previous coercion from this type

Previous coercion to this type

Upgrader replaces implicit coercions with this new Gosu code

String

T where T is option coverage term type

gw.api.upgrade.PCCoercions.

makeOptionCovTerm<T>(value)

T where T is package coverage term type

gw.api.upgrade.PCCoercions.

makePackageOptionCovTerm<T>(value)

T where T is product model type

gw.api.upgrade.PCCoercions.

makeProductModel<T>(value)