-
Notifications
You must be signed in to change notification settings - Fork 8
Access Modes
Geoffrey Wiseman edited this page May 23, 2014
·
3 revisions
Access Modes allow you to control how properties are set, across an entire class, or for a particular property. There are two approaches: field access and method access. Field access attempts to write directly to the fields of the object, while method access uses setter methods.
In order to change the access mode for a class, annotate the class with @Access:
@Access(AccessMode.METHOD)
public class ClassWithSetters() {
}
On the other hand, if you simply want to tell moo to treat something as a property that doesn't match the access mode for the class, mark it with @Property:
public class FieldAccessible {
private Name name;
private String rank;
private Integer serialNumber;
@Property
public setFirstName( String name ) {
name.setFirstName( name );
}
@Property
public setLastName( String name ) {
name.setLastName( name );
}
}
Access mode is not currently inherited. If you have a type hierarchy, you may need to apply the configuration to super and sub classes.
Access modes were added in Moo v1.1.
- 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