ExpandoMetaClass - Dynamic Method Names

ExpandoMetaClass - Dynamic method/property name cre=
ation

=20

Since Groovy allows you to use Strings as property names this in turns a=
llows you to dynamically create method and property names at runtime.

=
=20

The Basics

=20

To create a method with a dynamic name simply use Groovy's feature of re=
ference property names as strings. You can combine this with Groovy's strin=
g interpolation (Gstrings) to create method and property names on the fly:<=
/p>=20

So what we do with these classes is to evaluate the convention and add &=
quot;encodeAsXXX" methods to every object based on the first part of t=
he name of the codec class such as "encodeAsHTML". The pseudo cod=
e to achieve this is below: