-
Notifications
You must be signed in to change notification settings - Fork 8
Translating to Value Types
Normally, the destination of a translation would be another mutable object that Moo can create with a NoArgument Constructor (see Constructors) and then modify during the translation process.
This doesn't work with value types, which are typically simple and immutable.
Moo doesn't have full support for value types yet, but there was one kind of value type that seemed more important than the others, one whose value type translation has been built into the Java class hierarchy from Object
on down: java.lang.String
.
As of Moo v2.0, Moo can translate to String
types using the Object's own implementation of toString()
.
This has been implemented with a ValueTypeTranslator
interface and a StringValueTypeTranslator
implementation.
Using this is very simple: use a String as a destination, a non-string as the source and specify translate=true
@Property(translate=true)
String summary;
- Five Minute Introduction
- Getting Moo
- Translating Object Properties
- Translating Collection Properties
- Translating Map Properties
- Source Expressions
- Access Modes
- Translating to Value Types
- Extensions
- External Objects in Translation
- Ignoring Properties
- Updating Collections
- Translation Target Factories
- Nested Updates
- Optional and Required Properties
- Order of Property Translation
- Constructors
- Lookup on Update
- Caching
Releases
Background