You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.1 KiB
84 lines
2.1 KiB
5 years ago
|
/*
|
||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*/
|
||
|
package codetoanalyze.java.litho;
|
||
|
|
||
|
import com.facebook.litho.Component;
|
||
|
import com.facebook.litho.annotations.Prop;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
|
||
|
/** varArg test */
|
||
|
class VarArgPropComponent extends Component {
|
||
|
|
||
|
@Prop(varArg = "prop")
|
||
|
List<Object> props;
|
||
|
|
||
|
public Builder create() {
|
||
|
return new Builder();
|
||
|
}
|
||
|
|
||
|
static class Builder extends Component.Builder<Builder> {
|
||
|
|
||
|
VarArgPropComponent mVarArgPropComponent;
|
||
|
|
||
|
public Builder prop(Object prop) {
|
||
|
if (prop == null) {
|
||
|
return this;
|
||
|
}
|
||
|
if (this.mVarArgPropComponent.props == null) {
|
||
|
this.mVarArgPropComponent.props = new ArrayList<Object>();
|
||
|
}
|
||
|
this.mVarArgPropComponent.props.add(prop);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public Builder propAttr(Object prop) {
|
||
|
if (prop == null) {
|
||
|
return this;
|
||
|
}
|
||
|
if (this.mVarArgPropComponent.props == null) {
|
||
|
this.mVarArgPropComponent.props = new ArrayList<Object>();
|
||
|
}
|
||
|
this.mVarArgPropComponent.props.add(prop);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public Builder propsAttr(List<Object> props) {
|
||
|
if (props == null) {
|
||
|
return this;
|
||
|
}
|
||
|
if (this.mVarArgPropComponent.props == null || this.mVarArgPropComponent.props.isEmpty()) {
|
||
|
this.mVarArgPropComponent.props = props;
|
||
|
} else {
|
||
|
this.mVarArgPropComponent.props.addAll(props);
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public Builder props(List<Object> props) {
|
||
|
if (props == null) {
|
||
|
return this;
|
||
|
}
|
||
|
if (this.mVarArgPropComponent.props == null || this.mVarArgPropComponent.props.isEmpty()) {
|
||
|
this.mVarArgPropComponent.props = props;
|
||
|
} else {
|
||
|
this.mVarArgPropComponent.props.addAll(props);
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public VarArgPropComponent build() {
|
||
|
return mVarArgPropComponent;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public Builder getThis() {
|
||
|
return this;
|
||
|
}
|
||
|
}
|
||
|
}
|