-
Notifications
You must be signed in to change notification settings - Fork 9
External Objects in Translation
Geoffrey Wiseman edited this page May 23, 2014
·
4 revisions
Using external objects which are not part of the source or destination within a translation allows you to pull in outside data and logic that you may need for your translation. Some examples are available within the variables test and below:
Translate.to( ScoredContent.class ).withVariable( "scorer", new ContentScorer() ).from( userContent );
public static class ScoredContent {
@Translation("scorer.getScore(this)")
private int score;
private String title;
private Strimg body;
}
In this example, we expect to pull the title and body from the user content, but the score will come from an external object, the 'scorer', which is passed in to the translation as a named variable.
This capability was added in Moo v1.2. Between then and v2.0, when MVEL was part of the core of Moo, you could use this anywhere. As of Moo v2.0, this can only be used with moo-mvel, although it's possible that will be available with other extensions as well in the future.
- 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