@ -27,6 +27,14 @@ enum ResType {
boolean optional ( ) default false ;
boolean optional ( ) default false ;
}
}
@Target ( { ElementType . PARAMETER , ElementType . FIELD } )
@Retention ( RetentionPolicy . CLASS )
@interface TreeProp {
ResType resType ( ) default ResType . NONE ;
boolean optional ( ) default false ;
}
class MyComponent extends Component {
class MyComponent extends Component {
@Prop Object prop1 ; // implicitly non-optional
@Prop Object prop1 ; // implicitly non-optional
@ -66,6 +74,29 @@ class MyComponent extends Component {
}
}
}
}
class MyTreeComponent extends Component {
@TreeProp Object prop1 ; // implicitly non-optional
Object nonProp ;
public Builder create ( ) {
return new Builder ( ) ;
}
static class Builder extends Component . Builder {
MyTreeComponent mMyTreeComponent ;
public Builder prop1 ( Object o ) {
this . mMyTreeComponent . prop1 = o ;
return this ;
}
public MyTreeComponent build ( ) {
return mMyTreeComponent ;
}
}
}
/ * *
/ * *
* using @Prop ( resType = . . ) allows you to set the Prop with any of . propname , . propnameRes , or
* using @Prop ( resType = . . ) allows you to set the Prop with any of . propname , . propnameRes , or
* . propnameAttr
* . propnameAttr
@ -216,4 +247,13 @@ public class RequiredProps {
public void buildPropResMissingBad ( ) {
public void buildPropResMissingBad ( ) {
mResPropComponent . create ( ) . build ( ) ;
mResPropComponent . create ( ) . build ( ) ;
}
}
public class NonRequiredTreeProps {
public MyTreeComponent mMyTreeComponent ;
public MyTreeComponent buildWithoutOk ( ) {
return mMyTreeComponent . create ( ) . build ( ) ;
}
}
}
}