index int64 0 0 | repo_id stringlengths 26 205 | file_path stringlengths 51 246 | content stringlengths 8 433k | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | Create_ds/epoxy/epoxy-processortest/src/test/resources/baseModelWithAttribute/ksp | Create_ds/epoxy/epoxy-processortest/src/test/resources/baseModelWithAttribute/ksp/actual/BaseModelViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class BaseModelViewModel_ extends TestBaseModel<BaseModelView> implements GeneratedModel<BaseModelView>, BaseModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(2);
private OnModelBoundListener<BaseModelViewModel_, BaseModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<BaseModelViewModel_, BaseModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<BaseModelViewModel_, BaseModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<BaseModelViewModel_, BaseModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
@NonNull
private String clickListener_String;
public BaseModelViewModel_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(0)) {
throw new IllegalStateException("A value is required for setClickListener");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final BaseModelView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final BaseModelView object) {
super.bind(object);
object.setClickListener(clickListener_String);
}
@Override
public void bind(final BaseModelView object, EpoxyModel previousModel) {
if (!(previousModel instanceof BaseModelViewModel_)) {
bind(object);
return;
}
BaseModelViewModel_ that = (BaseModelViewModel_) previousModel;
super.bind(object);
if ((clickListener_String != null ? !clickListener_String.equals(that.clickListener_String) : that.clickListener_String != null)) {
object.setClickListener(clickListener_String);
}
}
@Override
public void handlePostBind(final BaseModelView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public BaseModelViewModel_ onBind(
OnModelBoundListener<BaseModelViewModel_, BaseModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(BaseModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public BaseModelViewModel_ onUnbind(
OnModelUnboundListener<BaseModelViewModel_, BaseModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final BaseModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public BaseModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<BaseModelViewModel_, BaseModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final BaseModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public BaseModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<BaseModelViewModel_, BaseModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Required.</i>
*
* @see BaseModelView#setClickListener(String)
*/
public BaseModelViewModel_ clickListener(@NonNull String clickListener) {
if (clickListener == null) {
throw new IllegalArgumentException("clickListener cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(0);
onMutation();
this.clickListener_String = clickListener;
return this;
}
@NonNull
public String clickListener() {
return clickListener_String;
}
public BaseModelViewModel_ baseModelString(String baseModelString) {
onMutation();
super.baseModelString = baseModelString;
return this;
}
public String baseModelString() {
return baseModelString;
}
@Override
public BaseModelViewModel_ id(long p0) {
super.id(p0);
return this;
}
@Override
public BaseModelViewModel_ id(@Nullable Number... p0) {
super.id(p0);
return this;
}
@Override
public BaseModelViewModel_ id(long p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public BaseModelViewModel_ id(@Nullable CharSequence p0) {
super.id(p0);
return this;
}
@Override
public BaseModelViewModel_ id(@Nullable CharSequence p0, @Nullable CharSequence... p1) {
super.id(p0, p1);
return this;
}
@Override
public BaseModelViewModel_ id(@Nullable CharSequence p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public BaseModelViewModel_ layout(@LayoutRes int p0) {
super.layout(p0);
return this;
}
@Override
public BaseModelViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback p0) {
super.spanSizeOverride(p0);
return this;
}
@Override
public BaseModelViewModel_ show() {
super.show();
return this;
}
@Override
public BaseModelViewModel_ show(boolean p0) {
super.show(p0);
return this;
}
@Override
public BaseModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public BaseModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.clickListener_String = null;
super.baseModelString = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof BaseModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
BaseModelViewModel_ that = (BaseModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((clickListener_String != null ? !clickListener_String.equals(that.clickListener_String) : that.clickListener_String != null)) {
return false;
}
if ((baseModelString != null ? !baseModelString.equals(that.baseModelString) : that.baseModelString != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (clickListener_String != null ? clickListener_String.hashCode() : 0);
_result = 31 * _result + (baseModelString != null ? baseModelString.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "BaseModelViewModel_{" +
"clickListener_String=" + clickListener_String +
", baseModelString=" + baseModelString +
"}" + super.toString();
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,800 |
0 | Create_ds/epoxy/epoxy-processortest/src/test/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-processortest/src/test/java/com/airbnb/epoxy/testpackage/DifferentPackageTest.java | package com.airbnb.epoxy.testpackage;
import org.junit.Test;
import com.airbnb.integrationtest.processortest.differentpackage.Model_;
/**
* A test to check that a model subclass in a different package from its super class does not
* include package private fields from its super class on its generated model.
* <p>
* This also tests that model superclasses in different modules have their attributes included in
* the generated class too.
*/
public class DifferentPackageTest {
@Test
public void differentPackageUsage() {
new Model_()
.subclassValue(1)
// Attributes from super class in same module, different package.
.publicValue(1)
.protectedValue(1)
// Inherited attributes from a subclass in a different module
.processorTest2ValueProtected(3)
.processorTest2ValuePublic(3);
}
}
| 8,801 |
0 | Create_ds/epoxy/epoxy-processortest/src/main/java/com/airbnb/integrationtest | Create_ds/epoxy/epoxy-processortest/src/main/java/com/airbnb/integrationtest/processortest/ProcessorTestModel.java | package com.airbnb.integrationtest.processortest;
import android.view.View;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.processortest2.ProcessorTest2Model;
public class ProcessorTestModel extends ProcessorTest2Model<View> {
@EpoxyAttribute public int publicValue;
@EpoxyAttribute protected int protectedValue;
@EpoxyAttribute int packagePrivateValue;
@Override
protected int getDefaultLayout() {
return 0;
}
}
| 8,802 |
0 | Create_ds/epoxy/epoxy-processortest/src/main/java/com/airbnb/integrationtest/processortest | Create_ds/epoxy/epoxy-processortest/src/main/java/com/airbnb/integrationtest/processortest/differentpackage/Model.java | package com.airbnb.integrationtest.processortest.differentpackage;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.integrationtest.processortest.ProcessorTestModel;
public class Model extends ProcessorTestModel {
@EpoxyAttribute int subclassValue;
}
| 8,803 |
0 | Create_ds/epoxy/epoxy-databinding/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-databinding/src/main/java/com/airbnb/epoxy/DataBindingEpoxyModel.java | package com.airbnb.epoxy;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import com.airbnb.epoxy.DataBindingEpoxyModel.DataBindingHolder;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
/**
* A version of {@link com.airbnb.epoxy.EpoxyModel} that can be used with databinding. The layout
* resource used with this model must be a databinding layout. This class will create the
* databinding object from the layout and call the {@link #setDataBindingVariables} methods when the
* view needs binding to the model.
* <p>
* The easiest way to use this model is to have Epoxy generate a model to do all the binding work
* for you. To do this, create an abstract subclass of this model, annotate it with {@link
* EpoxyModelClass}, and pass your layout resource as the layout param. (You must pass the layout
* this way instead of implementing {@link #getDefaultLayout()}).
* <p>
* Then, make a field to represent each of the data variables in your layout and annotate each one
* with {@link EpoxyAttribute}. The name of each field must match the name of the variable in the
* layout exactly.
* <p>
* Epoxy will generate a subclass of your model at compile time that implements {@link
* #setDataBindingVariables(ViewDataBinding)} and {@link #setDataBindingVariables(ViewDataBinding,
* EpoxyModel)} for you. This will do all binding for you, and also only bind variables that change
* if you update your model (Note: The change optimization only works when used with {@link
* EpoxyController}).
*/
public abstract class DataBindingEpoxyModel extends EpoxyModelWithHolder<DataBindingHolder> {
@Override
public View buildView(@NonNull ViewGroup parent) {
LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
ViewDataBinding binding = DataBindingUtil.inflate(layoutInflater, getViewType(), parent, false);
View view = binding.getRoot();
view.setTag(binding);
return view;
}
@Override
public void bind(@NonNull DataBindingHolder holder) {
setDataBindingVariables(holder.dataBinding);
holder.dataBinding.executePendingBindings();
}
@Override
public void bind(@NonNull DataBindingHolder holder, @NonNull EpoxyModel<?> previouslyBoundModel) {
setDataBindingVariables(holder.dataBinding, previouslyBoundModel);
holder.dataBinding.executePendingBindings();
}
@Override
public void bind(@NonNull DataBindingHolder holder, @NonNull List<Object> payloads) {
setDataBindingVariables(holder.dataBinding, payloads);
holder.dataBinding.executePendingBindings();
}
/**
* This is called when the model is bound to a view, and the view's variables should be updated
* with the model's data. {@link ViewDataBinding#executePendingBindings()} is called for you after
* this method is run.
* <p>
* If you leave your class abstract and have a model generated for you via annotations this will
* be implemented for you. However, you may choose to implement this manually if you like.
*/
protected abstract void setDataBindingVariables(ViewDataBinding binding);
/**
* Similar to {@link #setDataBindingVariables(ViewDataBinding)}, but this method only binds
* variables that have changed. The changed model comes from {@link #bind(DataBindingHolder,
* EpoxyModel)}. This will only be called if the model is used in an {@link EpoxyController}
* <p>
* If you leave your class abstract and have a model generated for you via annotations this will
* be implemented for you. However, you may choose to implement this manually if you like.
*/
protected void setDataBindingVariables(ViewDataBinding dataBinding,
EpoxyModel<?> previouslyBoundModel) {
setDataBindingVariables(dataBinding);
}
protected void setDataBindingVariables(ViewDataBinding dataBinding, List<Object> payloads) {
setDataBindingVariables(dataBinding);
}
@Override
public void unbind(@NonNull DataBindingHolder holder) {
holder.dataBinding.unbind();
}
@Override
protected final DataBindingHolder createNewHolder(@NonNull ViewParent parent) {
return new DataBindingHolder();
}
public static class DataBindingHolder extends EpoxyHolder {
private ViewDataBinding dataBinding;
public ViewDataBinding getDataBinding() {
return dataBinding;
}
@Override
protected void bindView(@NonNull View itemView) {
dataBinding = (ViewDataBinding) itemView.getTag();
}
}
}
| 8,804 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ModelFactoryBasicModelWithAttribute.java | package com.airbnb.epoxy;
public class ModelFactoryBasicModelWithAttribute extends EpoxyModel<Object> {
@EpoxyAttribute int value;
@Override
protected int getDefaultLayout() {
return 0;
}
} | 8,805 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/GroupPropSingleSupportedAttributeModelViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class GroupPropSingleSupportedAttributeModelViewModel_ extends EpoxyModel<GroupPropSingleSupportedAttributeModelView> implements GeneratedModel<GroupPropSingleSupportedAttributeModelView>, GroupPropSingleSupportedAttributeModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(2);
private OnModelBoundListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
@NonNull
private String title_String;
/**
* Bitset index: 1
*/
@NonNull
private Object title_Object;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(0) && !assignedAttributes_epoxyGeneratedModel.get(1)) {
throw new IllegalStateException("A value is required for setTitle");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder,
final GroupPropSingleSupportedAttributeModelView object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final GroupPropSingleSupportedAttributeModelView object) {
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
object.setTitle(title_String);
}
else {
object.setTitle(title_Object);
}
}
@Override
public void bind(final GroupPropSingleSupportedAttributeModelView object,
EpoxyModel previousModel) {
if (!(previousModel instanceof GroupPropSingleSupportedAttributeModelViewModel_)) {
bind(object);
return;
}
GroupPropSingleSupportedAttributeModelViewModel_ that = (GroupPropSingleSupportedAttributeModelViewModel_) previousModel;
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(0) || (title_String != null ? !title_String.equals(that.title_String) : that.title_String != null)) {
object.setTitle(title_String);
}
}
else if (assignedAttributes_epoxyGeneratedModel.get(1)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(1) || (title_Object != null ? !title_Object.equals(that.title_Object) : that.title_Object != null)) {
object.setTitle(title_Object);
}
}
}
@Override
public void handlePostBind(final GroupPropSingleSupportedAttributeModelView object,
int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GroupPropSingleSupportedAttributeModelViewModel_ onBind(
OnModelBoundListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(GroupPropSingleSupportedAttributeModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GroupPropSingleSupportedAttributeModelViewModel_ onUnbind(
OnModelUnboundListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState,
final GroupPropSingleSupportedAttributeModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GroupPropSingleSupportedAttributeModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth,
final GroupPropSingleSupportedAttributeModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GroupPropSingleSupportedAttributeModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Required.</i>
*
* @see GroupPropSingleSupportedAttributeModelView#setTitle(String)
*/
public GroupPropSingleSupportedAttributeModelViewModel_ title(@NonNull String title) {
if (title == null) {
throw new IllegalArgumentException("title cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(0);
assignedAttributes_epoxyGeneratedModel.clear(1);
this.title_Object = null;
onMutation();
this.title_String = title;
return this;
}
@NonNull
public String titleString() {
return title_String;
}
/**
* <i>Required.</i>
*
* @see GroupPropSingleSupportedAttributeModelView#setTitle(Object)
*/
public GroupPropSingleSupportedAttributeModelViewModel_ title(@NonNull Object title) {
if (title == null) {
throw new IllegalArgumentException("title cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(1);
assignedAttributes_epoxyGeneratedModel.clear(0);
this.title_String = null;
onMutation();
this.title_Object = title;
return this;
}
@NonNull
public Object titleObject() {
return title_Object;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ show() {
super.show();
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.title_String = null;
this.title_Object = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof GroupPropSingleSupportedAttributeModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
GroupPropSingleSupportedAttributeModelViewModel_ that = (GroupPropSingleSupportedAttributeModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((title_String != null ? !title_String.equals(that.title_String) : that.title_String != null)) {
return false;
}
if ((title_Object != null ? !title_Object.equals(that.title_Object) : that.title_Object != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (title_String != null ? title_String.hashCode() : 0);
_result = 31 * _result + (title_Object != null ? title_Object.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "GroupPropSingleSupportedAttributeModelViewModel_{" +
"title_String=" + title_String +
", title_Object=" + title_Object +
"}" + super.toString();
}
public static GroupPropSingleSupportedAttributeModelViewModel_ from(ModelProperties properties) {
GroupPropSingleSupportedAttributeModelViewModel_ model = new GroupPropSingleSupportedAttributeModelViewModel_();
model.id(properties.getId());
if (properties.has("title")) {
model.title(properties.getString("title"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,806 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/BasicModelWithFinalAttribute.java | package com.airbnb.epoxy;
public class BasicModelWithFinalAttribute extends EpoxyModel<Object> {
@EpoxyAttribute final int value;
public BasicModelWithFinalAttribute() {
value = 0;
}
@Override
protected int getDefaultLayout() {
return 0;
}
} | 8,807 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ModelFactoryBaseModelView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.widget.FrameLayout;
@ModelView(defaultLayout = 1)
public class ModelFactoryBaseModelView extends FrameLayout {
public ModelFactoryBaseModelView(Context context) {
super(context);
}
@ModelProp
public void setTitle(String title) {
}
} | 8,808 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/StyleableModelView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.widget.FrameLayout;
import com.airbnb.paris.annotations.Styleable;
@Styleable
@ModelView
public class StyleableModelView extends FrameLayout {
public StyleableModelView(Context context) {
super(context);
}
@ModelProp
public void setTitle(String title) {
}
} | 8,809 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ extends EpoxyModel<GroupPropMultipleSupportedAttributeDifferentNameModelView> implements GeneratedModel<GroupPropMultipleSupportedAttributeDifferentNameModelView>, GroupPropMultipleSupportedAttributeDifferentNameModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(2);
private OnModelBoundListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
@NonNull
private String titleString_String;
/**
* Bitset index: 1
*/
private int titleInt_Int = 0;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder,
final GroupPropMultipleSupportedAttributeDifferentNameModelView object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final GroupPropMultipleSupportedAttributeDifferentNameModelView object) {
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
object.setTitleString(titleString_String);
}
else if (assignedAttributes_epoxyGeneratedModel.get(1)) {
object.setTitleInt(titleInt_Int);
}
else {
object.setTitleInt(titleInt_Int);
}
}
@Override
public void bind(final GroupPropMultipleSupportedAttributeDifferentNameModelView object,
EpoxyModel previousModel) {
if (!(previousModel instanceof GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_)) {
bind(object);
return;
}
GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ that = (GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_) previousModel;
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(0) || (titleString_String != null ? !titleString_String.equals(that.titleString_String) : that.titleString_String != null)) {
object.setTitleString(titleString_String);
}
}
else if (assignedAttributes_epoxyGeneratedModel.get(1)) {
if ((titleInt_Int != that.titleInt_Int)) {
object.setTitleInt(titleInt_Int);
}
}
// A value was not set so we should use the default value, but we only need to set it if the previous model had a custom value set.
else if (that.assignedAttributes_epoxyGeneratedModel.get(0) || that.assignedAttributes_epoxyGeneratedModel.get(1)) {
object.setTitleInt(titleInt_Int);
}
}
@Override
public void handlePostBind(final GroupPropMultipleSupportedAttributeDifferentNameModelView object,
int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onBind(
OnModelBoundListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(GroupPropMultipleSupportedAttributeDifferentNameModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onUnbind(
OnModelUnboundListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState,
final GroupPropMultipleSupportedAttributeDifferentNameModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth,
final GroupPropMultipleSupportedAttributeDifferentNameModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Required.</i>
*
* @see GroupPropMultipleSupportedAttributeDifferentNameModelView#setTitleString(String)
*/
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ titleString(
@NonNull String titleString) {
if (titleString == null) {
throw new IllegalArgumentException("titleString cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(0);
assignedAttributes_epoxyGeneratedModel.clear(1);
this.titleInt_Int = 0;
onMutation();
this.titleString_String = titleString;
return this;
}
@NonNull
public String titleStringString() {
return titleString_String;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see GroupPropMultipleSupportedAttributeDifferentNameModelView#setTitleInt(int)
*/
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ titleInt(int titleInt) {
assignedAttributes_epoxyGeneratedModel.set(1);
assignedAttributes_epoxyGeneratedModel.clear(0);
this.titleString_String = null;
onMutation();
this.titleInt_Int = titleInt;
return this;
}
public int titleIntInt() {
return titleInt_Int;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(
@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(
@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(
@Nullable CharSequence key, @Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(
@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ layout(
@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ show() {
super.show();
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.titleString_String = null;
this.titleInt_Int = 0;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ that = (GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((titleString_String != null ? !titleString_String.equals(that.titleString_String) : that.titleString_String != null)) {
return false;
}
if ((titleInt_Int != that.titleInt_Int)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (titleString_String != null ? titleString_String.hashCode() : 0);
_result = 31 * _result + titleInt_Int;
return _result;
}
@Override
public String toString() {
return "GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_{" +
"titleString_String=" + titleString_String +
", titleInt_Int=" + titleInt_Int +
"}" + super.toString();
}
public static GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ from(
ModelProperties properties) {
GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ model = new GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_();
model.id(properties.getId());
if (properties.has("titleString")) {
model.titleString(properties.getString("titleString"));
} else if (properties.has("titleInt")) {
model.titleInt(properties.getInt("titleInt"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,810 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/AllTypesModelView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.widget.FrameLayout;
import androidx.annotation.DrawableRes;
import androidx.annotation.RawRes;
import com.airbnb.epoxy.ModelProp.Option;
import java.util.List;
@ModelView(defaultLayout = 1)
public class AllTypesModelView extends FrameLayout {
public AllTypesModelView(Context context) {
super(context);
}
@ModelProp
public void setBooleanValue(boolean value) {
}
@ModelProp
public void setBoxedBooleanValue(Boolean value) {
}
@ModelProp
public void setCharSequenceValue(CharSequence value) {
}
@ModelProp
public void setBoxedDoubleValue(Double value) {
}
@ModelProp
public void setDoubleValue(double value) {
}
@ModelProp
public void setDrawableRes(@DrawableRes int value) {
}
@ModelProp
public void setEpoxyModelList(List<? extends EpoxyModel<?>> value) {
}
@ModelProp
public void setIntValue(int value) {
}
@ModelProp
public void setBoxedIntValue(Integer value) {
}
@ModelProp
public void setLongValue(long value) {
}
@ModelProp
public void setBoxedLongValue(Long value) {
}
@ModelProp({ Option.DoNotHash })
public void setOnClickListener(OnClickListener value) {
}
@ModelProp
public void setRawRes(@RawRes int value) {
}
@ModelProp
public void setStringValue(String value) {
}
@ModelProp
public void setStringList(List<String> value) {
}
}
| 8,811 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ListSubtypeModelViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.ArrayList;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class ListSubtypeModelViewModel_ extends EpoxyModel<ListSubtypeModelView> implements GeneratedModel<ListSubtypeModelView>, ListSubtypeModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(1);
private OnModelBoundListener<ListSubtypeModelViewModel_, ListSubtypeModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ListSubtypeModelViewModel_, ListSubtypeModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ListSubtypeModelViewModel_, ListSubtypeModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ListSubtypeModelViewModel_, ListSubtypeModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
@NonNull
private ArrayList<String> stringArrayList_ArrayList;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(0)) {
throw new IllegalStateException("A value is required for setStringArrayList");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final ListSubtypeModelView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final ListSubtypeModelView object) {
super.bind(object);
object.setStringArrayList(stringArrayList_ArrayList);
}
@Override
public void bind(final ListSubtypeModelView object, EpoxyModel previousModel) {
if (!(previousModel instanceof ListSubtypeModelViewModel_)) {
bind(object);
return;
}
ListSubtypeModelViewModel_ that = (ListSubtypeModelViewModel_) previousModel;
super.bind(object);
if ((stringArrayList_ArrayList != null ? !stringArrayList_ArrayList.equals(that.stringArrayList_ArrayList) : that.stringArrayList_ArrayList != null)) {
object.setStringArrayList(stringArrayList_ArrayList);
}
}
@Override
public void handlePostBind(final ListSubtypeModelView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ListSubtypeModelViewModel_ onBind(
OnModelBoundListener<ListSubtypeModelViewModel_, ListSubtypeModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(ListSubtypeModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ListSubtypeModelViewModel_ onUnbind(
OnModelUnboundListener<ListSubtypeModelViewModel_, ListSubtypeModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final ListSubtypeModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ListSubtypeModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ListSubtypeModelViewModel_, ListSubtypeModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final ListSubtypeModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ListSubtypeModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<ListSubtypeModelViewModel_, ListSubtypeModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Required.</i>
*
* @see ListSubtypeModelView#setStringArrayList(ArrayList<String>)
*/
public ListSubtypeModelViewModel_ stringArrayList(@NonNull ArrayList<String> stringArrayList) {
if (stringArrayList == null) {
throw new IllegalArgumentException("stringArrayList cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(0);
onMutation();
this.stringArrayList_ArrayList = stringArrayList;
return this;
}
@NonNull
public ArrayList<String> stringArrayList() {
return stringArrayList_ArrayList;
}
@Override
public ListSubtypeModelViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public ListSubtypeModelViewModel_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ListSubtypeModelViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ListSubtypeModelViewModel_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ListSubtypeModelViewModel_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ListSubtypeModelViewModel_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ListSubtypeModelViewModel_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ListSubtypeModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ListSubtypeModelViewModel_ show() {
super.show();
return this;
}
@Override
public ListSubtypeModelViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ListSubtypeModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public ListSubtypeModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.stringArrayList_ArrayList = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ListSubtypeModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ListSubtypeModelViewModel_ that = (ListSubtypeModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((stringArrayList_ArrayList != null ? !stringArrayList_ArrayList.equals(that.stringArrayList_ArrayList) : that.stringArrayList_ArrayList != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (stringArrayList_ArrayList != null ? stringArrayList_ArrayList.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ListSubtypeModelViewModel_{" +
"stringArrayList_ArrayList=" + stringArrayList_ArrayList +
"}" + super.toString();
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,812 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/TextPropModelView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.widget.FrameLayout;
@ModelView(defaultLayout = 1)
public class TextPropModelView extends FrameLayout {
public TextPropModelView(Context context) {
super(context);
}
@TextProp
public void setTitle(CharSequence title) {
}
} | 8,813 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ModelFactoryBasicModelWithAttribute_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class ModelFactoryBasicModelWithAttribute_ extends ModelFactoryBasicModelWithAttribute implements GeneratedModel<Object>, ModelFactoryBasicModelWithAttributeBuilder {
private OnModelBoundListener<ModelFactoryBasicModelWithAttribute_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelFactoryBasicModelWithAttribute_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelFactoryBasicModelWithAttribute_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelFactoryBasicModelWithAttribute_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelFactoryBasicModelWithAttribute_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelFactoryBasicModelWithAttribute_ onBind(
OnModelBoundListener<ModelFactoryBasicModelWithAttribute_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelFactoryBasicModelWithAttribute_ onUnbind(
OnModelUnboundListener<ModelFactoryBasicModelWithAttribute_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelFactoryBasicModelWithAttribute_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelFactoryBasicModelWithAttribute_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelFactoryBasicModelWithAttribute_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelFactoryBasicModelWithAttribute_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public ModelFactoryBasicModelWithAttribute_ value(int value) {
onMutation();
super.value = value;
return this;
}
public int value() {
return value;
}
@Override
public ModelFactoryBasicModelWithAttribute_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ show() {
super.show();
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ hide() {
super.hide();
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.value = 0;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelFactoryBasicModelWithAttribute_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelFactoryBasicModelWithAttribute_ that = (ModelFactoryBasicModelWithAttribute_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((value != that.value)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + value;
return _result;
}
@Override
public String toString() {
return "ModelFactoryBasicModelWithAttribute_{" +
"value=" + value +
"}" + super.toString();
}
public static ModelFactoryBasicModelWithAttribute_ from(ModelProperties properties) {
ModelFactoryBasicModelWithAttribute_ model = new ModelFactoryBasicModelWithAttribute_();
model.id(properties.getId());
if (properties.has("value")) {
model.value(properties.getInt("value"));
}
return model;
}
}
| 8,814 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/BasicModelWithFinalAttribute_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class BasicModelWithFinalAttribute_ extends BasicModelWithFinalAttribute implements GeneratedModel<Object>, BasicModelWithFinalAttributeBuilder {
private OnModelBoundListener<BasicModelWithFinalAttribute_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<BasicModelWithFinalAttribute_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<BasicModelWithFinalAttribute_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<BasicModelWithFinalAttribute_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public BasicModelWithFinalAttribute_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public BasicModelWithFinalAttribute_ onBind(
OnModelBoundListener<BasicModelWithFinalAttribute_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public BasicModelWithFinalAttribute_ onUnbind(
OnModelUnboundListener<BasicModelWithFinalAttribute_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public BasicModelWithFinalAttribute_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<BasicModelWithFinalAttribute_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public BasicModelWithFinalAttribute_ onVisibilityChanged(
OnModelVisibilityChangedListener<BasicModelWithFinalAttribute_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public int value() {
return value;
}
@Override
public BasicModelWithFinalAttribute_ id(long id) {
super.id(id);
return this;
}
@Override
public BasicModelWithFinalAttribute_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public BasicModelWithFinalAttribute_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public BasicModelWithFinalAttribute_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public BasicModelWithFinalAttribute_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public BasicModelWithFinalAttribute_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public BasicModelWithFinalAttribute_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public BasicModelWithFinalAttribute_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public BasicModelWithFinalAttribute_ show() {
super.show();
return this;
}
@Override
public BasicModelWithFinalAttribute_ show(boolean show) {
super.show(show);
return this;
}
@Override
public BasicModelWithFinalAttribute_ hide() {
super.hide();
return this;
}
@Override
public BasicModelWithFinalAttribute_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof BasicModelWithFinalAttribute_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
BasicModelWithFinalAttribute_ that = (BasicModelWithFinalAttribute_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((value != that.value)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + value;
return _result;
}
@Override
public String toString() {
return "BasicModelWithFinalAttribute_{" +
"value=" + value +
"}" + super.toString();
}
}
| 8,815 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/GroupPropMultipleSupportedAttributeDifferentNameModelView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.widget.FrameLayout;
import com.airbnb.epoxy.ModelProp.Option;
@ModelView(defaultLayout = 1)
public class GroupPropMultipleSupportedAttributeDifferentNameModelView extends FrameLayout {
public GroupPropMultipleSupportedAttributeDifferentNameModelView(Context context) {
super(context);
}
@ModelProp(group = "title")
public void setTitleString(String title) {
}
@ModelProp(group = "title")
public void setTitleInt(int title) {
}
} | 8,816 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/GroupPropMultipleSupportedAttributeSameNameModelView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.widget.FrameLayout;
import com.airbnb.epoxy.ModelProp.Option;
@ModelView(defaultLayout = 1)
public class GroupPropMultipleSupportedAttributeSameNameModelView extends FrameLayout {
public GroupPropMultipleSupportedAttributeSameNameModelView(Context context) {
super(context);
}
@ModelProp(group = "title")
public void setTitleString(String title) {
}
@ModelProp(group = "title")
public void setTitleInt(int title) {
}
} | 8,817 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/StyleableModelViewModel_.java | package com.airbnb.epoxy;
import android.os.AsyncTask;
import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.airbnb.paris.StyleApplierUtils;
import com.airbnb.paris.styles.Style;
import com.airbnb.viewmodeladapter.R;
import java.lang.AssertionError;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.Runnable;
import java.lang.String;
import java.lang.UnsupportedOperationException;
import java.lang.ref.WeakReference;
import java.util.BitSet;
import java.util.Objects;
/**
* Generated file. Do not modify! */
public class StyleableModelViewModel_ extends EpoxyModel<StyleableModelView> implements GeneratedModel<StyleableModelView>, StyleableModelViewModelBuilder {
private static final Style DEFAULT_PARIS_STYLE = new StyleableModelViewStyleApplier.StyleBuilder().addDefault().build();
private static WeakReference<Style> parisStyleReference_default;
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(2);
private OnModelBoundListener<StyleableModelViewModel_, StyleableModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<StyleableModelViewModel_, StyleableModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<StyleableModelViewModel_, StyleableModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<StyleableModelViewModel_, StyleableModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0 */
@NonNull
private String title_String;
/**
* Bitset index: 1 */
private Style style = DEFAULT_PARIS_STYLE;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(0)) {
throw new IllegalStateException("A value is required for setTitle");
}
}
@Override
protected int getViewType() {
return 0;
}
@Override
public StyleableModelView buildView(ViewGroup parent) {
StyleableModelView v = new StyleableModelView(parent.getContext());
v.setLayoutParams(new ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams.WRAP_CONTENT, ViewGroup.MarginLayoutParams.WRAP_CONTENT));
return v;
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final StyleableModelView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
if (!Objects.equals(style, object.getTag(R.id.epoxy_saved_view_style))) {
AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() {
public void run() {
try {
StyleApplierUtils.Companion.assertSameAttributes(new StyleableModelViewStyleApplier(object), style, DEFAULT_PARIS_STYLE);
}
catch(AssertionError e) {
throw new IllegalStateException("StyleableModelViewModel_ model at position " + position + " has an invalid style:\n\n" + e.getMessage());
}
}
} );
}
}
@Override
public void bind(final StyleableModelView object) {
if (!Objects.equals(style, object.getTag(R.id.epoxy_saved_view_style))) {
StyleableModelViewStyleApplier styleApplier = new StyleableModelViewStyleApplier(object);
styleApplier.apply(style);
object.setTag(R.id.epoxy_saved_view_style, style);
}
super.bind(object);
object.setTitle(title_String);
}
@Override
public void bind(final StyleableModelView object, EpoxyModel previousModel) {
if (!(previousModel instanceof StyleableModelViewModel_)) {
bind(object);
return;
}
StyleableModelViewModel_ that = (StyleableModelViewModel_) previousModel;
if (!Objects.equals(style, that.style)) {
StyleableModelViewStyleApplier styleApplier = new StyleableModelViewStyleApplier(object);
styleApplier.apply(style);
object.setTag(R.id.epoxy_saved_view_style, style);
}
super.bind(object);
if ((title_String != null ? !title_String.equals(that.title_String) : that.title_String != null)) {
object.setTitle(title_String);
}
}
@Override
public void handlePostBind(final StyleableModelView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()} */
public StyleableModelViewModel_ onBind(
OnModelBoundListener<StyleableModelViewModel_, StyleableModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(StyleableModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()} */
public StyleableModelViewModel_ onUnbind(
OnModelUnboundListener<StyleableModelViewModel_, StyleableModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final StyleableModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()} */
public StyleableModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<StyleableModelViewModel_, StyleableModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final StyleableModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()} */
public StyleableModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<StyleableModelViewModel_, StyleableModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public StyleableModelViewModel_ style(Style style) {
assignedAttributes_epoxyGeneratedModel.set(1);
onMutation();
this.style = style;
return this;
}
public StyleableModelViewModel_ styleBuilder(
StyleBuilderCallback<StyleableModelViewStyleApplier.StyleBuilder> builderCallback) {
StyleableModelViewStyleApplier.StyleBuilder builder = new StyleableModelViewStyleApplier.StyleBuilder();
builderCallback.buildStyle(builder.addDefault());
return style(builder.build());
}
/**
* Empty style */
public StyleableModelViewModel_ withDefaultStyle() {
Style style = parisStyleReference_default != null ? parisStyleReference_default.get() : null;
if (style == null) {
style = new StyleableModelViewStyleApplier.StyleBuilder().addDefault().build();
parisStyleReference_default = new WeakReference<>(style);
}
return style(style);
}
/**
* <i>Required.</i>
*
* @see StyleableModelView#setTitle(String)
*/
public StyleableModelViewModel_ title(@NonNull String title) {
if (title == null) {
throw new IllegalArgumentException("title cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(0);
onMutation();
this.title_String = title;
return this;
}
@NonNull
public String title() {
return title_String;
}
@Override
public StyleableModelViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public StyleableModelViewModel_ id(@Nullable Number... arg0) {
super.id(arg0);
return this;
}
@Override
public StyleableModelViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public StyleableModelViewModel_ id(@Nullable CharSequence arg0) {
super.id(arg0);
return this;
}
@Override
public StyleableModelViewModel_ id(@Nullable CharSequence arg0, @Nullable CharSequence... arg1) {
super.id(arg0, arg1);
return this;
}
@Override
public StyleableModelViewModel_ id(@Nullable CharSequence arg0, long arg1) {
super.id(arg0, arg1);
return this;
}
@Override
public StyleableModelViewModel_ layout(@LayoutRes int arg0) {
throw new UnsupportedOperationException("Layout resources are unsupported with programmatic views.");
}
@Override
public StyleableModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) {
super.spanSizeOverride(arg0);
return this;
}
@Override
public StyleableModelViewModel_ show() {
super.show();
return this;
}
@Override
public StyleableModelViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public StyleableModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
throw new UnsupportedOperationException("Layout resources are unsupported for views created programmatically.");
}
@Override
public StyleableModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.title_String = null;
this.style = DEFAULT_PARIS_STYLE;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof StyleableModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
StyleableModelViewModel_ that = (StyleableModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((title_String != null ? !title_String.equals(that.title_String) : that.title_String != null)) {
return false;
}
if ((style != null ? !style.equals(that.style) : that.style != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
result = 31 * result + (title_String != null ? title_String.hashCode() : 0);
result = 31 * result + (style != null ? style.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "StyleableModelViewModel_{" +
"title_String=" + title_String +
", style=" + style +
"}" + super.toString();
}
public static StyleableModelViewModel_ from(ModelProperties properties) {
StyleableModelViewModel_ model = new StyleableModelViewModel_();
model.id(properties.getId());
if (properties.has("title")) {
model.title(properties.getString("title"));
}
Style style = properties.getStyle();
if (style != null) {
model.style(style);
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,818 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ModelFactoryBaseModelViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class ModelFactoryBaseModelViewModel_ extends EpoxyModel<ModelFactoryBaseModelView> implements GeneratedModel<ModelFactoryBaseModelView>, ModelFactoryBaseModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(1);
private OnModelBoundListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
@NonNull
private String title_String;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(0)) {
throw new IllegalStateException("A value is required for setTitle");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final ModelFactoryBaseModelView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final ModelFactoryBaseModelView object) {
super.bind(object);
object.setTitle(title_String);
}
@Override
public void bind(final ModelFactoryBaseModelView object, EpoxyModel previousModel) {
if (!(previousModel instanceof ModelFactoryBaseModelViewModel_)) {
bind(object);
return;
}
ModelFactoryBaseModelViewModel_ that = (ModelFactoryBaseModelViewModel_) previousModel;
super.bind(object);
if ((title_String != null ? !title_String.equals(that.title_String) : that.title_String != null)) {
object.setTitle(title_String);
}
}
@Override
public void handlePostBind(final ModelFactoryBaseModelView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelFactoryBaseModelViewModel_ onBind(
OnModelBoundListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(ModelFactoryBaseModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelFactoryBaseModelViewModel_ onUnbind(
OnModelUnboundListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState,
final ModelFactoryBaseModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelFactoryBaseModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final ModelFactoryBaseModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelFactoryBaseModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Required.</i>
*
* @see ModelFactoryBaseModelView#setTitle(String)
*/
public ModelFactoryBaseModelViewModel_ title(@NonNull String title) {
if (title == null) {
throw new IllegalArgumentException("title cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(0);
onMutation();
this.title_String = title;
return this;
}
@NonNull
public String title() {
return title_String;
}
@Override
public ModelFactoryBaseModelViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ show() {
super.show();
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public ModelFactoryBaseModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.title_String = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelFactoryBaseModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelFactoryBaseModelViewModel_ that = (ModelFactoryBaseModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((title_String != null ? !title_String.equals(that.title_String) : that.title_String != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (title_String != null ? title_String.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ModelFactoryBaseModelViewModel_{" +
"title_String=" + title_String +
"}" + super.toString();
}
public static ModelFactoryBaseModelViewModel_ from(ModelProperties properties) {
ModelFactoryBaseModelViewModel_ model = new ModelFactoryBaseModelViewModel_();
model.id(properties.getId());
if (properties.has("title")) {
model.title(properties.getString("title"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,819 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/CallbackPropModelViewModel_.java | package com.airbnb.epoxy;
import android.view.View;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class CallbackPropModelViewModel_ extends EpoxyModel<CallbackPropModelView> implements GeneratedModel<CallbackPropModelView>, CallbackPropModelViewModelBuilder {
private OnModelBoundListener<CallbackPropModelViewModel_, CallbackPropModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<CallbackPropModelViewModel_, CallbackPropModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<CallbackPropModelViewModel_, CallbackPropModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<CallbackPropModelViewModel_, CallbackPropModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
@Nullable
private View.OnClickListener onClickListener_OnClickListener = (View.OnClickListener) null;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final CallbackPropModelView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final CallbackPropModelView object) {
super.bind(object);
object.setOnClickListener(onClickListener_OnClickListener);
}
@Override
public void bind(final CallbackPropModelView object, EpoxyModel previousModel) {
if (!(previousModel instanceof CallbackPropModelViewModel_)) {
bind(object);
return;
}
CallbackPropModelViewModel_ that = (CallbackPropModelViewModel_) previousModel;
super.bind(object);
if (((onClickListener_OnClickListener == null) != (that.onClickListener_OnClickListener == null))) {
object.setOnClickListener(onClickListener_OnClickListener);
}
}
@Override
public void handlePostBind(final CallbackPropModelView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public CallbackPropModelViewModel_ onBind(
OnModelBoundListener<CallbackPropModelViewModel_, CallbackPropModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(CallbackPropModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
object.setOnClickListener((View.OnClickListener) null);
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public CallbackPropModelViewModel_ onUnbind(
OnModelUnboundListener<CallbackPropModelViewModel_, CallbackPropModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final CallbackPropModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public CallbackPropModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<CallbackPropModelViewModel_, CallbackPropModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final CallbackPropModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public CallbackPropModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<CallbackPropModelViewModel_, CallbackPropModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set
*/
public CallbackPropModelViewModel_ onClickListener(
@Nullable final OnModelClickListener<CallbackPropModelViewModel_, CallbackPropModelView> onClickListener) {
onMutation();
if (onClickListener == null) {
this.onClickListener_OnClickListener = null;
}
else {
this.onClickListener_OnClickListener = new WrappedEpoxyModelClickListener<>(onClickListener);
}
return this;
}
/**
* <i>Optional</i>: Default value is (View.OnClickListener) null
*
* @see CallbackPropModelView#setOnClickListener(View.OnClickListener)
*/
public CallbackPropModelViewModel_ onClickListener(
@Nullable View.OnClickListener onClickListener) {
onMutation();
this.onClickListener_OnClickListener = onClickListener;
return this;
}
@Nullable
public View.OnClickListener onClickListener() {
return onClickListener_OnClickListener;
}
@Override
public CallbackPropModelViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public CallbackPropModelViewModel_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public CallbackPropModelViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public CallbackPropModelViewModel_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public CallbackPropModelViewModel_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public CallbackPropModelViewModel_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public CallbackPropModelViewModel_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public CallbackPropModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public CallbackPropModelViewModel_ show() {
super.show();
return this;
}
@Override
public CallbackPropModelViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public CallbackPropModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public CallbackPropModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
this.onClickListener_OnClickListener = (View.OnClickListener) null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof CallbackPropModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
CallbackPropModelViewModel_ that = (CallbackPropModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onClickListener_OnClickListener == null) != (that.onClickListener_OnClickListener == null))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onClickListener_OnClickListener != null ? 1 : 0);
return _result;
}
@Override
public String toString() {
return "CallbackPropModelViewModel_{" +
"onClickListener_OnClickListener=" + onClickListener_OnClickListener +
"}" + super.toString();
}
public static CallbackPropModelViewModel_ from(ModelProperties properties) {
CallbackPropModelViewModel_ model = new CallbackPropModelViewModel_();
model.id(properties.getId());
if (properties.has("onClickListener")) {
model.onClickListener(properties.getOnClickListener("onClickListener"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,820 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/GroupPropSingleSupportedAttributeModelView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.widget.FrameLayout;
import com.airbnb.epoxy.ModelProp.Option;
@ModelView(defaultLayout = 1)
public class GroupPropSingleSupportedAttributeModelView extends FrameLayout {
public GroupPropSingleSupportedAttributeModelView(Context context) {
super(context);
}
@ModelProp
public void setTitle(String title) {
}
@ModelProp({ Option.IgnoreRequireHashCode })
public void setTitle(Object title) {
}
} | 8,821 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/CallbackPropModelView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;
@ModelView(defaultLayout = 1)
public class CallbackPropModelView extends FrameLayout {
public CallbackPropModelView(Context context) {
super(context);
}
@CallbackProp
public void setOnClickListener(@Nullable OnClickListener listener) {
}
}
| 8,822 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/TextPropModelViewModel_.java | package com.airbnb.epoxy;
import android.content.Context;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.PluralsRes;
import androidx.annotation.StringRes;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class TextPropModelViewModel_ extends EpoxyModel<TextPropModelView> implements GeneratedModel<TextPropModelView>, TextPropModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(1);
private OnModelBoundListener<TextPropModelViewModel_, TextPropModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<TextPropModelViewModel_, TextPropModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<TextPropModelViewModel_, TextPropModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<TextPropModelViewModel_, TextPropModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
private StringAttributeData title_StringAttributeData = new StringAttributeData();
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(0)) {
throw new IllegalStateException("A value is required for setTitle");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final TextPropModelView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final TextPropModelView object) {
super.bind(object);
object.setTitle(title_StringAttributeData.toString(object.getContext()));
}
@Override
public void bind(final TextPropModelView object, EpoxyModel previousModel) {
if (!(previousModel instanceof TextPropModelViewModel_)) {
bind(object);
return;
}
TextPropModelViewModel_ that = (TextPropModelViewModel_) previousModel;
super.bind(object);
if ((title_StringAttributeData != null ? !title_StringAttributeData.equals(that.title_StringAttributeData) : that.title_StringAttributeData != null)) {
object.setTitle(title_StringAttributeData.toString(object.getContext()));
}
}
@Override
public void handlePostBind(final TextPropModelView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public TextPropModelViewModel_ onBind(
OnModelBoundListener<TextPropModelViewModel_, TextPropModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(TextPropModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public TextPropModelViewModel_ onUnbind(
OnModelUnboundListener<TextPropModelViewModel_, TextPropModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final TextPropModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public TextPropModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<TextPropModelViewModel_, TextPropModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final TextPropModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public TextPropModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<TextPropModelViewModel_, TextPropModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public CharSequence getTitle(Context context) {
return title_StringAttributeData.toString(context);
}
/**
* <i>Required.</i>
*
* @see TextPropModelView#setTitle(CharSequence)
*/
public TextPropModelViewModel_ title(@NonNull CharSequence title) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
if (title == null) {
throw new IllegalArgumentException("title cannot be null");
}
title_StringAttributeData.setValue(title);
return this;
}
/**
* Throws if a value <= 0 is set.
* <p>
* <i>Required.</i>
*
* @see TextPropModelView#setTitle(CharSequence)
*/
public TextPropModelViewModel_ title(@StringRes int stringRes) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
title_StringAttributeData.setValue(stringRes);
return this;
}
/**
* Throws if a value <= 0 is set.
* <p>
* <i>Required.</i>
*
* @see TextPropModelView#setTitle(CharSequence)
*/
public TextPropModelViewModel_ title(@StringRes int stringRes, Object... formatArgs) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
title_StringAttributeData.setValue(stringRes, formatArgs);
return this;
}
/**
* Throws if a value <= 0 is set.
* <p>
* <i>Required.</i>
*
* @see TextPropModelView#setTitle(CharSequence)
*/
public TextPropModelViewModel_ titleQuantityRes(@PluralsRes int pluralRes, int quantity,
Object... formatArgs) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
title_StringAttributeData.setValue(pluralRes, quantity, formatArgs);
return this;
}
@Override
public TextPropModelViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public TextPropModelViewModel_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public TextPropModelViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public TextPropModelViewModel_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public TextPropModelViewModel_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public TextPropModelViewModel_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public TextPropModelViewModel_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public TextPropModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public TextPropModelViewModel_ show() {
super.show();
return this;
}
@Override
public TextPropModelViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public TextPropModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public TextPropModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.title_StringAttributeData = new StringAttributeData();
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof TextPropModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
TextPropModelViewModel_ that = (TextPropModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((title_StringAttributeData != null ? !title_StringAttributeData.equals(that.title_StringAttributeData) : that.title_StringAttributeData != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (title_StringAttributeData != null ? title_StringAttributeData.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "TextPropModelViewModel_{" +
"title_StringAttributeData=" + title_StringAttributeData +
"}" + super.toString();
}
public static TextPropModelViewModel_ from(ModelProperties properties) {
TextPropModelViewModel_ model = new TextPropModelViewModel_();
model.id(properties.getId());
if (properties.has("title")) {
model.title(properties.getString("title"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,823 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/AllTypesModelViewModel_.java | package com.airbnb.epoxy;
import android.view.View;
import androidx.annotation.DrawableRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes;
import java.lang.Boolean;
import java.lang.CharSequence;
import java.lang.Double;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Integer;
import java.lang.Long;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
import java.util.List;
/**
* Generated file. Do not modify!
*/
public class AllTypesModelViewModel_ extends EpoxyModel<AllTypesModelView> implements GeneratedModel<AllTypesModelView>, AllTypesModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(15);
private OnModelBoundListener<AllTypesModelViewModel_, AllTypesModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<AllTypesModelViewModel_, AllTypesModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<AllTypesModelViewModel_, AllTypesModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<AllTypesModelViewModel_, AllTypesModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
private boolean booleanValue_Boolean = false;
/**
* Bitset index: 1
*/
@NonNull
private Boolean boxedBooleanValue_Boolean;
/**
* Bitset index: 2
*/
@NonNull
private CharSequence charSequenceValue_CharSequence;
/**
* Bitset index: 3
*/
@NonNull
private Double boxedDoubleValue_Double;
private double doubleValue_Double = 0.0d;
@DrawableRes
private int drawableRes_Int = 0;
/**
* Bitset index: 6
*/
@NonNull
private List<? extends EpoxyModel<?>> epoxyModelList_List;
private int intValue_Int = 0;
/**
* Bitset index: 8
*/
@NonNull
private Integer boxedIntValue_Integer;
private long longValue_Long = 0L;
/**
* Bitset index: 10
*/
@NonNull
private Long boxedLongValue_Long;
/**
* Bitset index: 11
*/
@NonNull
private View.OnClickListener onClickListener_OnClickListener;
@RawRes
private int rawRes_Int = 0;
/**
* Bitset index: 13
*/
@NonNull
private String stringValue_String;
/**
* Bitset index: 14
*/
@NonNull
private List<String> stringList_List;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(8)) {
throw new IllegalStateException("A value is required for setBoxedIntValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(1)) {
throw new IllegalStateException("A value is required for setBoxedBooleanValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(3)) {
throw new IllegalStateException("A value is required for setBoxedDoubleValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(6)) {
throw new IllegalStateException("A value is required for setEpoxyModelList");
}
if (!assignedAttributes_epoxyGeneratedModel.get(10)) {
throw new IllegalStateException("A value is required for setBoxedLongValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(14)) {
throw new IllegalStateException("A value is required for setStringList");
}
if (!assignedAttributes_epoxyGeneratedModel.get(13)) {
throw new IllegalStateException("A value is required for setStringValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(11)) {
throw new IllegalStateException("A value is required for setOnClickListener");
}
if (!assignedAttributes_epoxyGeneratedModel.get(2)) {
throw new IllegalStateException("A value is required for setCharSequenceValue");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final AllTypesModelView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final AllTypesModelView object) {
super.bind(object);
object.setBooleanValue(booleanValue_Boolean);
object.setBoxedIntValue(boxedIntValue_Integer);
object.setBoxedBooleanValue(boxedBooleanValue_Boolean);
object.setBoxedDoubleValue(boxedDoubleValue_Double);
object.setEpoxyModelList(epoxyModelList_List);
object.setBoxedLongValue(boxedLongValue_Long);
object.setLongValue(longValue_Long);
object.setStringList(stringList_List);
object.setStringValue(stringValue_String);
object.setOnClickListener(onClickListener_OnClickListener);
object.setIntValue(intValue_Int);
object.setDrawableRes(drawableRes_Int);
object.setDoubleValue(doubleValue_Double);
object.setRawRes(rawRes_Int);
object.setCharSequenceValue(charSequenceValue_CharSequence);
}
@Override
public void bind(final AllTypesModelView object, EpoxyModel previousModel) {
if (!(previousModel instanceof AllTypesModelViewModel_)) {
bind(object);
return;
}
AllTypesModelViewModel_ that = (AllTypesModelViewModel_) previousModel;
super.bind(object);
if ((booleanValue_Boolean != that.booleanValue_Boolean)) {
object.setBooleanValue(booleanValue_Boolean);
}
if ((boxedIntValue_Integer != null ? !boxedIntValue_Integer.equals(that.boxedIntValue_Integer) : that.boxedIntValue_Integer != null)) {
object.setBoxedIntValue(boxedIntValue_Integer);
}
if ((boxedBooleanValue_Boolean != null ? !boxedBooleanValue_Boolean.equals(that.boxedBooleanValue_Boolean) : that.boxedBooleanValue_Boolean != null)) {
object.setBoxedBooleanValue(boxedBooleanValue_Boolean);
}
if ((boxedDoubleValue_Double != null ? !boxedDoubleValue_Double.equals(that.boxedDoubleValue_Double) : that.boxedDoubleValue_Double != null)) {
object.setBoxedDoubleValue(boxedDoubleValue_Double);
}
if ((epoxyModelList_List != null ? !epoxyModelList_List.equals(that.epoxyModelList_List) : that.epoxyModelList_List != null)) {
object.setEpoxyModelList(epoxyModelList_List);
}
if ((boxedLongValue_Long != null ? !boxedLongValue_Long.equals(that.boxedLongValue_Long) : that.boxedLongValue_Long != null)) {
object.setBoxedLongValue(boxedLongValue_Long);
}
if ((longValue_Long != that.longValue_Long)) {
object.setLongValue(longValue_Long);
}
if ((stringList_List != null ? !stringList_List.equals(that.stringList_List) : that.stringList_List != null)) {
object.setStringList(stringList_List);
}
if ((stringValue_String != null ? !stringValue_String.equals(that.stringValue_String) : that.stringValue_String != null)) {
object.setStringValue(stringValue_String);
}
if (((onClickListener_OnClickListener == null) != (that.onClickListener_OnClickListener == null))) {
object.setOnClickListener(onClickListener_OnClickListener);
}
if ((intValue_Int != that.intValue_Int)) {
object.setIntValue(intValue_Int);
}
if ((drawableRes_Int != that.drawableRes_Int)) {
object.setDrawableRes(drawableRes_Int);
}
if ((Double.compare(that.doubleValue_Double, doubleValue_Double) != 0)) {
object.setDoubleValue(doubleValue_Double);
}
if ((rawRes_Int != that.rawRes_Int)) {
object.setRawRes(rawRes_Int);
}
if ((charSequenceValue_CharSequence != null ? !charSequenceValue_CharSequence.equals(that.charSequenceValue_CharSequence) : that.charSequenceValue_CharSequence != null)) {
object.setCharSequenceValue(charSequenceValue_CharSequence);
}
}
@Override
public void handlePostBind(final AllTypesModelView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public AllTypesModelViewModel_ onBind(
OnModelBoundListener<AllTypesModelViewModel_, AllTypesModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(AllTypesModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public AllTypesModelViewModel_ onUnbind(
OnModelUnboundListener<AllTypesModelViewModel_, AllTypesModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final AllTypesModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public AllTypesModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<AllTypesModelViewModel_, AllTypesModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final AllTypesModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public AllTypesModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<AllTypesModelViewModel_, AllTypesModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Optional</i>: Default value is false
*
* @see AllTypesModelView#setBooleanValue(boolean)
*/
public AllTypesModelViewModel_ booleanValue(boolean booleanValue) {
onMutation();
this.booleanValue_Boolean = booleanValue;
return this;
}
public boolean booleanValue() {
return booleanValue_Boolean;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setBoxedBooleanValue(Boolean)
*/
public AllTypesModelViewModel_ boxedBooleanValue(@NonNull Boolean boxedBooleanValue) {
if (boxedBooleanValue == null) {
throw new IllegalArgumentException("boxedBooleanValue cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(1);
onMutation();
this.boxedBooleanValue_Boolean = boxedBooleanValue;
return this;
}
@NonNull
public Boolean boxedBooleanValue() {
return boxedBooleanValue_Boolean;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setCharSequenceValue(CharSequence)
*/
public AllTypesModelViewModel_ charSequenceValue(@NonNull CharSequence charSequenceValue) {
if (charSequenceValue == null) {
throw new IllegalArgumentException("charSequenceValue cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(2);
onMutation();
this.charSequenceValue_CharSequence = charSequenceValue;
return this;
}
@NonNull
public CharSequence charSequenceValue() {
return charSequenceValue_CharSequence;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setBoxedDoubleValue(Double)
*/
public AllTypesModelViewModel_ boxedDoubleValue(@NonNull Double boxedDoubleValue) {
if (boxedDoubleValue == null) {
throw new IllegalArgumentException("boxedDoubleValue cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(3);
onMutation();
this.boxedDoubleValue_Double = boxedDoubleValue;
return this;
}
@NonNull
public Double boxedDoubleValue() {
return boxedDoubleValue_Double;
}
/**
* <i>Optional</i>: Default value is 0.0d
*
* @see AllTypesModelView#setDoubleValue(double)
*/
public AllTypesModelViewModel_ doubleValue(double doubleValue) {
onMutation();
this.doubleValue_Double = doubleValue;
return this;
}
public double doubleValue() {
return doubleValue_Double;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see AllTypesModelView#setDrawableRes(int)
*/
public AllTypesModelViewModel_ drawableRes(@DrawableRes int drawableRes) {
onMutation();
this.drawableRes_Int = drawableRes;
return this;
}
@DrawableRes
public int drawableRes() {
return drawableRes_Int;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setEpoxyModelList(List<? extends EpoxyModel<?>>)
*/
public AllTypesModelViewModel_ epoxyModelList(
@NonNull List<? extends EpoxyModel<?>> epoxyModelList) {
if (epoxyModelList == null) {
throw new IllegalArgumentException("epoxyModelList cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(6);
onMutation();
this.epoxyModelList_List = epoxyModelList;
return this;
}
@NonNull
public List<? extends EpoxyModel<?>> epoxyModelList() {
return epoxyModelList_List;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see AllTypesModelView#setIntValue(int)
*/
public AllTypesModelViewModel_ intValue(int intValue) {
onMutation();
this.intValue_Int = intValue;
return this;
}
public int intValue() {
return intValue_Int;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setBoxedIntValue(Integer)
*/
public AllTypesModelViewModel_ boxedIntValue(@NonNull Integer boxedIntValue) {
if (boxedIntValue == null) {
throw new IllegalArgumentException("boxedIntValue cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(8);
onMutation();
this.boxedIntValue_Integer = boxedIntValue;
return this;
}
@NonNull
public Integer boxedIntValue() {
return boxedIntValue_Integer;
}
/**
* <i>Optional</i>: Default value is 0L
*
* @see AllTypesModelView#setLongValue(long)
*/
public AllTypesModelViewModel_ longValue(long longValue) {
onMutation();
this.longValue_Long = longValue;
return this;
}
public long longValue() {
return longValue_Long;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setBoxedLongValue(Long)
*/
public AllTypesModelViewModel_ boxedLongValue(@NonNull Long boxedLongValue) {
if (boxedLongValue == null) {
throw new IllegalArgumentException("boxedLongValue cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(10);
onMutation();
this.boxedLongValue_Long = boxedLongValue;
return this;
}
@NonNull
public Long boxedLongValue() {
return boxedLongValue_Long;
}
/**
* Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set
*/
public AllTypesModelViewModel_ onClickListener(
@NonNull final OnModelClickListener<AllTypesModelViewModel_, AllTypesModelView> onClickListener) {
assignedAttributes_epoxyGeneratedModel.set(11);
onMutation();
if (onClickListener == null) {
this.onClickListener_OnClickListener = null;
}
else {
this.onClickListener_OnClickListener = new WrappedEpoxyModelClickListener<>(onClickListener);
}
return this;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setOnClickListener(View.OnClickListener)
*/
public AllTypesModelViewModel_ onClickListener(@NonNull View.OnClickListener onClickListener) {
if (onClickListener == null) {
throw new IllegalArgumentException("onClickListener cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(11);
onMutation();
this.onClickListener_OnClickListener = onClickListener;
return this;
}
@NonNull
public View.OnClickListener onClickListener() {
return onClickListener_OnClickListener;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see AllTypesModelView#setRawRes(int)
*/
public AllTypesModelViewModel_ rawRes(@RawRes int rawRes) {
onMutation();
this.rawRes_Int = rawRes;
return this;
}
@RawRes
public int rawRes() {
return rawRes_Int;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setStringValue(String)
*/
public AllTypesModelViewModel_ stringValue(@NonNull String stringValue) {
if (stringValue == null) {
throw new IllegalArgumentException("stringValue cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(13);
onMutation();
this.stringValue_String = stringValue;
return this;
}
@NonNull
public String stringValue() {
return stringValue_String;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setStringList(List<String>)
*/
public AllTypesModelViewModel_ stringList(@NonNull List<String> stringList) {
if (stringList == null) {
throw new IllegalArgumentException("stringList cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(14);
onMutation();
this.stringList_List = stringList;
return this;
}
@NonNull
public List<String> stringList() {
return stringList_List;
}
@Override
public AllTypesModelViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public AllTypesModelViewModel_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public AllTypesModelViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public AllTypesModelViewModel_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public AllTypesModelViewModel_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public AllTypesModelViewModel_ id(@Nullable CharSequence key, long id) {
super.id(key, id);
return this;
}
@Override
public AllTypesModelViewModel_ layout(@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public AllTypesModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public AllTypesModelViewModel_ show() {
super.show();
return this;
}
@Override
public AllTypesModelViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public AllTypesModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public AllTypesModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.booleanValue_Boolean = false;
this.boxedBooleanValue_Boolean = null;
this.charSequenceValue_CharSequence = null;
this.boxedDoubleValue_Double = null;
this.doubleValue_Double = 0.0d;
this.drawableRes_Int = 0;
this.epoxyModelList_List = null;
this.intValue_Int = 0;
this.boxedIntValue_Integer = null;
this.longValue_Long = 0L;
this.boxedLongValue_Long = null;
this.onClickListener_OnClickListener = null;
this.rawRes_Int = 0;
this.stringValue_String = null;
this.stringList_List = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof AllTypesModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
AllTypesModelViewModel_ that = (AllTypesModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((booleanValue_Boolean != that.booleanValue_Boolean)) {
return false;
}
if ((boxedBooleanValue_Boolean != null ? !boxedBooleanValue_Boolean.equals(that.boxedBooleanValue_Boolean) : that.boxedBooleanValue_Boolean != null)) {
return false;
}
if ((charSequenceValue_CharSequence != null ? !charSequenceValue_CharSequence.equals(that.charSequenceValue_CharSequence) : that.charSequenceValue_CharSequence != null)) {
return false;
}
if ((boxedDoubleValue_Double != null ? !boxedDoubleValue_Double.equals(that.boxedDoubleValue_Double) : that.boxedDoubleValue_Double != null)) {
return false;
}
if ((Double.compare(that.doubleValue_Double, doubleValue_Double) != 0)) {
return false;
}
if ((drawableRes_Int != that.drawableRes_Int)) {
return false;
}
if ((epoxyModelList_List != null ? !epoxyModelList_List.equals(that.epoxyModelList_List) : that.epoxyModelList_List != null)) {
return false;
}
if ((intValue_Int != that.intValue_Int)) {
return false;
}
if ((boxedIntValue_Integer != null ? !boxedIntValue_Integer.equals(that.boxedIntValue_Integer) : that.boxedIntValue_Integer != null)) {
return false;
}
if ((longValue_Long != that.longValue_Long)) {
return false;
}
if ((boxedLongValue_Long != null ? !boxedLongValue_Long.equals(that.boxedLongValue_Long) : that.boxedLongValue_Long != null)) {
return false;
}
if (((onClickListener_OnClickListener == null) != (that.onClickListener_OnClickListener == null))) {
return false;
}
if ((rawRes_Int != that.rawRes_Int)) {
return false;
}
if ((stringValue_String != null ? !stringValue_String.equals(that.stringValue_String) : that.stringValue_String != null)) {
return false;
}
if ((stringList_List != null ? !stringList_List.equals(that.stringList_List) : that.stringList_List != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
long temp;
_result = 31 * _result + (booleanValue_Boolean ? 1 : 0);
_result = 31 * _result + (boxedBooleanValue_Boolean != null ? boxedBooleanValue_Boolean.hashCode() : 0);
_result = 31 * _result + (charSequenceValue_CharSequence != null ? charSequenceValue_CharSequence.hashCode() : 0);
_result = 31 * _result + (boxedDoubleValue_Double != null ? boxedDoubleValue_Double.hashCode() : 0);
temp = Double.doubleToLongBits(doubleValue_Double);
_result = 31 * _result + (int) (temp ^ (temp >>> 32));
_result = 31 * _result + drawableRes_Int;
_result = 31 * _result + (epoxyModelList_List != null ? epoxyModelList_List.hashCode() : 0);
_result = 31 * _result + intValue_Int;
_result = 31 * _result + (boxedIntValue_Integer != null ? boxedIntValue_Integer.hashCode() : 0);
_result = 31 * _result + (int) (longValue_Long ^ (longValue_Long >>> 32));
_result = 31 * _result + (boxedLongValue_Long != null ? boxedLongValue_Long.hashCode() : 0);
_result = 31 * _result + (onClickListener_OnClickListener != null ? 1 : 0);
_result = 31 * _result + rawRes_Int;
_result = 31 * _result + (stringValue_String != null ? stringValue_String.hashCode() : 0);
_result = 31 * _result + (stringList_List != null ? stringList_List.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "AllTypesModelViewModel_{" +
"booleanValue_Boolean=" + booleanValue_Boolean +
", boxedBooleanValue_Boolean=" + boxedBooleanValue_Boolean +
", charSequenceValue_CharSequence=" + charSequenceValue_CharSequence +
", boxedDoubleValue_Double=" + boxedDoubleValue_Double +
", doubleValue_Double=" + doubleValue_Double +
", drawableRes_Int=" + drawableRes_Int +
", epoxyModelList_List=" + epoxyModelList_List +
", intValue_Int=" + intValue_Int +
", boxedIntValue_Integer=" + boxedIntValue_Integer +
", longValue_Long=" + longValue_Long +
", boxedLongValue_Long=" + boxedLongValue_Long +
", onClickListener_OnClickListener=" + onClickListener_OnClickListener +
", rawRes_Int=" + rawRes_Int +
", stringValue_String=" + stringValue_String +
", stringList_List=" + stringList_List +
"}" + super.toString();
}
public static AllTypesModelViewModel_ from(ModelProperties properties) {
AllTypesModelViewModel_ model = new AllTypesModelViewModel_();
model.id(properties.getId());
if (properties.has("booleanValue")) {
model.booleanValue(properties.getBoolean("booleanValue"));
}
if (properties.has("boxedBooleanValue")) {
model.boxedBooleanValue(properties.getBoolean("boxedBooleanValue"));
}
if (properties.has("charSequenceValue")) {
model.charSequenceValue(properties.getString("charSequenceValue"));
}
if (properties.has("boxedDoubleValue")) {
model.boxedDoubleValue(properties.getDouble("boxedDoubleValue"));
}
if (properties.has("doubleValue")) {
model.doubleValue(properties.getDouble("doubleValue"));
}
if (properties.has("drawableRes")) {
model.drawableRes(properties.getDrawableRes("drawableRes"));
}
if (properties.has("epoxyModelList")) {
model.epoxyModelList(properties.getEpoxyModelList("epoxyModelList"));
}
if (properties.has("intValue")) {
model.intValue(properties.getInt("intValue"));
}
if (properties.has("boxedIntValue")) {
model.boxedIntValue(properties.getInt("boxedIntValue"));
}
if (properties.has("longValue")) {
model.longValue(properties.getLong("longValue"));
}
if (properties.has("boxedLongValue")) {
model.boxedLongValue(properties.getLong("boxedLongValue"));
}
if (properties.has("onClickListener")) {
model.onClickListener(properties.getOnClickListener("onClickListener"));
}
if (properties.has("rawRes")) {
model.rawRes(properties.getRawRes("rawRes"));
}
if (properties.has("stringValue")) {
model.stringValue(properties.getString("stringValue"));
}
if (properties.has("stringList")) {
model.stringList(properties.getStringList("stringList"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,824 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/GroupPropMultipleSupportedAttributeSameNameModelViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class GroupPropMultipleSupportedAttributeSameNameModelViewModel_ extends EpoxyModel<GroupPropMultipleSupportedAttributeSameNameModelView> implements GeneratedModel<GroupPropMultipleSupportedAttributeSameNameModelView>, GroupPropMultipleSupportedAttributeSameNameModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(2);
private OnModelBoundListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
@NonNull
private String titleString_String;
/**
* Bitset index: 1
*/
private int titleInt_Int = 0;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder,
final GroupPropMultipleSupportedAttributeSameNameModelView object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final GroupPropMultipleSupportedAttributeSameNameModelView object) {
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
object.setTitleString(titleString_String);
}
else if (assignedAttributes_epoxyGeneratedModel.get(1)) {
object.setTitleInt(titleInt_Int);
}
else {
object.setTitleInt(titleInt_Int);
}
}
@Override
public void bind(final GroupPropMultipleSupportedAttributeSameNameModelView object,
EpoxyModel previousModel) {
if (!(previousModel instanceof GroupPropMultipleSupportedAttributeSameNameModelViewModel_)) {
bind(object);
return;
}
GroupPropMultipleSupportedAttributeSameNameModelViewModel_ that = (GroupPropMultipleSupportedAttributeSameNameModelViewModel_) previousModel;
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(0) || (titleString_String != null ? !titleString_String.equals(that.titleString_String) : that.titleString_String != null)) {
object.setTitleString(titleString_String);
}
}
else if (assignedAttributes_epoxyGeneratedModel.get(1)) {
if ((titleInt_Int != that.titleInt_Int)) {
object.setTitleInt(titleInt_Int);
}
}
// A value was not set so we should use the default value, but we only need to set it if the previous model had a custom value set.
else if (that.assignedAttributes_epoxyGeneratedModel.get(0) || that.assignedAttributes_epoxyGeneratedModel.get(1)) {
object.setTitleInt(titleInt_Int);
}
}
@Override
public void handlePostBind(final GroupPropMultipleSupportedAttributeSameNameModelView object,
int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onBind(
OnModelBoundListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(GroupPropMultipleSupportedAttributeSameNameModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onUnbind(
OnModelUnboundListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState,
final GroupPropMultipleSupportedAttributeSameNameModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth,
final GroupPropMultipleSupportedAttributeSameNameModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Required.</i>
*
* @see GroupPropMultipleSupportedAttributeSameNameModelView#setTitleString(String)
*/
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ titleString(
@NonNull String titleString) {
if (titleString == null) {
throw new IllegalArgumentException("titleString cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(0);
assignedAttributes_epoxyGeneratedModel.clear(1);
this.titleInt_Int = 0;
onMutation();
this.titleString_String = titleString;
return this;
}
@NonNull
public String titleStringString() {
return titleString_String;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see GroupPropMultipleSupportedAttributeSameNameModelView#setTitleInt(int)
*/
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ titleInt(int titleInt) {
assignedAttributes_epoxyGeneratedModel.set(1);
assignedAttributes_epoxyGeneratedModel.clear(0);
this.titleString_String = null;
onMutation();
this.titleInt_Int = titleInt;
return this;
}
public int titleIntInt() {
return titleInt_Int;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(long id) {
super.id(id);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(@Nullable Number... ids) {
super.id(ids);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(long id1, long id2) {
super.id(id1, id2);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(@Nullable CharSequence key) {
super.id(key);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(@Nullable CharSequence key,
@Nullable CharSequence... otherKeys) {
super.id(key, otherKeys);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(@Nullable CharSequence key,
long id) {
super.id(key, id);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ layout(
@LayoutRes int layoutRes) {
super.layout(layoutRes);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback spanSizeCallback) {
super.spanSizeOverride(spanSizeCallback);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ show() {
super.show();
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ show(boolean show) {
super.show(show);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.titleString_String = null;
this.titleInt_Int = 0;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof GroupPropMultipleSupportedAttributeSameNameModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
GroupPropMultipleSupportedAttributeSameNameModelViewModel_ that = (GroupPropMultipleSupportedAttributeSameNameModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((titleString_String != null ? !titleString_String.equals(that.titleString_String) : that.titleString_String != null)) {
return false;
}
if ((titleInt_Int != that.titleInt_Int)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (titleString_String != null ? titleString_String.hashCode() : 0);
_result = 31 * _result + titleInt_Int;
return _result;
}
@Override
public String toString() {
return "GroupPropMultipleSupportedAttributeSameNameModelViewModel_{" +
"titleString_String=" + titleString_String +
", titleInt_Int=" + titleInt_Int +
"}" + super.toString();
}
public static GroupPropMultipleSupportedAttributeSameNameModelViewModel_ from(
ModelProperties properties) {
GroupPropMultipleSupportedAttributeSameNameModelViewModel_ model = new GroupPropMultipleSupportedAttributeSameNameModelViewModel_();
model.id(properties.getId());
if (properties.has("titleString")) {
model.titleString(properties.getString("titleString"));
} else if (properties.has("titleInt")) {
model.titleInt(properties.getInt("titleInt"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,825 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ListSubtypeModelView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;
import java.util.ArrayList;
@ModelView(defaultLayout = 1)
public class ListSubtypeModelView extends FrameLayout {
public ListSubtypeModelView(Context context) {
super(context);
}
@ModelProp
public void setStringArrayList(ArrayList<String> value) {
}
}
| 8,826 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ksp/GroupPropSingleSupportedAttributeModelViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class GroupPropSingleSupportedAttributeModelViewModel_ extends EpoxyModel<GroupPropSingleSupportedAttributeModelView> implements GeneratedModel<GroupPropSingleSupportedAttributeModelView>, GroupPropSingleSupportedAttributeModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(2);
private OnModelBoundListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
@NonNull
private String title_String;
/**
* Bitset index: 1
*/
@NonNull
private Object title_Object;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(0) && !assignedAttributes_epoxyGeneratedModel.get(1)) {
throw new IllegalStateException("A value is required for setTitle");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder,
final GroupPropSingleSupportedAttributeModelView object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final GroupPropSingleSupportedAttributeModelView object) {
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
object.setTitle(title_String);
}
else {
object.setTitle(title_Object);
}
}
@Override
public void bind(final GroupPropSingleSupportedAttributeModelView object,
EpoxyModel previousModel) {
if (!(previousModel instanceof GroupPropSingleSupportedAttributeModelViewModel_)) {
bind(object);
return;
}
GroupPropSingleSupportedAttributeModelViewModel_ that = (GroupPropSingleSupportedAttributeModelViewModel_) previousModel;
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(0) || (title_String != null ? !title_String.equals(that.title_String) : that.title_String != null)) {
object.setTitle(title_String);
}
}
else if (assignedAttributes_epoxyGeneratedModel.get(1)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(1) || (title_Object != null ? !title_Object.equals(that.title_Object) : that.title_Object != null)) {
object.setTitle(title_Object);
}
}
}
@Override
public void handlePostBind(final GroupPropSingleSupportedAttributeModelView object,
int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GroupPropSingleSupportedAttributeModelViewModel_ onBind(
OnModelBoundListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(GroupPropSingleSupportedAttributeModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GroupPropSingleSupportedAttributeModelViewModel_ onUnbind(
OnModelUnboundListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState,
final GroupPropSingleSupportedAttributeModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GroupPropSingleSupportedAttributeModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth,
final GroupPropSingleSupportedAttributeModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GroupPropSingleSupportedAttributeModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<GroupPropSingleSupportedAttributeModelViewModel_, GroupPropSingleSupportedAttributeModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Required.</i>
*
* @see GroupPropSingleSupportedAttributeModelView#setTitle(String)
*/
public GroupPropSingleSupportedAttributeModelViewModel_ title(@NonNull String title) {
if (title == null) {
throw new IllegalArgumentException("title cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(0);
assignedAttributes_epoxyGeneratedModel.clear(1);
this.title_Object = null;
onMutation();
this.title_String = title;
return this;
}
@NonNull
public String titleString() {
return title_String;
}
/**
* <i>Required.</i>
*
* @see GroupPropSingleSupportedAttributeModelView#setTitle(Object)
*/
public GroupPropSingleSupportedAttributeModelViewModel_ title(@NonNull Object title) {
if (title == null) {
throw new IllegalArgumentException("title cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(1);
assignedAttributes_epoxyGeneratedModel.clear(0);
this.title_String = null;
onMutation();
this.title_Object = title;
return this;
}
@NonNull
public Object titleObject() {
return title_Object;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ id(long p0) {
super.id(p0);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ id(@Nullable Number... p0) {
super.id(p0);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ id(long p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ id(@Nullable CharSequence p0) {
super.id(p0);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ id(@Nullable CharSequence p0,
@Nullable CharSequence... p1) {
super.id(p0, p1);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ id(@Nullable CharSequence p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ layout(@LayoutRes int p0) {
super.layout(p0);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback p0) {
super.spanSizeOverride(p0);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ show() {
super.show();
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ show(boolean p0) {
super.show(p0);
return this;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public GroupPropSingleSupportedAttributeModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.title_String = null;
this.title_Object = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof GroupPropSingleSupportedAttributeModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
GroupPropSingleSupportedAttributeModelViewModel_ that = (GroupPropSingleSupportedAttributeModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((title_String != null ? !title_String.equals(that.title_String) : that.title_String != null)) {
return false;
}
if ((title_Object != null ? !title_Object.equals(that.title_Object) : that.title_Object != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (title_String != null ? title_String.hashCode() : 0);
_result = 31 * _result + (title_Object != null ? title_Object.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "GroupPropSingleSupportedAttributeModelViewModel_{" +
"title_String=" + title_String +
", title_Object=" + title_Object +
"}" + super.toString();
}
public static GroupPropSingleSupportedAttributeModelViewModel_ from(ModelProperties properties) {
GroupPropSingleSupportedAttributeModelViewModel_ model = new GroupPropSingleSupportedAttributeModelViewModel_();
model.id(properties.getId());
if (properties.has("title")) {
model.title(properties.getString("title"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,827 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ksp/GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ extends EpoxyModel<GroupPropMultipleSupportedAttributeDifferentNameModelView> implements GeneratedModel<GroupPropMultipleSupportedAttributeDifferentNameModelView>, GroupPropMultipleSupportedAttributeDifferentNameModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(2);
private OnModelBoundListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
@NonNull
private String titleString_String;
/**
* Bitset index: 1
*/
private int titleInt_Int = 0;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder,
final GroupPropMultipleSupportedAttributeDifferentNameModelView object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final GroupPropMultipleSupportedAttributeDifferentNameModelView object) {
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
object.setTitleString(titleString_String);
}
else if (assignedAttributes_epoxyGeneratedModel.get(1)) {
object.setTitleInt(titleInt_Int);
}
else {
object.setTitleInt(titleInt_Int);
}
}
@Override
public void bind(final GroupPropMultipleSupportedAttributeDifferentNameModelView object,
EpoxyModel previousModel) {
if (!(previousModel instanceof GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_)) {
bind(object);
return;
}
GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ that = (GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_) previousModel;
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(0) || (titleString_String != null ? !titleString_String.equals(that.titleString_String) : that.titleString_String != null)) {
object.setTitleString(titleString_String);
}
}
else if (assignedAttributes_epoxyGeneratedModel.get(1)) {
if ((titleInt_Int != that.titleInt_Int)) {
object.setTitleInt(titleInt_Int);
}
}
// A value was not set so we should use the default value, but we only need to set it if the previous model had a custom value set.
else if (that.assignedAttributes_epoxyGeneratedModel.get(0) || that.assignedAttributes_epoxyGeneratedModel.get(1)) {
object.setTitleInt(titleInt_Int);
}
}
@Override
public void handlePostBind(final GroupPropMultipleSupportedAttributeDifferentNameModelView object,
int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onBind(
OnModelBoundListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(GroupPropMultipleSupportedAttributeDifferentNameModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onUnbind(
OnModelUnboundListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState,
final GroupPropMultipleSupportedAttributeDifferentNameModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth,
final GroupPropMultipleSupportedAttributeDifferentNameModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_, GroupPropMultipleSupportedAttributeDifferentNameModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Required.</i>
*
* @see GroupPropMultipleSupportedAttributeDifferentNameModelView#setTitleString(String)
*/
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ titleString(
@NonNull String titleString) {
if (titleString == null) {
throw new IllegalArgumentException("titleString cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(0);
assignedAttributes_epoxyGeneratedModel.clear(1);
this.titleInt_Int = 0;
onMutation();
this.titleString_String = titleString;
return this;
}
@NonNull
public String titleStringString() {
return titleString_String;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see GroupPropMultipleSupportedAttributeDifferentNameModelView#setTitleInt(int)
*/
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ titleInt(int titleInt) {
assignedAttributes_epoxyGeneratedModel.set(1);
assignedAttributes_epoxyGeneratedModel.clear(0);
this.titleString_String = null;
onMutation();
this.titleInt_Int = titleInt;
return this;
}
public int titleIntInt() {
return titleInt_Int;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(long p0) {
super.id(p0);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(
@Nullable Number... p0) {
super.id(p0);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(long p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(
@Nullable CharSequence p0) {
super.id(p0);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(
@Nullable CharSequence p0, @Nullable CharSequence... p1) {
super.id(p0, p1);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(
@Nullable CharSequence p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ layout(@LayoutRes int p0) {
super.layout(p0);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback p0) {
super.spanSizeOverride(p0);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ show() {
super.show();
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ show(boolean p0) {
super.show(p0);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.titleString_String = null;
this.titleInt_Int = 0;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ that = (GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((titleString_String != null ? !titleString_String.equals(that.titleString_String) : that.titleString_String != null)) {
return false;
}
if ((titleInt_Int != that.titleInt_Int)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (titleString_String != null ? titleString_String.hashCode() : 0);
_result = 31 * _result + titleInt_Int;
return _result;
}
@Override
public String toString() {
return "GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_{" +
"titleString_String=" + titleString_String +
", titleInt_Int=" + titleInt_Int +
"}" + super.toString();
}
public static GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ from(
ModelProperties properties) {
GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ model = new GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_();
model.id(properties.getId());
if (properties.has("titleString")) {
model.titleString(properties.getString("titleString"));
} else if (properties.has("titleInt")) {
model.titleInt(properties.getInt("titleInt"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,828 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ksp/ListSubtypeModelViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.ArrayList;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class ListSubtypeModelViewModel_ extends EpoxyModel<ListSubtypeModelView> implements GeneratedModel<ListSubtypeModelView>, ListSubtypeModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(1);
private OnModelBoundListener<ListSubtypeModelViewModel_, ListSubtypeModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ListSubtypeModelViewModel_, ListSubtypeModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ListSubtypeModelViewModel_, ListSubtypeModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ListSubtypeModelViewModel_, ListSubtypeModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
@NonNull
private ArrayList<String> stringArrayList_ArrayList;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(0)) {
throw new IllegalStateException("A value is required for setStringArrayList");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final ListSubtypeModelView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final ListSubtypeModelView object) {
super.bind(object);
object.setStringArrayList(stringArrayList_ArrayList);
}
@Override
public void bind(final ListSubtypeModelView object, EpoxyModel previousModel) {
if (!(previousModel instanceof ListSubtypeModelViewModel_)) {
bind(object);
return;
}
ListSubtypeModelViewModel_ that = (ListSubtypeModelViewModel_) previousModel;
super.bind(object);
if ((stringArrayList_ArrayList != null ? !stringArrayList_ArrayList.equals(that.stringArrayList_ArrayList) : that.stringArrayList_ArrayList != null)) {
object.setStringArrayList(stringArrayList_ArrayList);
}
}
@Override
public void handlePostBind(final ListSubtypeModelView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ListSubtypeModelViewModel_ onBind(
OnModelBoundListener<ListSubtypeModelViewModel_, ListSubtypeModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(ListSubtypeModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ListSubtypeModelViewModel_ onUnbind(
OnModelUnboundListener<ListSubtypeModelViewModel_, ListSubtypeModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final ListSubtypeModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ListSubtypeModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ListSubtypeModelViewModel_, ListSubtypeModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final ListSubtypeModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ListSubtypeModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<ListSubtypeModelViewModel_, ListSubtypeModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Required.</i>
*
* @see ListSubtypeModelView#setStringArrayList(ArrayList<String>)
*/
public ListSubtypeModelViewModel_ stringArrayList(@NonNull ArrayList<String> stringArrayList) {
if (stringArrayList == null) {
throw new IllegalArgumentException("stringArrayList cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(0);
onMutation();
this.stringArrayList_ArrayList = stringArrayList;
return this;
}
@NonNull
public ArrayList<String> stringArrayList() {
return stringArrayList_ArrayList;
}
@Override
public ListSubtypeModelViewModel_ id(long p0) {
super.id(p0);
return this;
}
@Override
public ListSubtypeModelViewModel_ id(@Nullable Number... p0) {
super.id(p0);
return this;
}
@Override
public ListSubtypeModelViewModel_ id(long p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public ListSubtypeModelViewModel_ id(@Nullable CharSequence p0) {
super.id(p0);
return this;
}
@Override
public ListSubtypeModelViewModel_ id(@Nullable CharSequence p0, @Nullable CharSequence... p1) {
super.id(p0, p1);
return this;
}
@Override
public ListSubtypeModelViewModel_ id(@Nullable CharSequence p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public ListSubtypeModelViewModel_ layout(@LayoutRes int p0) {
super.layout(p0);
return this;
}
@Override
public ListSubtypeModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback p0) {
super.spanSizeOverride(p0);
return this;
}
@Override
public ListSubtypeModelViewModel_ show() {
super.show();
return this;
}
@Override
public ListSubtypeModelViewModel_ show(boolean p0) {
super.show(p0);
return this;
}
@Override
public ListSubtypeModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public ListSubtypeModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.stringArrayList_ArrayList = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ListSubtypeModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ListSubtypeModelViewModel_ that = (ListSubtypeModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((stringArrayList_ArrayList != null ? !stringArrayList_ArrayList.equals(that.stringArrayList_ArrayList) : that.stringArrayList_ArrayList != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (stringArrayList_ArrayList != null ? stringArrayList_ArrayList.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ListSubtypeModelViewModel_{" +
"stringArrayList_ArrayList=" + stringArrayList_ArrayList +
"}" + super.toString();
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,829 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ksp/ModelFactoryBasicModelWithAttribute_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class ModelFactoryBasicModelWithAttribute_ extends ModelFactoryBasicModelWithAttribute implements GeneratedModel<Object>, ModelFactoryBasicModelWithAttributeBuilder {
private OnModelBoundListener<ModelFactoryBasicModelWithAttribute_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelFactoryBasicModelWithAttribute_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelFactoryBasicModelWithAttribute_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelFactoryBasicModelWithAttribute_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public ModelFactoryBasicModelWithAttribute_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelFactoryBasicModelWithAttribute_ onBind(
OnModelBoundListener<ModelFactoryBasicModelWithAttribute_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelFactoryBasicModelWithAttribute_ onUnbind(
OnModelUnboundListener<ModelFactoryBasicModelWithAttribute_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelFactoryBasicModelWithAttribute_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelFactoryBasicModelWithAttribute_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelFactoryBasicModelWithAttribute_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelFactoryBasicModelWithAttribute_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public ModelFactoryBasicModelWithAttribute_ value(int value) {
onMutation();
super.value = value;
return this;
}
public int value() {
return value;
}
@Override
public ModelFactoryBasicModelWithAttribute_ id(long p0) {
super.id(p0);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ id(@Nullable Number... p0) {
super.id(p0);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ id(long p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ id(@Nullable CharSequence p0) {
super.id(p0);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ id(@Nullable CharSequence p0,
@Nullable CharSequence... p1) {
super.id(p0, p1);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ id(@Nullable CharSequence p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ layout(@LayoutRes int p0) {
super.layout(p0);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback p0) {
super.spanSizeOverride(p0);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ show() {
super.show();
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ show(boolean p0) {
super.show(p0);
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ hide() {
super.hide();
return this;
}
@Override
public ModelFactoryBasicModelWithAttribute_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.value = 0;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelFactoryBasicModelWithAttribute_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelFactoryBasicModelWithAttribute_ that = (ModelFactoryBasicModelWithAttribute_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((value != that.value)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + value;
return _result;
}
@Override
public String toString() {
return "ModelFactoryBasicModelWithAttribute_{" +
"value=" + value +
"}" + super.toString();
}
public static ModelFactoryBasicModelWithAttribute_ from(ModelProperties properties) {
ModelFactoryBasicModelWithAttribute_ model = new ModelFactoryBasicModelWithAttribute_();
model.id(properties.getId());
if (properties.has("value")) {
model.value(properties.getInt("value"));
}
return model;
}
}
| 8,830 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ksp/BasicModelWithFinalAttribute_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class BasicModelWithFinalAttribute_ extends BasicModelWithFinalAttribute implements GeneratedModel<Object>, BasicModelWithFinalAttributeBuilder {
private OnModelBoundListener<BasicModelWithFinalAttribute_, Object> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<BasicModelWithFinalAttribute_, Object> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<BasicModelWithFinalAttribute_, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<BasicModelWithFinalAttribute_, Object> onModelVisibilityChangedListener_epoxyGeneratedModel;
public BasicModelWithFinalAttribute_() {
super();
}
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final Object object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void handlePostBind(final Object object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public BasicModelWithFinalAttribute_ onBind(
OnModelBoundListener<BasicModelWithFinalAttribute_, Object> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(Object object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public BasicModelWithFinalAttribute_ onUnbind(
OnModelUnboundListener<BasicModelWithFinalAttribute_, Object> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final Object object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public BasicModelWithFinalAttribute_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<BasicModelWithFinalAttribute_, Object> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final Object object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public BasicModelWithFinalAttribute_ onVisibilityChanged(
OnModelVisibilityChangedListener<BasicModelWithFinalAttribute_, Object> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public int value() {
return value;
}
@Override
public BasicModelWithFinalAttribute_ id(long p0) {
super.id(p0);
return this;
}
@Override
public BasicModelWithFinalAttribute_ id(@Nullable Number... p0) {
super.id(p0);
return this;
}
@Override
public BasicModelWithFinalAttribute_ id(long p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public BasicModelWithFinalAttribute_ id(@Nullable CharSequence p0) {
super.id(p0);
return this;
}
@Override
public BasicModelWithFinalAttribute_ id(@Nullable CharSequence p0, @Nullable CharSequence... p1) {
super.id(p0, p1);
return this;
}
@Override
public BasicModelWithFinalAttribute_ id(@Nullable CharSequence p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public BasicModelWithFinalAttribute_ layout(@LayoutRes int p0) {
super.layout(p0);
return this;
}
@Override
public BasicModelWithFinalAttribute_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback p0) {
super.spanSizeOverride(p0);
return this;
}
@Override
public BasicModelWithFinalAttribute_ show() {
super.show();
return this;
}
@Override
public BasicModelWithFinalAttribute_ show(boolean p0) {
super.show(p0);
return this;
}
@Override
public BasicModelWithFinalAttribute_ hide() {
super.hide();
return this;
}
@Override
public BasicModelWithFinalAttribute_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof BasicModelWithFinalAttribute_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
BasicModelWithFinalAttribute_ that = (BasicModelWithFinalAttribute_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((value != that.value)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + value;
return _result;
}
@Override
public String toString() {
return "BasicModelWithFinalAttribute_{" +
"value=" + value +
"}" + super.toString();
}
}
| 8,831 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ksp/ModelFactoryBaseModelViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class ModelFactoryBaseModelViewModel_ extends EpoxyModel<ModelFactoryBaseModelView> implements GeneratedModel<ModelFactoryBaseModelView>, ModelFactoryBaseModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(1);
private OnModelBoundListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
@NonNull
private String title_String;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(0)) {
throw new IllegalStateException("A value is required for setTitle");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final ModelFactoryBaseModelView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final ModelFactoryBaseModelView object) {
super.bind(object);
object.setTitle(title_String);
}
@Override
public void bind(final ModelFactoryBaseModelView object, EpoxyModel previousModel) {
if (!(previousModel instanceof ModelFactoryBaseModelViewModel_)) {
bind(object);
return;
}
ModelFactoryBaseModelViewModel_ that = (ModelFactoryBaseModelViewModel_) previousModel;
super.bind(object);
if ((title_String != null ? !title_String.equals(that.title_String) : that.title_String != null)) {
object.setTitle(title_String);
}
}
@Override
public void handlePostBind(final ModelFactoryBaseModelView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelFactoryBaseModelViewModel_ onBind(
OnModelBoundListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(ModelFactoryBaseModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public ModelFactoryBaseModelViewModel_ onUnbind(
OnModelUnboundListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState,
final ModelFactoryBaseModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelFactoryBaseModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final ModelFactoryBaseModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public ModelFactoryBaseModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<ModelFactoryBaseModelViewModel_, ModelFactoryBaseModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Required.</i>
*
* @see ModelFactoryBaseModelView#setTitle(String)
*/
public ModelFactoryBaseModelViewModel_ title(@NonNull String title) {
if (title == null) {
throw new IllegalArgumentException("title cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(0);
onMutation();
this.title_String = title;
return this;
}
@NonNull
public String title() {
return title_String;
}
@Override
public ModelFactoryBaseModelViewModel_ id(long p0) {
super.id(p0);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ id(@Nullable Number... p0) {
super.id(p0);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ id(long p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ id(@Nullable CharSequence p0) {
super.id(p0);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ id(@Nullable CharSequence p0,
@Nullable CharSequence... p1) {
super.id(p0, p1);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ id(@Nullable CharSequence p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ layout(@LayoutRes int p0) {
super.layout(p0);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback p0) {
super.spanSizeOverride(p0);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ show() {
super.show();
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ show(boolean p0) {
super.show(p0);
return this;
}
@Override
public ModelFactoryBaseModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public ModelFactoryBaseModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.title_String = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ModelFactoryBaseModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
ModelFactoryBaseModelViewModel_ that = (ModelFactoryBaseModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((title_String != null ? !title_String.equals(that.title_String) : that.title_String != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (title_String != null ? title_String.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "ModelFactoryBaseModelViewModel_{" +
"title_String=" + title_String +
"}" + super.toString();
}
public static ModelFactoryBaseModelViewModel_ from(ModelProperties properties) {
ModelFactoryBaseModelViewModel_ model = new ModelFactoryBaseModelViewModel_();
model.id(properties.getId());
if (properties.has("title")) {
model.title(properties.getString("title"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,832 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ksp/CallbackPropModelViewModel_.java | package com.airbnb.epoxy;
import android.view.View;
import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
/**
* Generated file. Do not modify!
*/
public class CallbackPropModelViewModel_ extends EpoxyModel<CallbackPropModelView> implements GeneratedModel<CallbackPropModelView>, CallbackPropModelViewModelBuilder {
private OnModelBoundListener<CallbackPropModelViewModel_, CallbackPropModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<CallbackPropModelViewModel_, CallbackPropModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<CallbackPropModelViewModel_, CallbackPropModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<CallbackPropModelViewModel_, CallbackPropModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
@Nullable
private View.OnClickListener onClickListener_OnClickListener = (View.OnClickListener) null;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final CallbackPropModelView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final CallbackPropModelView object) {
super.bind(object);
object.setOnClickListener(onClickListener_OnClickListener);
}
@Override
public void bind(final CallbackPropModelView object, EpoxyModel previousModel) {
if (!(previousModel instanceof CallbackPropModelViewModel_)) {
bind(object);
return;
}
CallbackPropModelViewModel_ that = (CallbackPropModelViewModel_) previousModel;
super.bind(object);
if (((onClickListener_OnClickListener == null) != (that.onClickListener_OnClickListener == null))) {
object.setOnClickListener(onClickListener_OnClickListener);
}
}
@Override
public void handlePostBind(final CallbackPropModelView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public CallbackPropModelViewModel_ onBind(
OnModelBoundListener<CallbackPropModelViewModel_, CallbackPropModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(CallbackPropModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
object.setOnClickListener((View.OnClickListener) null);
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public CallbackPropModelViewModel_ onUnbind(
OnModelUnboundListener<CallbackPropModelViewModel_, CallbackPropModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final CallbackPropModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public CallbackPropModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<CallbackPropModelViewModel_, CallbackPropModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final CallbackPropModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public CallbackPropModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<CallbackPropModelViewModel_, CallbackPropModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set
*/
public CallbackPropModelViewModel_ onClickListener(
@Nullable final OnModelClickListener<CallbackPropModelViewModel_, CallbackPropModelView> onClickListener) {
onMutation();
if (onClickListener == null) {
this.onClickListener_OnClickListener = null;
}
else {
this.onClickListener_OnClickListener = new WrappedEpoxyModelClickListener<>(onClickListener);
}
return this;
}
/**
* <i>Optional</i>: Default value is (View.OnClickListener) null
*
* @see CallbackPropModelView#setOnClickListener(View.OnClickListener)
*/
public CallbackPropModelViewModel_ onClickListener(
@Nullable View.OnClickListener onClickListener) {
onMutation();
this.onClickListener_OnClickListener = onClickListener;
return this;
}
@Nullable
public View.OnClickListener onClickListener() {
return onClickListener_OnClickListener;
}
@Override
public CallbackPropModelViewModel_ id(long p0) {
super.id(p0);
return this;
}
@Override
public CallbackPropModelViewModel_ id(@Nullable Number... p0) {
super.id(p0);
return this;
}
@Override
public CallbackPropModelViewModel_ id(long p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public CallbackPropModelViewModel_ id(@Nullable CharSequence p0) {
super.id(p0);
return this;
}
@Override
public CallbackPropModelViewModel_ id(@Nullable CharSequence p0, @Nullable CharSequence... p1) {
super.id(p0, p1);
return this;
}
@Override
public CallbackPropModelViewModel_ id(@Nullable CharSequence p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public CallbackPropModelViewModel_ layout(@LayoutRes int p0) {
super.layout(p0);
return this;
}
@Override
public CallbackPropModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback p0) {
super.spanSizeOverride(p0);
return this;
}
@Override
public CallbackPropModelViewModel_ show() {
super.show();
return this;
}
@Override
public CallbackPropModelViewModel_ show(boolean p0) {
super.show(p0);
return this;
}
@Override
public CallbackPropModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public CallbackPropModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
this.onClickListener_OnClickListener = (View.OnClickListener) null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof CallbackPropModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
CallbackPropModelViewModel_ that = (CallbackPropModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onClickListener_OnClickListener == null) != (that.onClickListener_OnClickListener == null))) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onClickListener_OnClickListener != null ? 1 : 0);
return _result;
}
@Override
public String toString() {
return "CallbackPropModelViewModel_{" +
"onClickListener_OnClickListener=" + onClickListener_OnClickListener +
"}" + super.toString();
}
public static CallbackPropModelViewModel_ from(ModelProperties properties) {
CallbackPropModelViewModel_ model = new CallbackPropModelViewModel_();
model.id(properties.getId());
if (properties.has("onClickListener")) {
model.onClickListener(properties.getOnClickListener("onClickListener"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,833 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ksp/TextPropModelViewModel_.java | package com.airbnb.epoxy;
import android.content.Context;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.PluralsRes;
import androidx.annotation.StringRes;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class TextPropModelViewModel_ extends EpoxyModel<TextPropModelView> implements GeneratedModel<TextPropModelView>, TextPropModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(1);
private OnModelBoundListener<TextPropModelViewModel_, TextPropModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<TextPropModelViewModel_, TextPropModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<TextPropModelViewModel_, TextPropModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<TextPropModelViewModel_, TextPropModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
private StringAttributeData title_StringAttributeData = new StringAttributeData();
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(0)) {
throw new IllegalStateException("A value is required for setTitle");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final TextPropModelView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final TextPropModelView object) {
super.bind(object);
object.setTitle(title_StringAttributeData.toString(object.getContext()));
}
@Override
public void bind(final TextPropModelView object, EpoxyModel previousModel) {
if (!(previousModel instanceof TextPropModelViewModel_)) {
bind(object);
return;
}
TextPropModelViewModel_ that = (TextPropModelViewModel_) previousModel;
super.bind(object);
if ((title_StringAttributeData != null ? !title_StringAttributeData.equals(that.title_StringAttributeData) : that.title_StringAttributeData != null)) {
object.setTitle(title_StringAttributeData.toString(object.getContext()));
}
}
@Override
public void handlePostBind(final TextPropModelView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public TextPropModelViewModel_ onBind(
OnModelBoundListener<TextPropModelViewModel_, TextPropModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(TextPropModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public TextPropModelViewModel_ onUnbind(
OnModelUnboundListener<TextPropModelViewModel_, TextPropModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final TextPropModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public TextPropModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<TextPropModelViewModel_, TextPropModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final TextPropModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public TextPropModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<TextPropModelViewModel_, TextPropModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
public CharSequence getTitle(Context context) {
return title_StringAttributeData.toString(context);
}
/**
* <i>Required.</i>
*
* @see TextPropModelView#setTitle(CharSequence)
*/
public TextPropModelViewModel_ title(@NonNull CharSequence title) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
if (title == null) {
throw new IllegalArgumentException("title cannot be null");
}
title_StringAttributeData.setValue(title);
return this;
}
/**
* Throws if a value <= 0 is set.
* <p>
* <i>Required.</i>
*
* @see TextPropModelView#setTitle(CharSequence)
*/
public TextPropModelViewModel_ title(@StringRes int stringRes) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
title_StringAttributeData.setValue(stringRes);
return this;
}
/**
* Throws if a value <= 0 is set.
* <p>
* <i>Required.</i>
*
* @see TextPropModelView#setTitle(CharSequence)
*/
public TextPropModelViewModel_ title(@StringRes int stringRes, Object... formatArgs) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
title_StringAttributeData.setValue(stringRes, formatArgs);
return this;
}
/**
* Throws if a value <= 0 is set.
* <p>
* <i>Required.</i>
*
* @see TextPropModelView#setTitle(CharSequence)
*/
public TextPropModelViewModel_ titleQuantityRes(@PluralsRes int pluralRes, int quantity,
Object... formatArgs) {
onMutation();
assignedAttributes_epoxyGeneratedModel.set(0);
title_StringAttributeData.setValue(pluralRes, quantity, formatArgs);
return this;
}
@Override
public TextPropModelViewModel_ id(long p0) {
super.id(p0);
return this;
}
@Override
public TextPropModelViewModel_ id(@Nullable Number... p0) {
super.id(p0);
return this;
}
@Override
public TextPropModelViewModel_ id(long p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public TextPropModelViewModel_ id(@Nullable CharSequence p0) {
super.id(p0);
return this;
}
@Override
public TextPropModelViewModel_ id(@Nullable CharSequence p0, @Nullable CharSequence... p1) {
super.id(p0, p1);
return this;
}
@Override
public TextPropModelViewModel_ id(@Nullable CharSequence p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public TextPropModelViewModel_ layout(@LayoutRes int p0) {
super.layout(p0);
return this;
}
@Override
public TextPropModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback p0) {
super.spanSizeOverride(p0);
return this;
}
@Override
public TextPropModelViewModel_ show() {
super.show();
return this;
}
@Override
public TextPropModelViewModel_ show(boolean p0) {
super.show(p0);
return this;
}
@Override
public TextPropModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public TextPropModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.title_StringAttributeData = new StringAttributeData();
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof TextPropModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
TextPropModelViewModel_ that = (TextPropModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((title_StringAttributeData != null ? !title_StringAttributeData.equals(that.title_StringAttributeData) : that.title_StringAttributeData != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (title_StringAttributeData != null ? title_StringAttributeData.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "TextPropModelViewModel_{" +
"title_StringAttributeData=" + title_StringAttributeData +
"}" + super.toString();
}
public static TextPropModelViewModel_ from(ModelProperties properties) {
TextPropModelViewModel_ model = new TextPropModelViewModel_();
model.id(properties.getId());
if (properties.has("title")) {
model.title(properties.getString("title"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,834 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ksp/AllTypesModelViewModel_.java | package com.airbnb.epoxy;
import android.view.View;
import androidx.annotation.DrawableRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes;
import java.lang.Boolean;
import java.lang.CharSequence;
import java.lang.Double;
import java.lang.IllegalArgumentException;
import java.lang.IllegalStateException;
import java.lang.Integer;
import java.lang.Long;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
import java.util.List;
/**
* Generated file. Do not modify!
*/
public class AllTypesModelViewModel_ extends EpoxyModel<AllTypesModelView> implements GeneratedModel<AllTypesModelView>, AllTypesModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(15);
private OnModelBoundListener<AllTypesModelViewModel_, AllTypesModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<AllTypesModelViewModel_, AllTypesModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<AllTypesModelViewModel_, AllTypesModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<AllTypesModelViewModel_, AllTypesModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
private boolean booleanValue_Boolean = false;
/**
* Bitset index: 1
*/
@NonNull
private Boolean boxedBooleanValue_Boolean;
/**
* Bitset index: 2
*/
@NonNull
private CharSequence charSequenceValue_CharSequence;
/**
* Bitset index: 3
*/
@NonNull
private Double boxedDoubleValue_Double;
private double doubleValue_Double = 0.0d;
@DrawableRes
private int drawableRes_Int = 0;
/**
* Bitset index: 6
*/
@NonNull
private List<? extends EpoxyModel<?>> epoxyModelList_List;
private int intValue_Int = 0;
/**
* Bitset index: 8
*/
@NonNull
private Integer boxedIntValue_Integer;
private long longValue_Long = 0L;
/**
* Bitset index: 10
*/
@NonNull
private Long boxedLongValue_Long;
/**
* Bitset index: 11
*/
@NonNull
private View.OnClickListener onClickListener_OnClickListener;
@RawRes
private int rawRes_Int = 0;
/**
* Bitset index: 13
*/
@NonNull
private String stringValue_String;
/**
* Bitset index: 14
*/
@NonNull
private List<String> stringList_List;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
if (!assignedAttributes_epoxyGeneratedModel.get(8)) {
throw new IllegalStateException("A value is required for setBoxedIntValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(1)) {
throw new IllegalStateException("A value is required for setBoxedBooleanValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(3)) {
throw new IllegalStateException("A value is required for setBoxedDoubleValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(6)) {
throw new IllegalStateException("A value is required for setEpoxyModelList");
}
if (!assignedAttributes_epoxyGeneratedModel.get(10)) {
throw new IllegalStateException("A value is required for setBoxedLongValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(14)) {
throw new IllegalStateException("A value is required for setStringList");
}
if (!assignedAttributes_epoxyGeneratedModel.get(13)) {
throw new IllegalStateException("A value is required for setStringValue");
}
if (!assignedAttributes_epoxyGeneratedModel.get(11)) {
throw new IllegalStateException("A value is required for setOnClickListener");
}
if (!assignedAttributes_epoxyGeneratedModel.get(2)) {
throw new IllegalStateException("A value is required for setCharSequenceValue");
}
}
@Override
public void handlePreBind(final EpoxyViewHolder holder, final AllTypesModelView object,
final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final AllTypesModelView object) {
super.bind(object);
object.setBooleanValue(booleanValue_Boolean);
object.setBoxedIntValue(boxedIntValue_Integer);
object.setBoxedBooleanValue(boxedBooleanValue_Boolean);
object.setBoxedDoubleValue(boxedDoubleValue_Double);
object.setEpoxyModelList(epoxyModelList_List);
object.setBoxedLongValue(boxedLongValue_Long);
object.setLongValue(longValue_Long);
object.setStringList(stringList_List);
object.setStringValue(stringValue_String);
object.setOnClickListener(onClickListener_OnClickListener);
object.setIntValue(intValue_Int);
object.setDrawableRes(drawableRes_Int);
object.setDoubleValue(doubleValue_Double);
object.setRawRes(rawRes_Int);
object.setCharSequenceValue(charSequenceValue_CharSequence);
}
@Override
public void bind(final AllTypesModelView object, EpoxyModel previousModel) {
if (!(previousModel instanceof AllTypesModelViewModel_)) {
bind(object);
return;
}
AllTypesModelViewModel_ that = (AllTypesModelViewModel_) previousModel;
super.bind(object);
if ((booleanValue_Boolean != that.booleanValue_Boolean)) {
object.setBooleanValue(booleanValue_Boolean);
}
if ((boxedIntValue_Integer != null ? !boxedIntValue_Integer.equals(that.boxedIntValue_Integer) : that.boxedIntValue_Integer != null)) {
object.setBoxedIntValue(boxedIntValue_Integer);
}
if ((boxedBooleanValue_Boolean != null ? !boxedBooleanValue_Boolean.equals(that.boxedBooleanValue_Boolean) : that.boxedBooleanValue_Boolean != null)) {
object.setBoxedBooleanValue(boxedBooleanValue_Boolean);
}
if ((boxedDoubleValue_Double != null ? !boxedDoubleValue_Double.equals(that.boxedDoubleValue_Double) : that.boxedDoubleValue_Double != null)) {
object.setBoxedDoubleValue(boxedDoubleValue_Double);
}
if ((epoxyModelList_List != null ? !epoxyModelList_List.equals(that.epoxyModelList_List) : that.epoxyModelList_List != null)) {
object.setEpoxyModelList(epoxyModelList_List);
}
if ((boxedLongValue_Long != null ? !boxedLongValue_Long.equals(that.boxedLongValue_Long) : that.boxedLongValue_Long != null)) {
object.setBoxedLongValue(boxedLongValue_Long);
}
if ((longValue_Long != that.longValue_Long)) {
object.setLongValue(longValue_Long);
}
if ((stringList_List != null ? !stringList_List.equals(that.stringList_List) : that.stringList_List != null)) {
object.setStringList(stringList_List);
}
if ((stringValue_String != null ? !stringValue_String.equals(that.stringValue_String) : that.stringValue_String != null)) {
object.setStringValue(stringValue_String);
}
if (((onClickListener_OnClickListener == null) != (that.onClickListener_OnClickListener == null))) {
object.setOnClickListener(onClickListener_OnClickListener);
}
if ((intValue_Int != that.intValue_Int)) {
object.setIntValue(intValue_Int);
}
if ((drawableRes_Int != that.drawableRes_Int)) {
object.setDrawableRes(drawableRes_Int);
}
if ((Double.compare(that.doubleValue_Double, doubleValue_Double) != 0)) {
object.setDoubleValue(doubleValue_Double);
}
if ((rawRes_Int != that.rawRes_Int)) {
object.setRawRes(rawRes_Int);
}
if ((charSequenceValue_CharSequence != null ? !charSequenceValue_CharSequence.equals(that.charSequenceValue_CharSequence) : that.charSequenceValue_CharSequence != null)) {
object.setCharSequenceValue(charSequenceValue_CharSequence);
}
}
@Override
public void handlePostBind(final AllTypesModelView object, int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public AllTypesModelViewModel_ onBind(
OnModelBoundListener<AllTypesModelViewModel_, AllTypesModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(AllTypesModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public AllTypesModelViewModel_ onUnbind(
OnModelUnboundListener<AllTypesModelViewModel_, AllTypesModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState, final AllTypesModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public AllTypesModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<AllTypesModelViewModel_, AllTypesModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth, final AllTypesModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public AllTypesModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<AllTypesModelViewModel_, AllTypesModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Optional</i>: Default value is false
*
* @see AllTypesModelView#setBooleanValue(boolean)
*/
public AllTypesModelViewModel_ booleanValue(boolean booleanValue) {
onMutation();
this.booleanValue_Boolean = booleanValue;
return this;
}
public boolean booleanValue() {
return booleanValue_Boolean;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setBoxedBooleanValue(Boolean)
*/
public AllTypesModelViewModel_ boxedBooleanValue(@NonNull Boolean boxedBooleanValue) {
if (boxedBooleanValue == null) {
throw new IllegalArgumentException("boxedBooleanValue cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(1);
onMutation();
this.boxedBooleanValue_Boolean = boxedBooleanValue;
return this;
}
@NonNull
public Boolean boxedBooleanValue() {
return boxedBooleanValue_Boolean;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setCharSequenceValue(CharSequence)
*/
public AllTypesModelViewModel_ charSequenceValue(@NonNull CharSequence charSequenceValue) {
if (charSequenceValue == null) {
throw new IllegalArgumentException("charSequenceValue cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(2);
onMutation();
this.charSequenceValue_CharSequence = charSequenceValue;
return this;
}
@NonNull
public CharSequence charSequenceValue() {
return charSequenceValue_CharSequence;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setBoxedDoubleValue(Double)
*/
public AllTypesModelViewModel_ boxedDoubleValue(@NonNull Double boxedDoubleValue) {
if (boxedDoubleValue == null) {
throw new IllegalArgumentException("boxedDoubleValue cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(3);
onMutation();
this.boxedDoubleValue_Double = boxedDoubleValue;
return this;
}
@NonNull
public Double boxedDoubleValue() {
return boxedDoubleValue_Double;
}
/**
* <i>Optional</i>: Default value is 0.0d
*
* @see AllTypesModelView#setDoubleValue(double)
*/
public AllTypesModelViewModel_ doubleValue(double doubleValue) {
onMutation();
this.doubleValue_Double = doubleValue;
return this;
}
public double doubleValue() {
return doubleValue_Double;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see AllTypesModelView#setDrawableRes(int)
*/
public AllTypesModelViewModel_ drawableRes(@DrawableRes int drawableRes) {
onMutation();
this.drawableRes_Int = drawableRes;
return this;
}
@DrawableRes
public int drawableRes() {
return drawableRes_Int;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setEpoxyModelList(List<? extends EpoxyModel<?>>)
*/
public AllTypesModelViewModel_ epoxyModelList(
@NonNull List<? extends EpoxyModel<?>> epoxyModelList) {
if (epoxyModelList == null) {
throw new IllegalArgumentException("epoxyModelList cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(6);
onMutation();
this.epoxyModelList_List = epoxyModelList;
return this;
}
@NonNull
public List<? extends EpoxyModel<?>> epoxyModelList() {
return epoxyModelList_List;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see AllTypesModelView#setIntValue(int)
*/
public AllTypesModelViewModel_ intValue(int intValue) {
onMutation();
this.intValue_Int = intValue;
return this;
}
public int intValue() {
return intValue_Int;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setBoxedIntValue(Integer)
*/
public AllTypesModelViewModel_ boxedIntValue(@NonNull Integer boxedIntValue) {
if (boxedIntValue == null) {
throw new IllegalArgumentException("boxedIntValue cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(8);
onMutation();
this.boxedIntValue_Integer = boxedIntValue;
return this;
}
@NonNull
public Integer boxedIntValue() {
return boxedIntValue_Integer;
}
/**
* <i>Optional</i>: Default value is 0L
*
* @see AllTypesModelView#setLongValue(long)
*/
public AllTypesModelViewModel_ longValue(long longValue) {
onMutation();
this.longValue_Long = longValue;
return this;
}
public long longValue() {
return longValue_Long;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setBoxedLongValue(Long)
*/
public AllTypesModelViewModel_ boxedLongValue(@NonNull Long boxedLongValue) {
if (boxedLongValue == null) {
throw new IllegalArgumentException("boxedLongValue cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(10);
onMutation();
this.boxedLongValue_Long = boxedLongValue;
return this;
}
@NonNull
public Long boxedLongValue() {
return boxedLongValue_Long;
}
/**
* Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set
*/
public AllTypesModelViewModel_ onClickListener(
@NonNull final OnModelClickListener<AllTypesModelViewModel_, AllTypesModelView> onClickListener) {
assignedAttributes_epoxyGeneratedModel.set(11);
onMutation();
if (onClickListener == null) {
this.onClickListener_OnClickListener = null;
}
else {
this.onClickListener_OnClickListener = new WrappedEpoxyModelClickListener<>(onClickListener);
}
return this;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setOnClickListener(View.OnClickListener)
*/
public AllTypesModelViewModel_ onClickListener(@NonNull View.OnClickListener onClickListener) {
if (onClickListener == null) {
throw new IllegalArgumentException("onClickListener cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(11);
onMutation();
this.onClickListener_OnClickListener = onClickListener;
return this;
}
@NonNull
public View.OnClickListener onClickListener() {
return onClickListener_OnClickListener;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see AllTypesModelView#setRawRes(int)
*/
public AllTypesModelViewModel_ rawRes(@RawRes int rawRes) {
onMutation();
this.rawRes_Int = rawRes;
return this;
}
@RawRes
public int rawRes() {
return rawRes_Int;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setStringValue(String)
*/
public AllTypesModelViewModel_ stringValue(@NonNull String stringValue) {
if (stringValue == null) {
throw new IllegalArgumentException("stringValue cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(13);
onMutation();
this.stringValue_String = stringValue;
return this;
}
@NonNull
public String stringValue() {
return stringValue_String;
}
/**
* <i>Required.</i>
*
* @see AllTypesModelView#setStringList(List<String>)
*/
public AllTypesModelViewModel_ stringList(@NonNull List<String> stringList) {
if (stringList == null) {
throw new IllegalArgumentException("stringList cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(14);
onMutation();
this.stringList_List = stringList;
return this;
}
@NonNull
public List<String> stringList() {
return stringList_List;
}
@Override
public AllTypesModelViewModel_ id(long p0) {
super.id(p0);
return this;
}
@Override
public AllTypesModelViewModel_ id(@Nullable Number... p0) {
super.id(p0);
return this;
}
@Override
public AllTypesModelViewModel_ id(long p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public AllTypesModelViewModel_ id(@Nullable CharSequence p0) {
super.id(p0);
return this;
}
@Override
public AllTypesModelViewModel_ id(@Nullable CharSequence p0, @Nullable CharSequence... p1) {
super.id(p0, p1);
return this;
}
@Override
public AllTypesModelViewModel_ id(@Nullable CharSequence p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public AllTypesModelViewModel_ layout(@LayoutRes int p0) {
super.layout(p0);
return this;
}
@Override
public AllTypesModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback p0) {
super.spanSizeOverride(p0);
return this;
}
@Override
public AllTypesModelViewModel_ show() {
super.show();
return this;
}
@Override
public AllTypesModelViewModel_ show(boolean p0) {
super.show(p0);
return this;
}
@Override
public AllTypesModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public AllTypesModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.booleanValue_Boolean = false;
this.boxedBooleanValue_Boolean = null;
this.charSequenceValue_CharSequence = null;
this.boxedDoubleValue_Double = null;
this.doubleValue_Double = 0.0d;
this.drawableRes_Int = 0;
this.epoxyModelList_List = null;
this.intValue_Int = 0;
this.boxedIntValue_Integer = null;
this.longValue_Long = 0L;
this.boxedLongValue_Long = null;
this.onClickListener_OnClickListener = null;
this.rawRes_Int = 0;
this.stringValue_String = null;
this.stringList_List = null;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof AllTypesModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
AllTypesModelViewModel_ that = (AllTypesModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((booleanValue_Boolean != that.booleanValue_Boolean)) {
return false;
}
if ((boxedBooleanValue_Boolean != null ? !boxedBooleanValue_Boolean.equals(that.boxedBooleanValue_Boolean) : that.boxedBooleanValue_Boolean != null)) {
return false;
}
if ((charSequenceValue_CharSequence != null ? !charSequenceValue_CharSequence.equals(that.charSequenceValue_CharSequence) : that.charSequenceValue_CharSequence != null)) {
return false;
}
if ((boxedDoubleValue_Double != null ? !boxedDoubleValue_Double.equals(that.boxedDoubleValue_Double) : that.boxedDoubleValue_Double != null)) {
return false;
}
if ((Double.compare(that.doubleValue_Double, doubleValue_Double) != 0)) {
return false;
}
if ((drawableRes_Int != that.drawableRes_Int)) {
return false;
}
if ((epoxyModelList_List != null ? !epoxyModelList_List.equals(that.epoxyModelList_List) : that.epoxyModelList_List != null)) {
return false;
}
if ((intValue_Int != that.intValue_Int)) {
return false;
}
if ((boxedIntValue_Integer != null ? !boxedIntValue_Integer.equals(that.boxedIntValue_Integer) : that.boxedIntValue_Integer != null)) {
return false;
}
if ((longValue_Long != that.longValue_Long)) {
return false;
}
if ((boxedLongValue_Long != null ? !boxedLongValue_Long.equals(that.boxedLongValue_Long) : that.boxedLongValue_Long != null)) {
return false;
}
if (((onClickListener_OnClickListener == null) != (that.onClickListener_OnClickListener == null))) {
return false;
}
if ((rawRes_Int != that.rawRes_Int)) {
return false;
}
if ((stringValue_String != null ? !stringValue_String.equals(that.stringValue_String) : that.stringValue_String != null)) {
return false;
}
if ((stringList_List != null ? !stringList_List.equals(that.stringList_List) : that.stringList_List != null)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
long temp;
_result = 31 * _result + (booleanValue_Boolean ? 1 : 0);
_result = 31 * _result + (boxedBooleanValue_Boolean != null ? boxedBooleanValue_Boolean.hashCode() : 0);
_result = 31 * _result + (charSequenceValue_CharSequence != null ? charSequenceValue_CharSequence.hashCode() : 0);
_result = 31 * _result + (boxedDoubleValue_Double != null ? boxedDoubleValue_Double.hashCode() : 0);
temp = Double.doubleToLongBits(doubleValue_Double);
_result = 31 * _result + (int) (temp ^ (temp >>> 32));
_result = 31 * _result + drawableRes_Int;
_result = 31 * _result + (epoxyModelList_List != null ? epoxyModelList_List.hashCode() : 0);
_result = 31 * _result + intValue_Int;
_result = 31 * _result + (boxedIntValue_Integer != null ? boxedIntValue_Integer.hashCode() : 0);
_result = 31 * _result + (int) (longValue_Long ^ (longValue_Long >>> 32));
_result = 31 * _result + (boxedLongValue_Long != null ? boxedLongValue_Long.hashCode() : 0);
_result = 31 * _result + (onClickListener_OnClickListener != null ? 1 : 0);
_result = 31 * _result + rawRes_Int;
_result = 31 * _result + (stringValue_String != null ? stringValue_String.hashCode() : 0);
_result = 31 * _result + (stringList_List != null ? stringList_List.hashCode() : 0);
return _result;
}
@Override
public String toString() {
return "AllTypesModelViewModel_{" +
"booleanValue_Boolean=" + booleanValue_Boolean +
", boxedBooleanValue_Boolean=" + boxedBooleanValue_Boolean +
", charSequenceValue_CharSequence=" + charSequenceValue_CharSequence +
", boxedDoubleValue_Double=" + boxedDoubleValue_Double +
", doubleValue_Double=" + doubleValue_Double +
", drawableRes_Int=" + drawableRes_Int +
", epoxyModelList_List=" + epoxyModelList_List +
", intValue_Int=" + intValue_Int +
", boxedIntValue_Integer=" + boxedIntValue_Integer +
", longValue_Long=" + longValue_Long +
", boxedLongValue_Long=" + boxedLongValue_Long +
", onClickListener_OnClickListener=" + onClickListener_OnClickListener +
", rawRes_Int=" + rawRes_Int +
", stringValue_String=" + stringValue_String +
", stringList_List=" + stringList_List +
"}" + super.toString();
}
public static AllTypesModelViewModel_ from(ModelProperties properties) {
AllTypesModelViewModel_ model = new AllTypesModelViewModel_();
model.id(properties.getId());
if (properties.has("booleanValue")) {
model.booleanValue(properties.getBoolean("booleanValue"));
}
if (properties.has("boxedBooleanValue")) {
model.boxedBooleanValue(properties.getBoolean("boxedBooleanValue"));
}
if (properties.has("charSequenceValue")) {
model.charSequenceValue(properties.getString("charSequenceValue"));
}
if (properties.has("boxedDoubleValue")) {
model.boxedDoubleValue(properties.getDouble("boxedDoubleValue"));
}
if (properties.has("doubleValue")) {
model.doubleValue(properties.getDouble("doubleValue"));
}
if (properties.has("drawableRes")) {
model.drawableRes(properties.getDrawableRes("drawableRes"));
}
if (properties.has("epoxyModelList")) {
model.epoxyModelList(properties.getEpoxyModelList("epoxyModelList"));
}
if (properties.has("intValue")) {
model.intValue(properties.getInt("intValue"));
}
if (properties.has("boxedIntValue")) {
model.boxedIntValue(properties.getInt("boxedIntValue"));
}
if (properties.has("longValue")) {
model.longValue(properties.getLong("longValue"));
}
if (properties.has("boxedLongValue")) {
model.boxedLongValue(properties.getLong("boxedLongValue"));
}
if (properties.has("onClickListener")) {
model.onClickListener(properties.getOnClickListener("onClickListener"));
}
if (properties.has("rawRes")) {
model.rawRes(properties.getRawRes("rawRes"));
}
if (properties.has("stringValue")) {
model.stringValue(properties.getString("stringValue"));
}
if (properties.has("stringList")) {
model.stringList(properties.getStringList("stringList"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,835 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources | Create_ds/epoxy/epoxy-modelfactorytest/src/test/resources/ksp/GroupPropMultipleSupportedAttributeSameNameModelViewModel_.java | package com.airbnb.epoxy;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.CharSequence;
import java.lang.IllegalArgumentException;
import java.lang.Number;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.BitSet;
/**
* Generated file. Do not modify!
*/
public class GroupPropMultipleSupportedAttributeSameNameModelViewModel_ extends EpoxyModel<GroupPropMultipleSupportedAttributeSameNameModelView> implements GeneratedModel<GroupPropMultipleSupportedAttributeSameNameModelView>, GroupPropMultipleSupportedAttributeSameNameModelViewModelBuilder {
private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(2);
private OnModelBoundListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> onModelBoundListener_epoxyGeneratedModel;
private OnModelUnboundListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> onModelUnboundListener_epoxyGeneratedModel;
private OnModelVisibilityStateChangedListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> onModelVisibilityStateChangedListener_epoxyGeneratedModel;
private OnModelVisibilityChangedListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> onModelVisibilityChangedListener_epoxyGeneratedModel;
/**
* Bitset index: 0
*/
@NonNull
private String titleString_String;
/**
* Bitset index: 1
*/
private int titleInt_Int = 0;
@Override
public void addTo(EpoxyController controller) {
super.addTo(controller);
addWithDebugValidation(controller);
}
@Override
public void handlePreBind(final EpoxyViewHolder holder,
final GroupPropMultipleSupportedAttributeSameNameModelView object, final int position) {
validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position);
}
@Override
public void bind(final GroupPropMultipleSupportedAttributeSameNameModelView object) {
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
object.setTitleString(titleString_String);
}
else if (assignedAttributes_epoxyGeneratedModel.get(1)) {
object.setTitleInt(titleInt_Int);
}
else {
object.setTitleInt(titleInt_Int);
}
}
@Override
public void bind(final GroupPropMultipleSupportedAttributeSameNameModelView object,
EpoxyModel previousModel) {
if (!(previousModel instanceof GroupPropMultipleSupportedAttributeSameNameModelViewModel_)) {
bind(object);
return;
}
GroupPropMultipleSupportedAttributeSameNameModelViewModel_ that = (GroupPropMultipleSupportedAttributeSameNameModelViewModel_) previousModel;
super.bind(object);
if (assignedAttributes_epoxyGeneratedModel.get(0)) {
if (!that.assignedAttributes_epoxyGeneratedModel.get(0) || (titleString_String != null ? !titleString_String.equals(that.titleString_String) : that.titleString_String != null)) {
object.setTitleString(titleString_String);
}
}
else if (assignedAttributes_epoxyGeneratedModel.get(1)) {
if ((titleInt_Int != that.titleInt_Int)) {
object.setTitleInt(titleInt_Int);
}
}
// A value was not set so we should use the default value, but we only need to set it if the previous model had a custom value set.
else if (that.assignedAttributes_epoxyGeneratedModel.get(0) || that.assignedAttributes_epoxyGeneratedModel.get(1)) {
object.setTitleInt(titleInt_Int);
}
}
@Override
public void handlePostBind(final GroupPropMultipleSupportedAttributeSameNameModelView object,
int position) {
if (onModelBoundListener_epoxyGeneratedModel != null) {
onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position);
}
validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position);
}
/**
* Register a listener that will be called when this model is bound to a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onBind(
OnModelBoundListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> listener) {
onMutation();
this.onModelBoundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void unbind(GroupPropMultipleSupportedAttributeSameNameModelView object) {
super.unbind(object);
if (onModelUnboundListener_epoxyGeneratedModel != null) {
onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object);
}
}
/**
* Register a listener that will be called when this model is unbound from a view.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
* <p>
* You may clear the listener by setting a null value, or by calling {@link #reset()}
*/
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onUnbind(
OnModelUnboundListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> listener) {
onMutation();
this.onModelUnboundListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityStateChanged(int visibilityState,
final GroupPropMultipleSupportedAttributeSameNameModelView object) {
if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState);
}
super.onVisibilityStateChanged(visibilityState, object);
}
/**
* Register a listener that will be called when this model visibility state has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onVisibilityStateChanged(
OnModelVisibilityStateChangedListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> listener) {
onMutation();
this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener;
return this;
}
@Override
public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth,
int visibleHeight, int visibleWidth,
final GroupPropMultipleSupportedAttributeSameNameModelView object) {
if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) {
onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth);
}
super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object);
}
/**
* Register a listener that will be called when this model visibility has changed.
* <p>
* The listener will contribute to this model's hashCode state per the {@link
* com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.
*/
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onVisibilityChanged(
OnModelVisibilityChangedListener<GroupPropMultipleSupportedAttributeSameNameModelViewModel_, GroupPropMultipleSupportedAttributeSameNameModelView> listener) {
onMutation();
this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener;
return this;
}
/**
* <i>Required.</i>
*
* @see GroupPropMultipleSupportedAttributeSameNameModelView#setTitleString(String)
*/
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ titleString(
@NonNull String titleString) {
if (titleString == null) {
throw new IllegalArgumentException("titleString cannot be null");
}
assignedAttributes_epoxyGeneratedModel.set(0);
assignedAttributes_epoxyGeneratedModel.clear(1);
this.titleInt_Int = 0;
onMutation();
this.titleString_String = titleString;
return this;
}
@NonNull
public String titleStringString() {
return titleString_String;
}
/**
* <i>Optional</i>: Default value is 0
*
* @see GroupPropMultipleSupportedAttributeSameNameModelView#setTitleInt(int)
*/
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ titleInt(int titleInt) {
assignedAttributes_epoxyGeneratedModel.set(1);
assignedAttributes_epoxyGeneratedModel.clear(0);
this.titleString_String = null;
onMutation();
this.titleInt_Int = titleInt;
return this;
}
public int titleIntInt() {
return titleInt_Int;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(long p0) {
super.id(p0);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(@Nullable Number... p0) {
super.id(p0);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(long p0, long p1) {
super.id(p0, p1);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(@Nullable CharSequence p0) {
super.id(p0);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(@Nullable CharSequence p0,
@Nullable CharSequence... p1) {
super.id(p0, p1);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(@Nullable CharSequence p0,
long p1) {
super.id(p0, p1);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ layout(@LayoutRes int p0) {
super.layout(p0);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ spanSizeOverride(
@Nullable EpoxyModel.SpanSizeOverrideCallback p0) {
super.spanSizeOverride(p0);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ show() {
super.show();
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ show(boolean p0) {
super.show(p0);
return this;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ hide() {
super.hide();
return this;
}
@Override
@LayoutRes
protected int getDefaultLayout() {
return 1;
}
@Override
public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ reset() {
onModelBoundListener_epoxyGeneratedModel = null;
onModelUnboundListener_epoxyGeneratedModel = null;
onModelVisibilityStateChangedListener_epoxyGeneratedModel = null;
onModelVisibilityChangedListener_epoxyGeneratedModel = null;
assignedAttributes_epoxyGeneratedModel.clear();
this.titleString_String = null;
this.titleInt_Int = 0;
super.reset();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof GroupPropMultipleSupportedAttributeSameNameModelViewModel_)) {
return false;
}
if (!super.equals(o)) {
return false;
}
GroupPropMultipleSupportedAttributeSameNameModelViewModel_ that = (GroupPropMultipleSupportedAttributeSameNameModelViewModel_) o;
if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) {
return false;
}
if ((titleString_String != null ? !titleString_String.equals(that.titleString_String) : that.titleString_String != null)) {
return false;
}
if ((titleInt_Int != that.titleInt_Int)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int _result = super.hashCode();
_result = 31 * _result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0);
_result = 31 * _result + (titleString_String != null ? titleString_String.hashCode() : 0);
_result = 31 * _result + titleInt_Int;
return _result;
}
@Override
public String toString() {
return "GroupPropMultipleSupportedAttributeSameNameModelViewModel_{" +
"titleString_String=" + titleString_String +
", titleInt_Int=" + titleInt_Int +
"}" + super.toString();
}
public static GroupPropMultipleSupportedAttributeSameNameModelViewModel_ from(
ModelProperties properties) {
GroupPropMultipleSupportedAttributeSameNameModelViewModel_ model = new GroupPropMultipleSupportedAttributeSameNameModelViewModel_();
model.id(properties.getId());
if (properties.has("titleString")) {
model.titleString(properties.getString("titleString"));
} else if (properties.has("titleInt")) {
model.titleInt(properties.getInt("titleInt"));
}
return model;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return totalSpanCount;
}
}
| 8,836 |
0 | Create_ds/epoxy/epoxy-modelfactorytest/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-modelfactorytest/src/main/java/com/airbnb/epoxy/TestModelPropertiesView.java | package com.airbnb.epoxy;
import android.content.Context;
import android.widget.FrameLayout;
import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes;
import com.airbnb.epoxy.ModelView.Size;
import java.util.List;
@ModelView(autoLayout = Size.MATCH_WIDTH_WRAP_HEIGHT)
public class TestModelPropertiesView extends FrameLayout {
public TestModelPropertiesView(Context context) {
super(context);
}
@ModelProp
public void setBooleanValue(boolean value) {
}
@ModelProp
public void setBoxedBooleanValue(Boolean value) {
}
@ModelProp
public void setDoubleValue(double value) {
}
@ModelProp
public void setBoxedDoubleValue(Double value) {
}
@ModelProp
public void setDrawableRes(@DrawableRes int value) {
}
@ModelProp
public void setEpoxyModelList(List<? extends EpoxyModel<?>> value) {
}
@ModelProp
public void setIntValue(int value) {
}
@ModelProp
public void setBoxedIntValue(Integer value) {
}
@ModelProp
public void setLongValue(long value) {
}
@ModelProp
public void setBoxedLongValue(Long value) {
}
@CallbackProp
public void setOnClickListener(@Nullable OnClickListener value) {
}
@ModelProp
public void setRawRes(@RawRes int value) {
}
@ModelProp
public void setStringValue(CharSequence value) {
}
@ModelProp
public void setStringList(List<String> value) {
}
}
| 8,837 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/PackageModelViewConfig.java | package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Settings that apply to all views annotated with {@link com.airbnb.epoxy.ModelView} in this
* package. Also applies to subpackages, unless other package config values are set in those sub
* packages.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface PackageModelViewConfig {
/**
* The R class used in this module (eg "com.example.app.R.class"). This is needed so Epoxy can
* look up layout files.
*/
Class<?> rClass();
/**
* A default layout pattern to be used for specifying layouts for generated models. If this is set
* then a layout can be omitted from a view's {@link com.airbnb.epoxy.ModelView} annotation.
* <p>
* The "%s" placeholder represents the view's name in snack case. For example, the default value
* will use a layout resource of "R.layout.my_view" for the MyView class. If the layout name is
* changed to "view_holder_%s" then the layout used would be "R.layout.view_holder_my_view".
*/
String defaultLayoutPattern() default "%s";
/** An optional EpoxyModel subclass that generated models should extend. */
Class<?> defaultBaseModelClass() default Void.class;
/**
* If true, any layout file name that has a view's default layout as a prefix will be included as
* a method on the generated model for that view.
* <p>
* For example, if the layout is "R.layout.my_view" then any layouts in the form of
* "R.layout.my_view_*" will result in a generated method like "with*Layout" that will apply that
* other layout instead of the default.
*/
boolean useLayoutOverloads() default false;
/**
* Suffix, which will be appended to generated model's names. "Model_" is a default value.
*/
String generatedModelSuffix() default "Model_";
/**
* Controls whether "builder" setter functions that returns the model type will be duplicated
* from super model classes with the function return type updated to use the generated model name.
* This helps make all setters (such as id(...) ) return the same generated model so they can be
* chained in a builder pattern. This is mainly intended for Java usage and is generally
* unnecessary when using models in kotlin, especially if the generated kotlin model
* build extension functions are used. Disabling this can greatly reduce the number of
* methods generated on models.
*
* Default is false. This may also be set project wide with an annotation processor option.
*/
Option disableGenerateBuilderOverloads() default Option.Default;
/**
* Controls whether getter functions (that return the value of each attribute) are generated
* on models.
*
* Disabling this can greatly reduce the number of methods generated on models.
*
* Default is false. This may also be set project wide with an annotation processor option.
*/
Option disableGenerateGetters() default Option.Default;
/**
* Controls whether the "reset" function (that clears all attribute values) are generated
* on models. This function is generally legacy and is not recommended to be used with the modern
* immutable model approach of EpoxyControllers.
*
* Disabling this reduces the amount of generated code.
*
* Default is false. This may also be set project wide with an annotation processor option.
*/
Option disableGenerateReset() default Option.Default;
/**
* Enable or Disable an option, or inherit the default.
*/
enum Option {
Default,
Enabled,
Disabled
}
}
| 8,838 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/AutoModel.java | package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Used to annotate model fields in an EpoxyController. Model fields annotated with this should not
* be assigned a value directly; a model will automatically be created for them. A stable ID will
* also be generated and assigned to the model. This ID will be the same across all instances of the
* adapter, so it can be used for saving state of a model.
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.CLASS)
public @interface AutoModel {
}
| 8,839 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java | package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This can be used to annotate methods inside classes with a {@link ModelView} annotation. Methods
* with this annotation will be called when the visibility state is changed.
* <p>
* Annotated methods should follow this signature :
* `@OnVisibilityStateChanged
* public void method(@Visibility int state)`
* <p>
* Possible States are declared in {@link com.airbnb.epoxy.VisibilityState}.
* <p>
* The equivalent methods on the model is
* {@link com.airbnb.epoxy.EpoxyModel#onVisibilityStateChanged}
* <p>
* @see OnModelVisibilityStateChangedListener
*/
@SuppressWarnings("JavadocReference")
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface OnVisibilityStateChanged {
}
| 8,840 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/ModelView.java | package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import androidx.annotation.LayoutRes;
/**
* An annotation on custom view classes to automatically generate an EpoxyModel for that view. Used
* in conjunction with {@link ModelProp}
* <p>
* See https://github.com/airbnb/epoxy/wiki/Generating-Models-from-View-Annotations
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface ModelView {
/**
* Use with {@link #autoLayout()} to declare what layout parameters should be used to size your
* view when it is added to a RecyclerView. This maps to the LayoutParams options {@code
* layout_width} and {@code layout_height}. If you want to set the LayoutParams manually, you can
* use {@link Size#MANUAL} and set the params in the View's constructor when it is initialized (a
* runtime exception will be thrown if layout params are not set during view instantiation when
* MANUAL is used).
*/
enum Size {
NONE,
MANUAL,
WRAP_WIDTH_WRAP_HEIGHT,
WRAP_WIDTH_MATCH_HEIGHT,
MATCH_WIDTH_WRAP_HEIGHT,
MATCH_WIDTH_MATCH_HEIGHT
}
/**
* If set to an option besides {@link Size#NONE} Epoxy will create an instance of this view
* programmatically at runtime instead of inflating the view from xml. This is an alternative to
* using {@link #defaultLayout()}, and is a good option if you just need to specify layout
* parameters on your view with no other styling.
* <p>
* The size option you choose will define which layout parameters Epoxy uses at runtime when
* creating the view.
*/
Size autoLayout() default Size.NONE;
/**
* The layout file to use in the generated model to inflate the view. This is required unless a
* default pattern is set via {@link PackageModelViewConfig} or {@link #autoLayout()} is used.
* <p>
* Overrides any default set in {@link PackageModelViewConfig}
*/
@LayoutRes int defaultLayout() default 0;
/**
* An optional EpoxyModel subclass to use as the base class of the generated view. A default can
* also be set with {@link PackageModelViewConfig}
* <p>
* * Overrides any default set in {@link PackageModelViewConfig}
*/
Class<?> baseModelClass() default Void.class;
/**
* Whether the model should save view state when unbound.
* <p>
* see: EpoxyModel#shouldSaveViewState
*/
boolean saveViewState() default false;
/**
* True to have the generated model take up the total available span count. False to instead use a
* span count of 1. If you need to programmatically determine your model's span size you can use
* the spanSizeCallback method on EpoxyModel.
*/
boolean fullSpan() default true;
}
| 8,841 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnViewRecycled.java | package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This can be used to annotate methods inside classes with a {@link com.airbnb.epoxy.ModelView}
* annotation. Methods with this annotation will be called when the view is recycled by the
* RecyclerView.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface OnViewRecycled {
}
| 8,842 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/EpoxyAttribute.java |
package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Used to annotate fields on EpoxyModel classes in order to generate a subclass of that model with
* getters, setters, equals, and hashcode for the annotated fields.
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.CLASS)
public @interface EpoxyAttribute {
/**
* Options that can be included on the attribute to affect how the model's generated class is
* created.
*/
enum Option {
/**
* A getter is generated for this attribute by default. Add this option to prevent a getter from
* being generated.
*/
NoGetter,
/**
* A setter is generated for this attribute by default. Add this option to prevent a setter from
* being generated.
*/
NoSetter,
/**
* By default every attribute's hashCode and equals method is called when determining the
* model's state. This option can be used to exclude an attribute's hashCode/equals from
* contributing to the state.
* <p>
* This is useful for objects that may change without actually changing the model's state. A
* common case is an anonymous click listener that gets recreated with every bind call.
* <p>
* When this is used, the attribute will affect the model state solely based on whether it is
* null or non null.
* <p>
* A good rule of thumb for whether to use this on an attribute is, "If this is the only
* attribute that changed do I still need to rebind and update the view?" If the answer if no
* then you can use this to prevent the rebind.
*/
DoNotHash,
/**
* This is meant to be used in conjunction with {@link PackageEpoxyConfig#requireHashCode()}.
* When that is enabled every attribute must implement hashCode/equals. However, there are some
* valid cases where the attribute type does not implement hashCode/equals, but it should still
* be hashed at runtime and contribute to the model's state. Use this option on an attribute in
* that case to tell the processor to let it pass the hashCode/equals validation.
* <p>
* An example case is AutoValue classes, where the generated class correctly implements
* hashCode/equals at runtime.
* <p>
* If you use this it is your responsibility to ensure that the object assigned to the attribute
* at runtime correctly implements hashCode/equals. If you don't want the attribute to
* contribute to model state you should use {@link Option#DoNotHash} instead.
*/
IgnoreRequireHashCode,
/**
* This attribute is used in {@link Object#toString()} implementation by default.
* Add this option to prevent this attribute being used in {@link Object#toString()}.
*/
DoNotUseInToString
}
/** Specify any {@link Option} values that should be used when generating the model class. */
Option[] value() default {};
/**
* Whether or not to include this attribute in equals and hashCode calculations.
* <p>
* It may be useful to disable this for objects that get recreated without the underlying data
* changing such as a click listener that gets created inline in every bind call.
*
* @deprecated Use {@link Option#DoNotHash} instead.
*/
@Deprecated
boolean hash() default true;
/**
* Whether or not to generate setter for this attribute.
* <p>
* It may be useful to disable this for attribute which can be immutable and doesn't require
* setter.
*
* @deprecated Use {@link Option#NoSetter} instead.
*/
@Deprecated
boolean setter() default true;
}
| 8,843 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/EpoxyModelClass.java |
package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import androidx.annotation.LayoutRes;
/**
* Used to annotate EpoxyModel classes in order to generate a subclass of that model with getters,
* setters, equals, and hashcode for the annotated fields, as well as other helper methods and
* boilerplate reduction.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface EpoxyModelClass {
/**
* A layout resource that should be used as the default layout for the model. If you set this you
* don't have to implement `getDefaultLayout`; it will be generated for you.
*/
@LayoutRes int layout() default 0;
/**
* If true, any layout file name that has {@link #layout()} as a prefix will be included as a
* method on the generated model.
* <p>
* For example, if the layout is "R.layout.my_view" then any layouts in the form of
* "R.layout.my_view_*" will result in a generated method like "with*Layout" that will apply that
* other layout instead of the default.
*/
boolean useLayoutOverloads() default false;
}
| 8,844 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/PackageEpoxyConfig.java | package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Use this annotation on any class or interface in your package to specify default behavior for the Epoxy
* annotation processor for that package. You can only have one instance of this annotation per
* package.
* <p>
* If an instance of this annotation is not found in a package then the default values are used.
* <p>
* See https://github.com/airbnb/epoxy/wiki/Configuration for more details on these options.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface PackageEpoxyConfig {
boolean REQUIRE_HASHCODE_DEFAULT = false;
boolean REQUIRE_ABSTRACT_MODELS_DEFAULT = false;
boolean IMPLICITLY_ADD_AUTO_MODELS_DEFAULT = false;
/**
* If true, all fields marked with {@link com.airbnb.epoxy.EpoxyAttribute} must have a type that
* implements hashCode and equals (besides the default Object implementation), or the attribute
* must set DoNotHash as an option.
* <p>
* Setting this to true is useful for ensuring that all model attributes correctly implement
* hashCode and equals, or use DoNotHash (eg for click listeners). It is a common mistake to miss
* these, which leads to invalid model state and incorrect diffing.
* <p>
* The check is done at compile time and compilation will fail if a hashCode validation fails.
* <p>
* Since it is done at compile time this can only check the direct type of the field. Interfaces
* or classes will pass the check if they either have an abstract hashCode/equals method (since it
* is assumed that the object at runtime will implement it) or their class hierarchy must have an
* implementation of hashCode/equals besides the default Object implementation.
* <p>
* If an attribute is an Iterable or Array then the type of object in that collection must
* implement hashCode/equals.
*/
boolean requireHashCode() default REQUIRE_HASHCODE_DEFAULT;
/**
* If true, all classes that contains {@link com.airbnb.epoxy.EpoxyAttribute} or {@link
* com.airbnb.epoxy.EpoxyModelClass} annotations in your project must be abstract. Otherwise
* compilation will fail.
* <p>
* Forcing models to be abstract can prevent the mistake of using the original model class instead
* of the generated class.
*/
boolean requireAbstractModels() default REQUIRE_ABSTRACT_MODELS_DEFAULT;
/**
* If true, models in an EpoxyController that use the {@link AutoModel} annotation don't need to
* be explicitly added to the controller with ".addTo". Instead, they will be added automatically
* after they are modified.
* <p>
* For more details, see the wiki:
* https://github.com/airbnb/epoxy/wiki/Epoxy-Controller#implicit-adding
*/
boolean implicitlyAddAutoModels() default IMPLICITLY_ADD_AUTO_MODELS_DEFAULT;
}
| 8,845 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/CallbackProp.java | package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* A convenient replacement for {@link ModelProp} when the prop represents a callback or listener.
* <p>
* This is the same as using {@link ModelProp} with the options {@link
* com.airbnb.epoxy.ModelProp.Option#NullOnRecycle} and
* {@link com.airbnb.epoxy.ModelProp.Option#DoNotHash}
* <p>
* This can only be used on setters who's parameter is marked as nullable. The prop will be set to
* null when the view is recycled to ensure that the listener is not leaked.
* <p>
* Be aware that since this applies the option {@link com.airbnb.epoxy.ModelProp.Option#DoNotHash}
* changing the value of the listener will not trigger an update to the view.
*/
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.CLASS)
public @interface CallbackProp {
}
| 8,846 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/EpoxyDataBindingPattern.java | package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Used to specify a naming pattern for the databinding layouts that you want models generated for.
* Use this instead of {@link EpoxyDataBindingLayouts} to avoid having to explicitly list every
* databinding layout.
* <p>
* The layouts must not specify a custom databinding class name or package via the
* class="com.example.CustomClassName" override in the layout xml.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface EpoxyDataBindingPattern {
/**
* The R class used in this module (eg "com.example.app.R.class"). This is needed so Epoxy can
* look up layout files.
*/
Class<?> rClass();
/**
* A string prefix that your databinding layouts start with. Epoxy will generate a model for each
* databinding layout whose name starts with this.
* <p>
* For example, if you set this prefix to "view_holder" and you have a "view_holder_header.xml"
* databinding layout, Epoxy will generate a HeaderBindingModel_ class for that layout.
*/
String layoutPrefix();
/**
* If true, any variable whose type does not implement equals and hashcode will have the
* {@link EpoxyAttribute.Option#DoNotHash} behavior applied to them automatically.
* <p>
* This is generally helpful for listeners - other variables should almost always implement
* equals and hashcode.
* <p>
* For details on the nuances of this, see https://github.com/airbnb/epoxy/wiki/DoNotHash
*/
boolean enableDoNotHash() default true;
}
| 8,847 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/TextProp.java | package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import androidx.annotation.StringRes;
/**
* A convenient replacement for {@link ModelProp} when the prop represents text.
* <p>
* This can only be used when the setter parameter is a {@link CharSequence}
* <p>
* This is the same as using {@link ModelProp} with the option {@link
* com.airbnb.epoxy.ModelProp.Option#GenerateStringOverloads}
*/
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.CLASS)
public @interface TextProp {
@StringRes int defaultRes() default 0;
}
| 8,848 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/EpoxyDataBindingLayouts.java | package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import androidx.annotation.LayoutRes;
/**
* Used to specify a list of databinding layout resources that you want EpoxyModels generated for.
* The models will be generated in the same package as this annotation. Every layout must be a valid
* databinding layout. The name of the generated model will be based on the layout resource name.
* <p>
* The layouts must not specify a custom databinding class name or package via the
* class="com.example.CustomClassName" override in the layout xml.
* <p>
* Alternatively you can use {@link EpoxyDataBindingPattern} to avoid explicitly declaring each
* layout.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface EpoxyDataBindingLayouts {
/** A list of databinding layout resources that should have EpoxyModel's generated for them. */
@LayoutRes int[] value();
/**
* If true, any variable whose type does not implement equals and hashcode will have the
* {@link EpoxyAttribute.Option#DoNotHash} behavior applied to them automatically.
* <p>
* This is generally helpful for listeners - other variables should almost always implement
* equals and hashcode.
* <p>
* For details on the nuances of this, see https://github.com/airbnb/epoxy/wiki/DoNotHash
*/
boolean enableDoNotHash() default true;
}
| 8,849 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/ModelProp.java | package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Used in conjunction with {@link ModelView} to automatically generate EpoxyModels from custom
* views - https://github.com/airbnb/epoxy/wiki/Generating-Models-from-View-Annotations
* <p>
* This annotation should be used on setter methods within a custom view class. Setters annotated
* with this will have a corresponding field on the generated model.
* <p>
* Alternatively, if your setter has no side effects, you can use this annotation on a field to have
* Epoxy set that field directly and avoid the boiler plate of a setter.
* <p>
* For convenience you can use {@link TextProp} instead for props representing text.
* <p>
* Similarly you can use {@link CallbackProp} for props representing listeners or callbacks.
* <p>
* Alternatively, the {@link #options()} parameter can be used to configure a prop.
*/
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.CLASS)
public @interface ModelProp {
enum Option {
/**
* By default every prop's hashCode and equals method is called when determining the
* model's state. This option can be used to exclude an prop's hashCode/equals from
* contributing to the state.
* <p>
* This is useful for props that may change without actually changing the model's state. A
* common case is an anonymous click listener that gets recreated with every bind call.
* <p>
* When this is used, the prop will affect the model state solely based on whether it is
* null or non null.
* <p>
* A good rule of thumb for whether to use this on an prop is, "If this is the only
* prop that changed do I still need to rebind and update the view?" If the answer if no
* then you can use this to prevent the rebind.
*/
DoNotHash,
/**
* This is meant to be used in conjunction with {@link PackageEpoxyConfig#requireHashCode()}.
* When that is enabled every prop must implement hashCode/equals. However, there are some
* valid cases where the prop type does not implement hashCode/equals, but it should still
* be hashed at runtime and contribute to the model's state. Use this option on an prop in
* that case to tell the processor to let it pass the hashCode/equals validation.
* <p>
* An example case is AutoValue classes, where the generated class correctly implements
* hashCode/equals at runtime.
* <p>
* If you use this it is your responsibility to ensure that the object assigned to the prop
* at runtime correctly implements hashCode/equals. If you don't want the prop to
* contribute to model state you should use {@link Option#DoNotHash} instead.
*/
IgnoreRequireHashCode,
/**
* Setters with a type of {@link CharSequence} can add this option to have {@link
* androidx.annotation.StringRes} and {@link androidx.annotation.PluralsRes}
* overload methods generated on the model, so users can set the string via a resource.
*/
GenerateStringOverloads,
/**
* Setters with a param annotated with @Nullable can use this to have null set when the view is
* recycled.
*/
NullOnRecycle
}
/** Specify any {@link Option} values that should be used when generating the model class. */
Option[] options() default {};
/**
* The same as {@link #options()}, but this allows the shortcut of setting an option eg
* "@ModelProp(DoNotHash)".
*/
Option[] value() default {};
/**
* The name of the constant field that should be used as the default value for this prop. The
* default value will be used if the prop value isn't set on the model.
* <p>
* For example, you would define a constant in your view class like <code>static final int
* DEFAULT_NUM_LINES = 3</code>, and then set this parameter to "DEFAULT_NUM_LINES" so that the
* annotation processor knows what constant to reference.
* <p>
* The name of the constant must be used instead of referencing the constant directly since
* objects are not valid annotation parameters.
*/
String defaultValue() default "";
/**
* Specify an optional group name. Multiple props with the same group name will only allow one of
* the props to be set on the view.
* <p>
* https://github.com/airbnb/epoxy/wiki/Generating-Models-from-View-Annotations#prop-groups
*/
String group() default "";
}
| 8,850 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java | package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This can be used to annotate methods inside classes with a {@link ModelView} annotation. Methods
* with this annotation will be called when visibility part of the view change.
* <p>
* Annotated methods should follow this signature :
* `@OnVisibilityChanged
* public void method(
* float percentVisibleHeight, float percentVisibleWidth: Float,
* int visibleHeight, int visibleWidth
* )`
* <p>
* The equivalent methods on the model is {@link com.airbnb.epoxy.EpoxyModel#onVisibilityChanged}
* <p>
* @see OnModelVisibilityChangedListener
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface OnVisibilityChanged {
}
| 8,851 |
0 | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-annotations/src/main/java/com/airbnb/epoxy/AfterPropsSet.java | package com.airbnb.epoxy;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This can be used to annotate methods inside classes with a {@link com.airbnb.epoxy.ModelView}
* annotation. Methods with this annotation will be called after a view instance is bound to a
* model and all model props have been set. This is useful if you need to wait until multiple props
* are set before doing certain initialization.
* <p>
* Methods with this annotation will be called after both the initial bind when the view comes on
* screen, and after partial binds when an onscreen view is updated.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface AfterPropsSet {
}
| 8,852 |
0 | Create_ds/epoxy/epoxy-glide-preloader/src/androidTest/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-glide-preloader/src/androidTest/java/com/airbnb/epoxy/preloader/ExampleInstrumentedTest.java | package com.airbnb.epoxy.preloader;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.airbnb.epoxy.preloader.test", appContext.getPackageName());
}
}
| 8,853 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb/epoxy/DataBindingModelIntegrationTest.java | package com.airbnb.epoxy;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.airbnb.epoxy.DataBindingEpoxyModel.DataBindingHolder;
import com.airbnb.epoxy.integrationtest.BuildConfig;
import com.airbnb.epoxy.integrationtest.DatabindingTestBindingModel_;
import com.airbnb.epoxy.integrationtest.ModelWithDataBindingBindingModel_;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.LooperMode;
import java.util.Collections;
import java.util.List;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@RunWith(RobolectricTestRunner.class)
@LooperMode(LooperMode.Mode.LEGACY)
public class DataBindingModelIntegrationTest {
@Test
public void createDataBindingModel() {
SimpleEpoxyController controller = new SimpleEpoxyController();
ModelWithDataBindingBindingModel_ firstModel = new ModelWithDataBindingBindingModel_()
.stringValue("hello")
.id(1);
controller.setModels(Collections.singletonList(firstModel));
ControllerLifecycleHelper lifecycleHelper = new ControllerLifecycleHelper();
EpoxyViewHolder viewHolder = lifecycleHelper.createViewHolder(controller.getAdapter(), 0);
controller.getAdapter().onBindViewHolder(viewHolder, 0);
DataBindingHolder dataBindingHolder = ((DataBindingHolder) viewHolder.objectToBind());
assertNotNull(dataBindingHolder.getDataBinding());
// Check that the requiredText was set on the view
assertEquals(firstModel.stringValue(), ((Button) viewHolder.itemView).getText());
ModelWithDataBindingBindingModel_ secondModel = new ModelWithDataBindingBindingModel_()
.stringValue("hello again")
.id(1);
controller.setModels(Collections.singletonList(secondModel));
List<Object> payloads = DiffPayloadTestUtil.payloadsWithChangedModels(firstModel);
controller.getAdapter().onBindViewHolder(viewHolder, 0, payloads);
// Check that the requiredText was updated after the change payload
assertEquals(secondModel.stringValue(), ((Button) viewHolder.itemView).getText());
}
@Test
public void fullyCreateDataBindingModel() {
SimpleEpoxyController controller = new SimpleEpoxyController();
ModelWithDataBindingBindingModel_ firstModel = new ModelWithDataBindingBindingModel_()
.stringValue("hello")
.id(1);
controller.setModels(Collections.singletonList(firstModel));
ControllerLifecycleHelper lifecycleHelper = new ControllerLifecycleHelper();
EpoxyViewHolder viewHolder = lifecycleHelper.createViewHolder(controller.getAdapter(), 0);
controller.getAdapter().onBindViewHolder(viewHolder, 0);
DataBindingHolder dataBindingHolder = ((DataBindingHolder) viewHolder.objectToBind());
assertNotNull(dataBindingHolder.getDataBinding());
// Check that the requiredText was set on the view
assertEquals(firstModel.stringValue(), ((Button) viewHolder.itemView).getText());
ModelWithDataBindingBindingModel_ secondModel = new ModelWithDataBindingBindingModel_()
.stringValue("hello again")
.id(1);
controller.setModels(Collections.singletonList(secondModel));
List<Object> payloads = DiffPayloadTestUtil.payloadsWithChangedModels(firstModel);
controller.getAdapter().onBindViewHolder(viewHolder, 0, payloads);
// Check that the requiredText was updated after the change payload
assertEquals(secondModel.stringValue(), ((Button) viewHolder.itemView).getText());
}
@Test
public void typesWithOutHashCodeAreNotDiffed() {
SimpleEpoxyController controller = new SimpleEpoxyController();
AdapterDataObserver observerMock = mock(AdapterDataObserver.class);
controller.getAdapter().registerAdapterDataObserver(observerMock);
ModelWithDataBindingBindingModel_ firstModel = new ModelWithDataBindingBindingModel_()
.clickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
})
.id(1);
controller.setModels(Collections.singletonList(firstModel));
verify(observerMock).onItemRangeInserted(0, 1);
ModelWithDataBindingBindingModel_ secondModel = new ModelWithDataBindingBindingModel_()
.clickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
})
.id(1);
controller.setModels(Collections.singletonList(secondModel));
verifyNoMoreInteractions(observerMock);
}
@Test
public void typesWithHashCodeAreDiffed() {
SimpleEpoxyController controller = new SimpleEpoxyController();
AdapterDataObserver observerMock = mock(AdapterDataObserver.class);
controller.getAdapter().registerAdapterDataObserver(observerMock);
ModelWithDataBindingBindingModel_ firstModel = new ModelWithDataBindingBindingModel_()
.stringValue("value1")
.id(1);
controller.setModels(Collections.singletonList(firstModel));
verify(observerMock).onItemRangeInserted(0, 1);
ModelWithDataBindingBindingModel_ secondModel = new ModelWithDataBindingBindingModel_()
.stringValue("value2")
.id(1);
controller.setModels(Collections.singletonList(secondModel));
verify(observerMock).onItemRangeChanged(eq(0), eq(1), any());
verifyNoMoreInteractions(observerMock);
}
@Test
public void generatesBindingModelFromNamingPattern() {
// Make sure that the model was generated from the annotation naming pattern
new DatabindingTestBindingModel_();
}
}
| 8,854 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb/epoxy/ModelClickListenerTest.java | package com.airbnb.epoxy;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CompoundButton;
import com.airbnb.epoxy.integrationtest.BuildConfig;
import com.airbnb.epoxy.integrationtest.ModelWithCheckedChangeListener_;
import com.airbnb.epoxy.integrationtest.ModelWithClickListener_;
import com.airbnb.epoxy.integrationtest.ModelWithLongClickListener_;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.LooperMode;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNotSame;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
@RunWith(RobolectricTestRunner.class)
@LooperMode(LooperMode.Mode.LEGACY)
public class ModelClickListenerTest {
private ControllerLifecycleHelper lifecycleHelper = new ControllerLifecycleHelper();
static class TestController extends EpoxyController {
private EpoxyModel<?> model;
@Override
protected void buildModels() {
add(model.id(1));
}
void setModel(EpoxyModel<?> model) {
this.model = model;
}
}
static class ModelClickListener implements OnModelClickListener<ModelWithClickListener_, View> {
boolean clicked;
@Override
public void onClick(ModelWithClickListener_ model, View view, View v, int position) {
clicked = true;
}
}
static class ModelLongClickListener
implements OnModelLongClickListener<ModelWithLongClickListener_, View> {
boolean clicked;
@Override
public boolean onLongClick(ModelWithLongClickListener_ model, View view, View v, int position) {
clicked = true;
return true;
}
}
static class ModelCheckedChangeListener
implements OnModelCheckedChangeListener<ModelWithCheckedChangeListener_, View> {
boolean checked;
@Override
public void onChecked(ModelWithCheckedChangeListener_ model, View parentView,
CompoundButton checkedView, boolean isChecked, int position) {
checked = true;
}
}
static class ViewClickListener implements OnClickListener {
boolean clicked;
@Override
public void onClick(View v) {
clicked = true;
}
}
@Test
public void basicModelClickListener() {
final ModelWithClickListener_ model = new ModelWithClickListener_();
ModelClickListener modelClickListener = spy(new ModelClickListener());
model.clickListener(modelClickListener);
TestController controller = new TestController();
controller.setModel(model);
lifecycleHelper.buildModelsAndBind(controller);
View viewMock = mockModelForClicking(model);
model.clickListener().onClick(viewMock);
assertTrue(modelClickListener.clicked);
verify(modelClickListener).onClick(eq(model), any(View.class), eq(viewMock), eq(1));
}
private View mockModelForClicking(EpoxyModel model) {
View mockedView = mock(View.class);
RecyclerView recyclerMock = mock(RecyclerView.class);
EpoxyViewHolder holderMock = mock(EpoxyViewHolder.class);
when(holderMock.getAdapterPosition()).thenReturn(1);
doReturn(recyclerMock).when(mockedView).getParent();
doReturn(holderMock).when(recyclerMock).findContainingViewHolder(mockedView);
doReturn(model).when(holderMock).getModel();
when(mockedView.getParent()).thenReturn(recyclerMock);
when(recyclerMock.findContainingViewHolder(mockedView)).thenReturn(holderMock);
when(holderMock.getAdapterPosition()).thenReturn(1);
when(holderMock.getModel()).thenReturn(model);
View parentView = mock(View.class);
when(holderMock.objectToBind()).thenReturn(parentView);
doReturn(parentView).when(holderMock).objectToBind();
return mockedView;
}
@Test
public void basicModelLongClickListener() {
final ModelWithLongClickListener_ model = new ModelWithLongClickListener_();
ModelLongClickListener modelClickListener = spy(new ModelLongClickListener());
model.clickListener(modelClickListener);
TestController controller = new TestController();
controller.setModel(model);
lifecycleHelper.buildModelsAndBind(controller);
View viewMock = mockModelForClicking(model);
model.clickListener().onLongClick(viewMock);
assertTrue(modelClickListener.clicked);
verify(modelClickListener).onLongClick(eq(model), any(View.class), eq(viewMock), eq(1));
}
@Test
public void basicModelCheckedChangeListener() {
final ModelWithCheckedChangeListener_ model = new ModelWithCheckedChangeListener_();
ModelCheckedChangeListener modelCheckedChangeListener = spy(new ModelCheckedChangeListener());
model.checkedChangeListener(modelCheckedChangeListener);
TestController controller = new TestController();
controller.setModel(model);
lifecycleHelper.buildModelsAndBind(controller);
CompoundButton compoundMock = mockCompoundButtonForClicking(model);
model.checkedChangeListener().onCheckedChanged(compoundMock, true);
assertTrue(modelCheckedChangeListener.checked);
verify(modelCheckedChangeListener).onChecked(eq(model), any(View.class), any(CompoundButton.class), eq(true), eq(1));
}
private CompoundButton mockCompoundButtonForClicking(EpoxyModel model) {
CompoundButton mockedView = mock(CompoundButton.class);
RecyclerView recyclerMock = mock(RecyclerView.class);
EpoxyViewHolder holderMock = mock(EpoxyViewHolder.class);
when(holderMock.getAdapterPosition()).thenReturn(1);
doReturn(recyclerMock).when(mockedView).getParent();
doReturn(holderMock).when(recyclerMock).findContainingViewHolder(mockedView);
doReturn(model).when(holderMock).getModel();
when(mockedView.getParent()).thenReturn(recyclerMock);
when(recyclerMock.findContainingViewHolder(mockedView)).thenReturn(holderMock);
when(holderMock.getAdapterPosition()).thenReturn(1);
when(holderMock.getModel()).thenReturn(model);
View parentView = mock(View.class);
when(holderMock.objectToBind()).thenReturn(parentView);
doReturn(parentView).when(holderMock).objectToBind();
return mockedView;
}
@Test
public void modelClickListenerOverridesViewClickListener() {
final ModelWithClickListener_ model = new ModelWithClickListener_();
TestController controller = new TestController();
controller.setModel(model);
ViewClickListener viewClickListener = new ViewClickListener();
model.clickListener(viewClickListener);
assertNotNull(model.clickListener());
ModelClickListener modelClickListener = new ModelClickListener();
model.clickListener(modelClickListener);
assertNotSame(model.clickListener(), viewClickListener);
lifecycleHelper.buildModelsAndBind(controller);
mockModelForClicking(model);
assertNotNull(model.clickListener());
View viewMock = mockModelForClicking(model);
model.clickListener().onClick(viewMock);
assertTrue(modelClickListener.clicked);
assertFalse(viewClickListener.clicked);
}
@Test
public void viewClickListenerOverridesModelClickListener() {
final ModelWithClickListener_ model = new ModelWithClickListener_();
TestController controller = new TestController();
controller.setModel(model);
ModelClickListener modelClickListener = new ModelClickListener();
model.clickListener(modelClickListener);
ViewClickListener viewClickListener = new ViewClickListener();
model.clickListener(viewClickListener);
lifecycleHelper.buildModelsAndBind(controller);
assertNotNull(model.clickListener());
model.clickListener().onClick(null);
assertTrue(viewClickListener.clicked);
assertFalse(modelClickListener.clicked);
}
@Test
public void resetClearsModelClickListener() {
final ModelWithClickListener_ model = new ModelWithClickListener_();
TestController controller = new TestController();
controller.setModel(model);
ModelClickListener modelClickListener = spy(new ModelClickListener());
model.clickListener(modelClickListener);
model.reset();
lifecycleHelper.buildModelsAndBind(controller);
assertNull(model.clickListener());
}
@Test
public void modelClickListenerIsDiffed() {
// Internally we wrap the model click listener with an anonymous click listener. We can't hash
// the anonymous click listener since that changes the model state, instead our anonymous
// click listener should use the hashCode of the user's click listener
ModelClickListener modelClickListener = new ModelClickListener();
ViewClickListener viewClickListener = new ViewClickListener();
TestController controller = new TestController();
AdapterDataObserver observerMock = mock(AdapterDataObserver.class);
controller.getAdapter().registerAdapterDataObserver(observerMock);
ModelWithClickListener_ model = new ModelWithClickListener_();
controller.setModel(model);
controller.requestModelBuild();
verify(observerMock).onItemRangeInserted(eq(0), eq(1));
model = new ModelWithClickListener_();
model.clickListener(modelClickListener);
controller.setModel(model);
lifecycleHelper.buildModelsAndBind(controller);
// The second update shouldn't cause a item change
model = new ModelWithClickListener_();
model.clickListener(modelClickListener);
controller.setModel(model);
lifecycleHelper.buildModelsAndBind(controller);
model = new ModelWithClickListener_();
model.clickListener(viewClickListener);
controller.setModel(model);
lifecycleHelper.buildModelsAndBind(controller);
verify(observerMock, times(2)).onItemRangeChanged(eq(0), eq(1), any());
verifyNoMoreInteractions(observerMock);
}
@Test
public void viewClickListenerIsDiffed() {
TestController controller = new TestController();
AdapterDataObserver observerMock = mock(AdapterDataObserver.class);
controller.getAdapter().registerAdapterDataObserver(observerMock);
ModelWithClickListener_ model = new ModelWithClickListener_();
controller.setModel(model);
controller.requestModelBuild();
verify(observerMock).onItemRangeInserted(eq(0), eq(1));
ViewClickListener viewClickListener = new ViewClickListener();
model = new ModelWithClickListener_();
model.clickListener(viewClickListener);
controller.setModel(model);
controller.requestModelBuild();
// The second update shouldn't cause a item change
model = new ModelWithClickListener_();
model.clickListener(viewClickListener);
controller.setModel(model);
controller.requestModelBuild();
ModelClickListener modelClickListener = new ModelClickListener();
model = new ModelWithClickListener_();
model.clickListener(modelClickListener);
controller.setModel(model);
controller.requestModelBuild();
verify(observerMock, times(2)).onItemRangeChanged(eq(0), eq(1), any());
verifyNoMoreInteractions(observerMock);
}
}
| 8,855 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb/epoxy/OnModelBindListenerTest.java | package com.airbnb.epoxy;
import android.view.View;
import com.airbnb.epoxy.integrationtest.BuildConfig;
import com.airbnb.epoxy.integrationtest.ModelWithClickListener_;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.LooperMode;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@RunWith(RobolectricTestRunner.class)
@LooperMode(LooperMode.Mode.LEGACY)
public class OnModelBindListenerTest {
private ControllerLifecycleHelper lifecycleHelper = new ControllerLifecycleHelper();
static class TestController extends EpoxyController {
private EpoxyModel model;
@Override
protected void buildModels() {
add(model);
}
void setModel(EpoxyModel model) {
this.model = model.id(1);
}
void buildWithModel(EpoxyModel model) {
setModel(model);
requestModelBuild();
}
}
static class BindListener implements OnModelBoundListener<ModelWithClickListener_, View> {
boolean called;
@Override
public void onModelBound(ModelWithClickListener_ model, View view, int position) {
called = true;
}
}
static class UnbindListener implements OnModelUnboundListener<ModelWithClickListener_, View> {
boolean called;
@Override
public void onModelUnbound(ModelWithClickListener_ model, View view) {
called = true;
}
}
@Test
public void onBindListenerGetsCalled() {
TestController controller = new TestController();
BindListener bindListener = new BindListener();
ModelWithClickListener_ model = new ModelWithClickListener_().onBind(bindListener);
controller.setModel(model);
assertFalse(bindListener.called);
lifecycleHelper.buildModelsAndBind(controller);
assertTrue(bindListener.called);
}
@Test
public void onUnbindListenerGetsCalled() {
TestController controller = new TestController();
ModelWithClickListener_ model = new ModelWithClickListener_();
controller.setModel(model);
UnbindListener unbindlistener = new UnbindListener();
model.onUnbind(unbindlistener);
assertFalse(unbindlistener.called);
lifecycleHelper.buildModelsAndBind(controller);
assertFalse(unbindlistener.called);
lifecycleHelper.recycleLastBoundModel(controller);
assertTrue(unbindlistener.called);
}
@Test
public void bindListenerChangesHashCode() {
TestController controller = new TestController();
AdapterDataObserver observerMock = mock(AdapterDataObserver.class);
controller.getAdapter().registerAdapterDataObserver(observerMock);
ModelWithClickListener_ model = new ModelWithClickListener_();
controller.buildWithModel(model);
verify(observerMock).onItemRangeInserted(eq(0), eq(1));
// shouldn't change
model = new ModelWithClickListener_();
model.onBind(null);
controller.buildWithModel(model);
verify(observerMock, never()).onItemRangeChanged(eq(0), eq(1), any());
model = new ModelWithClickListener_();
BindListener listener1 = new BindListener();
model.onBind(listener1);
controller.buildWithModel(model);
verify(observerMock, times(1)).onItemRangeChanged(eq(0), eq(1), any());
model = new ModelWithClickListener_();
model.onBind(listener1);
controller.buildWithModel(model);
verify(observerMock, times(1)).onItemRangeChanged(eq(0), eq(1), any());
}
@Test
public void nullBindListenerChangesHashCode() {
TestController controller = new TestController();
AdapterDataObserver observerMock = mock(AdapterDataObserver.class);
controller.getAdapter().registerAdapterDataObserver(observerMock);
ModelWithClickListener_ model = new ModelWithClickListener_();
controller.buildWithModel(model);
verify(observerMock).onItemRangeInserted(eq(0), eq(1));
model = new ModelWithClickListener_();
model.onBind(new BindListener());
controller.buildWithModel(model);
model = new ModelWithClickListener_();
model.onBind(null);
controller.buildWithModel(model);
verify(observerMock, times(2)).onItemRangeChanged(eq(0), eq(1), any());
}
@Test
public void newBindListenerDoesNotChangeHashCode() {
TestController controller = new TestController();
AdapterDataObserver observerMock = mock(AdapterDataObserver.class);
controller.getAdapter().registerAdapterDataObserver(observerMock);
ModelWithClickListener_ model = new ModelWithClickListener_();
controller.buildWithModel(model);
verify(observerMock).onItemRangeInserted(eq(0), eq(1));
model = new ModelWithClickListener_();
model.onBind(new BindListener());
controller.buildWithModel(model);
model = new ModelWithClickListener_();
model.onBind(new BindListener());
controller.buildWithModel(model);
verify(observerMock).onItemRangeChanged(eq(0), eq(1), any());
}
@Test
public void unbindListenerChangesHashCode() {
TestController controller = new TestController();
AdapterDataObserver observerMock = mock(AdapterDataObserver.class);
controller.getAdapter().registerAdapterDataObserver(observerMock);
ModelWithClickListener_ model = new ModelWithClickListener_();
controller.buildWithModel(model);
verify(observerMock).onItemRangeInserted(eq(0), eq(1));
// shouldn't change
model = new ModelWithClickListener_();
model.onUnbind(null);
controller.buildWithModel(model);
verify(observerMock, never()).onItemRangeChanged(eq(0), eq(1), any());
model = new ModelWithClickListener_();
UnbindListener listener1 = new UnbindListener();
model.onUnbind(listener1);
controller.buildWithModel(model);
verify(observerMock, times(1)).onItemRangeChanged(eq(0), eq(1), any());
model = new ModelWithClickListener_();
model.onUnbind(listener1);
controller.buildWithModel(model);
verify(observerMock, times(1)).onItemRangeChanged(eq(0), eq(1), any());
}
@Test
public void nullUnbindListenerChangesHashCode() {
TestController controller = new TestController();
AdapterDataObserver observerMock = mock(AdapterDataObserver.class);
controller.getAdapter().registerAdapterDataObserver(observerMock);
ModelWithClickListener_ model = new ModelWithClickListener_();
controller.buildWithModel(model);
verify(observerMock).onItemRangeInserted(eq(0), eq(1));
model = new ModelWithClickListener_();
model.onUnbind(new UnbindListener());
controller.buildWithModel(model);
model = new ModelWithClickListener_();
model.onUnbind(null);
controller.buildWithModel(model);
verify(observerMock, times(2)).onItemRangeChanged(eq(0), eq(1), any());
}
@Test
public void newUnbindListenerDoesNotChangHashCode() {
TestController controller = new TestController();
AdapterDataObserver observerMock = mock(AdapterDataObserver.class);
controller.getAdapter().registerAdapterDataObserver(observerMock);
ModelWithClickListener_ model = new ModelWithClickListener_();
controller.buildWithModel(model);
verify(observerMock).onItemRangeInserted(eq(0), eq(1));
model = new ModelWithClickListener_();
model.onUnbind(new UnbindListener());
controller.buildWithModel(model);
model = new ModelWithClickListener_();
model.onUnbind(new UnbindListener());
controller.buildWithModel(model);
verify(observerMock).onItemRangeChanged(eq(0), eq(1), any());
}
}
| 8,856 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb/epoxy/ViewAnnotationsStringOverloadsIntegrationTest.java | package com.airbnb.epoxy;
import android.content.res.Resources;
import com.airbnb.epoxy.integrationtest.R;
import com.airbnb.epoxy.integrationtest.ViewWithAnnotationsForIntegrationTest;
import com.airbnb.epoxy.integrationtest.ViewWithAnnotationsForIntegrationTestModel_;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.LooperMode;
import androidx.test.core.app.ApplicationProvider;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
@RunWith(RobolectricTestRunner.class)
@LooperMode(LooperMode.Mode.LEGACY)
public class ViewAnnotationsStringOverloadsIntegrationTest {
private ControllerLifecycleHelper lifecycleHelper;
ViewWithAnnotationsForIntegrationTest bind(ViewWithAnnotationsForIntegrationTestModel_ model) {
lifecycleHelper = new ControllerLifecycleHelper();
model.id(1);
return (ViewWithAnnotationsForIntegrationTest) lifecycleHelper.bindModel(model);
}
@Test
public void normalCharSequenceIsSet() {
String text = "hello world";
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_().requiredText(text);
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertEquals(text, view.requiredText);
}
@Test
public void getStringOffModel() {
String text = "hello world!";
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_().requiredText(text);
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertEquals(model.getRequiredText(view.getContext()), view.requiredText);
}
@Test
public void stringResIsSet() {
int stringWithNoArgs = R.string.string_with_no_args;
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText(stringWithNoArgs);
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertEquals(view.getContext().getText(stringWithNoArgs), view.requiredText);
}
@Test
public void stringResWithArgsIsSet() {
int stringWithNoArgs = R.string.string_with_args;
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText(stringWithNoArgs, 3);
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertEquals(view.getContext().getString(stringWithNoArgs, 3), view.requiredText);
}
@Test
public void quantityStringIsSet() {
int pluralString = R.plurals.plural_test_string;
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredTextQuantityRes(pluralString, 1);
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertEquals(view.getContext().getResources().getQuantityString(pluralString, 1),
view.requiredText);
}
@Test
public void quantityStringWithArgsIsSet() {
int pluralString = R.plurals.plural_test_string_with_args;
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredTextQuantityRes(pluralString, 1, 3);
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertEquals(view.getContext().getResources().getQuantityString(pluralString, 1, 3),
view.requiredText);
}
@Test(expected = IllegalArgumentException.class)
public void requiredTextThrowsWhenSetWithNull() {
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText(null);
}
@Test(expected = IllegalStateException.class)
public void requiredTextThrowsWhenNotSet() {
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_();
bind(model);
}
@Test(expected = IllegalArgumentException.class)
public void requiredTextThrowsOnBadStringRes() {
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText(0);
}
@Test(expected = IllegalArgumentException.class)
public void requiredTextThrowsOnBadStringResWithArgs() {
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText(0, "args");
}
@Test(expected = IllegalArgumentException.class)
public void requiredTextThrowsOnBadQuantityString() {
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredTextQuantityRes(0, 23, "args");
}
@Test
public void nullableTextSetsNullWhenNotSet() {
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_().requiredText("required");
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertNull(view.nullableText);
}
@Test
public void nullableTextAllowsNull() {
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.nullableText(null);
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertNull(view.nullableText);
}
@Test
public void nullableTextAllowsZeroStringRes() {
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.nullableText(0);
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertNull(view.nullableText);
}
@Test
public void nullableTextAllowsZeroQuantityRes() {
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.nullableTextQuantityRes(0, 1);
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertNull(view.nullableText);
}
@Test
public void defaultStringValueSetIfNothingElseIsSet() {
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required");
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertEquals(ViewWithAnnotationsForIntegrationTest.DEFAULT_STRING, view.textWithDefault);
assertEquals(ViewWithAnnotationsForIntegrationTest.DEFAULT_STRING,
view.nullableTextWithDefault);
}
@Test
public void stringOverridesDefault() {
String text = "hello world";
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.textWithDefault(text)
.nullableTextWithDefault(text);
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertEquals(text, view.nullableTextWithDefault);
assertEquals(text, view.textWithDefault);
}
@Test
public void nullableStringOverridesDefaultWithNull() {
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.nullableTextWithDefault(null);
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertEquals(null, view.nullableTextWithDefault);
}
@Test
public void zeroStringResSetsDefault() {
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.textWithDefault(0)
.nullableTextWithDefault(0);
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertEquals(ViewWithAnnotationsForIntegrationTest.DEFAULT_STRING, view.textWithDefault);
assertEquals(ViewWithAnnotationsForIntegrationTest.DEFAULT_STRING,
view.nullableTextWithDefault);
}
@Test
public void zeroQuantityStringResSetsDefault() {
ViewWithAnnotationsForIntegrationTestModel_ model =
new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.textWithDefaultQuantityRes(0, 1)
.nullableTextWithDefaultQuantityRes(0, 1);
ViewWithAnnotationsForIntegrationTest view = bind(model);
assertEquals(ViewWithAnnotationsForIntegrationTest.DEFAULT_STRING, view.textWithDefault);
assertEquals(ViewWithAnnotationsForIntegrationTest.DEFAULT_STRING,
view.nullableTextWithDefault);
}
@Test
public void stringOverloadsResetEachOther() {
Resources r = ApplicationProvider.getApplicationContext().getResources();
ViewWithAnnotationsForIntegrationTest view =
bind(new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.nullableText(R.string.string_with_no_args)
.nullableText("test"));
assertEquals("test", view.nullableText);
view = bind(new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.nullableText("test")
.nullableText(R.string.string_with_no_args));
assertEquals(r.getString(R.string.string_with_no_args), view.nullableText);
view = bind(new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.nullableText(R.string.string_with_no_args)
.nullableTextQuantityRes(R.plurals.plural_test_string, 1));
assertEquals(r.getQuantityString(R.plurals.plural_test_string, 1), view.nullableText);
view = bind(new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.nullableText(R.string.string_with_no_args)
.nullableTextQuantityRes(0, 1));
assertNull(view.nullableText);
view = bind(new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.nullableTextQuantityRes(R.plurals.plural_test_string, 1)
.nullableText(R.string.string_with_args, 2));
assertEquals(r.getString(R.string.string_with_args, 2), view.nullableText);
view = bind(new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.nullableText(0)
.nullableText(R.string.string_with_args, 2));
assertEquals(r.getString(R.string.string_with_args, 2), view.nullableText);
view = bind(new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.nullableText(0)
.nullableText(R.string.string_with_args, 2));
assertEquals(r.getString(R.string.string_with_args, 2), view.nullableText);
view = bind(new ViewWithAnnotationsForIntegrationTestModel_()
.requiredText("required")
.nullableText(R.string.string_with_args, 2)
.nullableText(0));
assertNull(view.nullableText);
}
}
| 8,857 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb/epoxy/BindModelIntegrationTest.java | package com.airbnb.epoxy;
import android.widget.TextView;
import com.airbnb.epoxy.integrationtest.BuildConfig;
import com.airbnb.epoxy.integrationtest.Model_;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.LooperMode;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@RunWith(RobolectricTestRunner.class)
@LooperMode(LooperMode.Mode.LEGACY)
public class BindModelIntegrationTest {
private Model_ model;
class TestAdapter extends BaseEpoxyAdapter {
private boolean diffPayloadsEnabled;
private List<EpoxyModel<?>> models;
TestAdapter(boolean diffPayloadsEnabled) {
this.diffPayloadsEnabled = diffPayloadsEnabled;
this.models = new ArrayList<>();
models.add(model);
}
@Override
List<EpoxyModel<?>> getCurrentModels() {
return models;
}
@Override
boolean diffPayloadsEnabled() {
return diffPayloadsEnabled;
}
}
@Before
public void before() {
model = spy(new Model_()).id(1);
}
@Test
public void bindNoPayloads() {
TestAdapter adapter = new TestAdapter(false);
EpoxyViewHolder viewHolder = ControllerLifecycleHelper.createViewHolder(adapter, 0);
adapter.onBindViewHolder(viewHolder, 0);
verify(model).bind((TextView) viewHolder.itemView);
verify(model, never()).bind(any(TextView.class), any(List.class));
verify(model, never()).bind(any(TextView.class), any(EpoxyModel.class));
}
@Test
public void bindWithPayloads() {
TestAdapter adapter = new TestAdapter(false);
EpoxyViewHolder viewHolder = ControllerLifecycleHelper.createViewHolder(adapter, 0);
ArrayList<Object> payloads = new ArrayList<>();
payloads.add("hello");
adapter.onBindViewHolder(viewHolder, 0, payloads);
verify(model).bind((TextView) viewHolder.itemView, payloads);
// This is called if the payloads bind call isn't implemented
verify(model).bind(any(TextView.class));
verify(model, never()).bind(any(TextView.class), any(EpoxyModel.class));
}
@Test
public void bindWithDiffPayload() {
TestAdapter adapter = new TestAdapter(true);
EpoxyViewHolder viewHolder = ControllerLifecycleHelper.createViewHolder(adapter, 0);
Model_ originallyBoundModel = new Model_();
originallyBoundModel.id(model.id());
List<Object> payloads = DiffPayloadTestUtil.payloadsWithChangedModels(originallyBoundModel);
adapter.onBindViewHolder(viewHolder, 0, payloads);
verify(model).bind((TextView) viewHolder.itemView, originallyBoundModel);
// This is called if the payloads bind call isn't implemented
verify(model).bind(any(TextView.class));
verify(model, never()).bind(any(TextView.class), any(List.class));
}
}
| 8,858 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb/epoxy/EpoxyModelValidationTest.java | package com.airbnb.epoxy;
import com.airbnb.epoxy.EpoxyController.Interceptor;
import com.airbnb.epoxy.integrationtest.BuildConfig;
import com.airbnb.epoxy.integrationtest.ControllerWithAutoModel;
import com.airbnb.epoxy.integrationtest.Model;
import com.airbnb.epoxy.integrationtest.ModelChangesDuringBind_;
import com.airbnb.epoxy.integrationtest.Model_;
import com.airbnb.epoxy.integrationtest.R;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.LooperMode;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
@LooperMode(LooperMode.Mode.LEGACY)
public class EpoxyModelValidationTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
static class Controller extends EpoxyController {
@Override
protected void buildModels() {
}
}
@Test
public void testModelCannotBeAddedTwice() {
thrown.expect(IllegalEpoxyUsage.class);
thrown.expectMessage("This model was already added to the controller at position 0");
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
Model model = new Model_().id(1);
model.addTo(this);
model.addTo(this);
}
};
controller.requestModelBuild();
}
@Test
public void addToOnlyValidInsideBuildModels() {
thrown.expect(IllegalEpoxyUsage.class);
thrown.expectMessage("Can only call this when inside");
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
}
};
new Model_()
.id(1)
.addTo(controller);
}
@Test
public void addModelOnlyValidInsideBuildModels() {
thrown.expect(IllegalEpoxyUsage.class);
thrown.expectMessage("Can only call this when inside");
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
}
};
controller.add(new Model_().id(1));
}
@Test
public void cannotCallBuildModelsDirectly() {
thrown.expect(IllegalEpoxyUsage.class);
thrown.expectMessage("Can only call this when inside");
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
new Model_()
.id(1)
.addTo(this);
}
};
controller.buildModels();
}
@Test
public void mustSpecifyModelIdInController() {
thrown.expect(IllegalEpoxyUsage.class);
thrown.expectMessage("You must set an id on a model");
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
new Model_()
.addTo(this);
}
};
controller.requestModelBuild();
}
@Test
public void hideModelNotAllowedInController() {
thrown.expect(IllegalEpoxyUsage.class);
thrown.expectMessage("You cannot hide a model");
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
new Model_()
.id(1)
.hide()
.addTo(this);
}
};
controller.requestModelBuild();
}
@Test
public void cannotChangeIdAfterAddingModelToController() {
thrown.expect(IllegalEpoxyUsage.class);
thrown.expectMessage("Cannot change a model's id");
final Model model = new Model_().id(1);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(model);
}
};
controller.requestModelBuild();
model.id(2);
}
@Test
public void mutationNotAllowedAfterModelIsAdded_reset() {
thrown.expect(ImmutableModelException.class);
thrown.expectMessage("Epoxy attribute fields on a model cannot be changed");
final Model model = new Model_().id(1);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(model);
}
};
controller.requestModelBuild();
model.reset();
}
@Test
public void mutationNotAllowedAfterModelIsAdded_bindListener() {
thrown.expect(ImmutableModelException.class);
thrown.expectMessage("Epoxy attribute fields on a model cannot be changed");
final Model_ model = new Model_().id(1);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(model);
}
};
controller.requestModelBuild();
model.onBind(null);
}
@Test
public void mutationNotAllowedAfterModelIsAdded_unbindListener() {
thrown.expect(ImmutableModelException.class);
thrown.expectMessage("Epoxy attribute fields on a model cannot be changed");
final Model_ model = new Model_().id(1);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(model);
}
};
controller.requestModelBuild();
model.onUnbind(null);
}
@Test
public void mutationNotAllowedAfterModelIsAdded_setter() {
thrown.expect(ImmutableModelException.class);
thrown.expectMessage("Epoxy attribute fields on a model cannot be changed");
final Model_ model = new Model_().id(1);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(model);
}
};
controller.requestModelBuild();
model.value(2);
}
@Test
public void mutationNotAllowedAfterModelIsAdded_layout() {
thrown.expect(ImmutableModelException.class);
thrown.expectMessage("Epoxy attribute fields on a model cannot be changed");
final Model model = new Model_().id(1);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(model);
}
};
controller.requestModelBuild();
model.layout(R.layout.view_holder_empty_view);
}
@Test
public void mutationNotAllowedAfterModelIsAdded_hide() {
thrown.expect(ImmutableModelException.class);
thrown.expectMessage("Epoxy attribute fields on a model cannot be changed");
final Model model = new Model_().id(1);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(model);
}
};
controller.requestModelBuild();
model.hide();
}
@Test
public void mutationAllowedDuringInterceptorCall() {
final Model model = new Model_().id(1);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(model);
}
};
controller.addInterceptor(new Interceptor() {
@Override
public void intercept(List<EpoxyModel<?>> models) {
model.reset();
}
});
controller.requestModelBuild();
}
@Test
public void hashChangeThrows_beforeBind() {
thrown.expect(ImmutableModelException.class);
thrown.expectMessage("Epoxy attribute fields on a model cannot be changed");
final Model model = new Model_().id(1);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(model);
}
};
controller.requestModelBuild();
model.value = 3;
new ControllerLifecycleHelper().bindModels(controller);
}
@Test
public void hashChangeThrows_duringBind() {
thrown.expect(ImmutableModelException.class);
thrown.expectMessage("Epoxy attribute fields on a model cannot be changed");
final ModelChangesDuringBind_ model =
new ModelChangesDuringBind_().id(1);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(model);
}
};
new ControllerLifecycleHelper().buildModelsAndBind(controller);
}
@Test
public void hashChangeThrows_beforeNextModelBuild() {
// This only works for controllers with AutoModels since only those have generated helpers
thrown.expect(ImmutableModelException.class);
thrown.expectMessage("Epoxy attribute fields on a model cannot be changed");
ControllerWithAutoModel controller = new ControllerWithAutoModel();
controller.requestModelBuild();
Model model = (Model) controller.getAdapter().getCopyOfModels().get(0);
model.value = 3;
controller.requestModelBuild();
}
@Test
public void hashChangeDuringInterceptorIsAllowed() {
final Model_ model = new Model_().id(1);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(model);
}
};
controller.addInterceptor(new Interceptor() {
@Override
public void intercept(List<EpoxyModel<?>> models) {
model.value(3);
}
});
controller.requestModelBuild();
}
} | 8,859 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb/epoxy/EpoxyModelIntegrationTest.java | package com.airbnb.epoxy;
import android.view.View;
import com.airbnb.epoxy.EpoxyModel.SpanSizeOverrideCallback;
import com.airbnb.epoxy.integrationtest.BuildConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals;
@RunWith(RobolectricTestRunner.class)
public class EpoxyModelIntegrationTest {
static class ModelWithSpanCount extends EpoxyModel<View> {
@Override
protected int getDefaultLayout() {
return 0;
}
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return 6;
}
}
@Test
public void modelReturnsSpanCount() {
ModelWithSpanCount model = new ModelWithSpanCount();
assertEquals(6, model.spanSize(0, 0, 0));
}
static class ModelWithSpanCountCallback extends EpoxyModel<View> {
@Override
protected int getDefaultLayout() {
return 0;
}
}
@Test
public void modelReturnsSpanCountFromCallback() {
ModelWithSpanCountCallback model = new ModelWithSpanCountCallback();
model.spanSizeOverride(new SpanSizeOverrideCallback() {
@Override
public int getSpanSize(int totalSpanCount, int position, int itemCount) {
return 7;
}
});
assertEquals(7, model.spanSize(0, 0, 0));
}
}
| 8,860 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb/epoxy/EpoxyAdapterIntegrationTest.java | package com.airbnb.epoxy;
import com.airbnb.epoxy.integrationtest.BuildConfig;
import com.airbnb.epoxy.integrationtest.Model;
import com.airbnb.epoxy.integrationtest.Model_;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals;
@RunWith(RobolectricTestRunner.class)
public class EpoxyAdapterIntegrationTest {
private ControllerLifecycleHelper lifecycleHelper = new ControllerLifecycleHelper();
private final SimpleEpoxyAdapter adapter = new SimpleEpoxyAdapter();
@Test
public void returnModelViewType() {
Model testModel = new Model_();
adapter.addModel(testModel);
int itemViewType = adapter.getItemViewType(0);
assertEquals(testModel.getViewType(), itemViewType);
}
@Test
public void returnHiddenModelViewType() {
Model testModel = new Model_();
testModel.hide();
adapter.addModel(testModel);
int itemViewType = adapter.getItemViewType(0);
assertEquals(new HiddenEpoxyModel().getViewType(), itemViewType);
}
@Test
public void bindHiddenModel() {
Model testModel = new Model_();
testModel.hide();
adapter.addModel(testModel);
lifecycleHelper.bindModels(adapter);
}
@Test
public void bindNormalModel() {
Model testModel = new Model_();
adapter.addModel(testModel);
lifecycleHelper.bindModels(adapter);
}
} | 8,861 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb/epoxy/DiffPayloadTestUtil.java | package com.airbnb.epoxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
class DiffPayloadTestUtil {
static DiffPayload diffPayloadWithModels(EpoxyModel<?>... models) {
List<EpoxyModel<?>> epoxyModels = Arrays.asList(models);
return new DiffPayload(epoxyModels);
}
static List<Object> payloadsWithDiffPayloads(DiffPayload... diffPayloads) {
List<DiffPayload> payloads = Arrays.asList(diffPayloads);
return new ArrayList<Object>(payloads);
}
static List<Object> payloadsWithChangedModels(EpoxyModel<?>... models) {
return payloadsWithDiffPayloads(diffPayloadWithModels(models));
}
}
| 8,862 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-integrationtest/src/test/java/com/airbnb/epoxy/AutoModelIntegrationTest.java | package com.airbnb.epoxy;
import com.airbnb.epoxy.integrationtest.AdapterWithFieldAssigned;
import com.airbnb.epoxy.integrationtest.AdapterWithIdChanged;
import com.airbnb.epoxy.integrationtest.BasicAutoModelsAdapter;
import com.airbnb.epoxy.integrationtest.ControllerWithoutImplicityAdding;
import com.airbnb.epoxy.integrationtest.Model_;
import com.airbnb.epoxy.integrationtest.autoaddautomodels.ControllerWithImplicitlyAddedModels;
import com.airbnb.epoxy.integrationtest.autoaddautomodels.ControllerWithImplicitlyAddedModels2;
import com.airbnb.epoxy.integrationtest.autoaddautomodels.ControllerWithImplicitlyAddedModels3;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
@RunWith(RobolectricTestRunner.class)
public class AutoModelIntegrationTest {
@Test
public void basicAutoModels() {
BasicAutoModelsAdapter controller = new BasicAutoModelsAdapter();
controller.requestModelBuild();
List<EpoxyModel<?>> models = controller.getAdapter().getCopyOfModels();
assertEquals("Models size", 2, models.size());
assertEquals("First model", Model_.class, models.get(0).getClass());
assertEquals("Second model", Model_.class, models.get(1).getClass());
}
@Test(expected = IllegalStateException.class)
public void assigningValueToFieldFails() {
AdapterWithFieldAssigned testAdapter = new AdapterWithFieldAssigned();
testAdapter.requestModelBuild();
}
@Test(expected = IllegalStateException.class)
public void assigningIdToAutoModelFails() {
AdapterWithIdChanged testAdapter = new AdapterWithIdChanged();
testAdapter.requestModelBuild();
}
@Test
public void implicitlyAddingAutoModelsDisabledByDefault() {
ControllerWithoutImplicityAdding controller = new ControllerWithoutImplicityAdding();
controller.requestModelBuild();
assertEquals(new ArrayList<>(), controller.getAdapter().getCopyOfModels());
}
@Test
public void implicitlyAddingAutoModels() {
ControllerWithImplicitlyAddedModels controller = new ControllerWithImplicitlyAddedModels();
controller.requestModelBuild();
assertEquals(controller.getExpectedModels(), controller.getAdapter().getCopyOfModels());
}
@Test
public void implicitlyAddingAutoModels2() {
ControllerWithImplicitlyAddedModels2 controller = new ControllerWithImplicitlyAddedModels2();
controller.requestModelBuild();
assertEquals(controller.getExpectedModels(), controller.getAdapter().getCopyOfModels());
}
@Test
public void implicitlyAddingAutoModels3() {
ControllerWithImplicitlyAddedModels3 controller = new ControllerWithImplicitlyAddedModels3();
controller.requestModelBuild();
assertEquals(controller.getExpectedModels(), controller.getAdapter().getCopyOfModels());
}
} | 8,863 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/AdapterWithFieldAssigned.java | package com.airbnb.epoxy.integrationtest;
import com.airbnb.epoxy.AutoModel;
import com.airbnb.epoxy.EpoxyController;
public class AdapterWithFieldAssigned extends EpoxyController {
@AutoModel Model_ model1 = new Model_();
@Override
protected void buildModels() {
add(model1);
}
}
| 8,864 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/ModelChangesDuringBind.java | package com.airbnb.epoxy.integrationtest;
import android.view.View;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModel;
import androidx.annotation.NonNull;
public class ModelChangesDuringBind extends EpoxyModel<View> {
@EpoxyAttribute public int value;
@Override
protected int getDefaultLayout() {
return R.layout.model_with_click_listener;
}
@Override
public void bind(@NonNull View view) {
super.bind(view);
value = 3;
}
}
| 8,865 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/ModelWithLongClickListener.java | package com.airbnb.epoxy.integrationtest;
import android.view.View;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModel;
import androidx.annotation.NonNull;
public class ModelWithLongClickListener extends EpoxyModel<View> {
@EpoxyAttribute View.OnLongClickListener clickListener;
@Override
protected int getDefaultLayout() {
return R.layout.model_with_click_listener;
}
@Override
public void bind(@NonNull View view) {
view.setOnLongClickListener(clickListener);
}
}
| 8,866 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/ModelWithClickListener.java | package com.airbnb.epoxy.integrationtest;
import android.view.View;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModel;
import androidx.annotation.NonNull;
public class ModelWithClickListener extends EpoxyModel<View> {
@EpoxyAttribute public View.OnClickListener clickListener;
@Override
protected int getDefaultLayout() {
return R.layout.model_with_click_listener;
}
@Override
public void bind(@NonNull View view) {
view.setOnClickListener(clickListener);
}
}
| 8,867 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/ControllerWithoutImplicityAdding.java | package com.airbnb.epoxy.integrationtest;
import com.airbnb.epoxy.AutoModel;
import com.airbnb.epoxy.EpoxyController;
public class ControllerWithoutImplicityAdding extends EpoxyController {
@AutoModel Model_ model1;
@Override
protected void buildModels() {
model1.value(3);
}
}
| 8,868 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/ModelGroupWithAnnotation.java | package com.airbnb.epoxy.integrationtest;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModel;
import com.airbnb.epoxy.EpoxyModelClass;
import com.airbnb.epoxy.EpoxyModelGroup;
import com.airbnb.epoxy.ModelGroupHolder;
import java.util.List;
import androidx.annotation.NonNull;
@EpoxyModelClass
public abstract class ModelGroupWithAnnotation extends EpoxyModelGroup {
@EpoxyAttribute int backgroundColor;
public ModelGroupWithAnnotation(List<? extends EpoxyModel<?>> models) {
super(R.layout.model_with_click_listener, models);
}
@Override
public void bind(@NonNull ModelGroupHolder holder) {
super.bind(holder);
holder.getRootView().setBackgroundColor(backgroundColor);
}
}
| 8,869 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/AdapterWithIdChanged.java | package com.airbnb.epoxy.integrationtest;
import com.airbnb.epoxy.AutoModel;
import com.airbnb.epoxy.EpoxyController;
public class AdapterWithIdChanged extends EpoxyController {
@AutoModel Model_ model1 = new Model_();
@Override
protected void buildModels() {
add(model1.id(23));
}
}
| 8,870 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/ControllerWithAutoModel.java | package com.airbnb.epoxy.integrationtest;
import com.airbnb.epoxy.AutoModel;
import com.airbnb.epoxy.EpoxyController;
public class ControllerWithAutoModel extends EpoxyController {
@AutoModel Model_ model;
@Override
protected void buildModels() {
add(model);
}
}
| 8,871 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/ModelWithNoGeneratedClass.java | package com.airbnb.epoxy.integrationtest;
import android.view.View;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModel;
// This class isn't used, but tests that a model is not generated for this and the processor and
// generated code handles this and compiles correctly. A kotlin extension function should not be
// generated
public abstract class ModelWithNoGeneratedClass extends EpoxyModel<View> {
@EpoxyAttribute int value;
}
| 8,872 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/ModelWithCheckedChangeListener.java | package com.airbnb.epoxy.integrationtest;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModel;
import androidx.annotation.NonNull;
public class ModelWithCheckedChangeListener extends EpoxyModel<View> {
@EpoxyAttribute OnCheckedChangeListener checkedChangeListener;
@Override
protected int getDefaultLayout() {
return R.layout.model_with_checked_change;
}
@Override
public void bind(@NonNull View view) {
if (view instanceof CompoundButton) {
((CompoundButton) view).setOnCheckedChangeListener(checkedChangeListener);
}
}
}
| 8,873 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/ViewWithAnnotationsForIntegrationTest.java | package com.airbnb.epoxy.integrationtest;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import com.airbnb.epoxy.CallbackProp;
import com.airbnb.epoxy.ModelProp;
import com.airbnb.epoxy.ModelProp.Option;
import com.airbnb.epoxy.ModelView;
import androidx.annotation.Nullable;
@ModelView(defaultLayout = R.layout.view_with_annotations_for_integration_test)
public class ViewWithAnnotationsForIntegrationTest extends View {
public static final String DEFAULT_STRING = "hello world";
public CharSequence requiredText;
public CharSequence nullableText;
public CharSequence textWithDefault;
public CharSequence nullableTextWithDefault;
public ViewWithAnnotationsForIntegrationTest(Context context) {
super(context);
}
public ViewWithAnnotationsForIntegrationTest(Context context,
@Nullable AttributeSet attrs) {
super(context, attrs);
}
public ViewWithAnnotationsForIntegrationTest(Context context,
@Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@ModelProp(options = Option.GenerateStringOverloads)
public void setRequiredText(CharSequence text) {
this.requiredText = text;
}
@ModelProp(options = Option.GenerateStringOverloads)
public void setNullableText(@Nullable CharSequence text) {
nullableText = text;
}
@ModelProp(options = Option.GenerateStringOverloads, defaultValue = "DEFAULT_STRING")
public void setTextWithDefault(CharSequence text) {
textWithDefault = text;
}
@ModelProp(options = Option.GenerateStringOverloads, defaultValue = "DEFAULT_STRING")
public void setNullableTextWithDefault(@Nullable CharSequence text) {
nullableTextWithDefault = text;
}
@CallbackProp
@Override
public void setOnClickListener(@Nullable OnClickListener l) {
super.setOnClickListener(l);
}
@ModelProp
public void setGroupWithNoDefault(String url) {
}
@CallbackProp
public void setGroupWithNoDefault(@Nullable OnClickListener url) {
}
@ModelProp
public void setGroupWithDefault(String url) {
}
@CallbackProp
public void setGroupWithDefault(@Nullable OnClickListener url) {
}
@ModelProp
public void setGroupWithDefault(int url) {
}
}
| 8,874 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/ModelWithConstructors.java | package com.airbnb.epoxy.integrationtest;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModel;
import com.airbnb.epoxy.EpoxyModelClass;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@EpoxyModelClass
public abstract class ModelWithConstructors extends EpoxyModel<TextView> {
@EpoxyAttribute public int value;
public ModelWithConstructors(long id, int value) {
super(id);
this.value = value;
}
public ModelWithConstructors(int value) {
this.value = value;
}
public ModelWithConstructors(long id) {
super(id);
}
// Tests that kotlin extension functions
public ModelWithConstructors(
Collection<String> collection,
Iterable<String> iterable,
List<String> list,
List<? extends String> upperBoundList,
// List<? super String> lowerBoundList,!!! Doesn't work, we would need to transform this
// type to
// a MutableList
List<?> wildCardList,
Map<String, String> map,
Set<String> set,
Boolean boxedBoolean,
Byte boxedByte,
Short boxedShort,
Integer boxedInteger,
Long boxedLong,
Character boxedCharacter,
Float boxedFloat,
Double boxedDouble,
String[] stringArray,
byte[] byteArray,
short[] shortArray,
char[] charArray,
int[] intArray,
float[] floatArray,
double[] doubleArray,
long[] longArray,
boolean[] booleanArray,
Byte[] boxedByteArray,
Short[] boxedShortArray,
Character[] boxedCharArray,
Integer[] boxedIntArray,
Float[] boxedFloatArray,
Double[] boxedDoubleArray,
Long[] boxedLongArray,
Boolean[] boxedBooleanArray,
Object objectParam
) {
}
@Override
protected int getDefaultLayout() {
return R.layout.model_with_click_listener;
}
}
| 8,875 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/ModelsWithCustomTypes.java | package com.airbnb.epoxy.integrationtest;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyModel;
import com.airbnb.epoxy.EpoxyModelClass;
/**
* This tests that the annotation processor looks up the correct bound object type on the model when
* a subclass defines a new type. In this test the generated model should correctly use TextView as
* the model type instead of the ImageView type of the subclass.
*/
class ModelsWithCustomTypes {
@EpoxyModelClass
abstract static class ModelWithCustomType extends BaseModelWithCustomType<ImageView> {
public ModelWithCustomType() {
}
@Override
protected int getDefaultLayout() {
return 0;
}
}
abstract static class BaseModelWithCustomType<U extends View> extends EpoxyModel<TextView> {
public BaseModelWithCustomType() {
}
public void testMethod(U param) {
}
@Override
protected int getDefaultLayout() {
return 0;
}
}
}
| 8,876 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/Model.java | package com.airbnb.epoxy.integrationtest;
import android.widget.TextView;
import com.airbnb.epoxy.EpoxyAttribute;
import com.airbnb.epoxy.EpoxyModel;
import com.airbnb.epoxy.EpoxyModelClass;
import androidx.annotation.NonNull;
@EpoxyModelClass
public abstract class Model extends EpoxyModel<TextView> {
@EpoxyAttribute public int value;
@Override
protected int getDefaultLayout() {
return R.layout.model_with_click_listener;
}
@Override
public void bind(@NonNull TextView view) {
view.setText(String.valueOf(value));
}
}
| 8,877 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/EpoxyDataBindingConfig.java | package com.airbnb.epoxy.integrationtest;
import com.airbnb.epoxy.EpoxyDataBindingLayouts;
import com.airbnb.epoxy.EpoxyDataBindingPattern;
@EpoxyDataBindingPattern(rClass = R.class, layoutPrefix = "view_holder")
@EpoxyDataBindingLayouts({R.layout.model_with_data_binding})
interface EpoxyDataBindingConfig {}
| 8,878 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/BasicAutoModelsAdapter.java | package com.airbnb.epoxy.integrationtest;
import com.airbnb.epoxy.AutoModel;
import com.airbnb.epoxy.EpoxyController;
public class BasicAutoModelsAdapter extends EpoxyController {
@AutoModel Model_ model1;
@AutoModel Model_ model2;
@Override
protected void buildModels() {
add(model1.id(1));
add(model2.id(2));
}
}
| 8,879 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/autoaddautomodels/ControllerWithImplicitlyAddedModels.java | package com.airbnb.epoxy.integrationtest.autoaddautomodels;
import com.airbnb.epoxy.AutoModel;
import com.airbnb.epoxy.EpoxyController;
import com.airbnb.epoxy.EpoxyModel.AddPredicate;
import com.airbnb.epoxy.integrationtest.Model_;
import java.util.ArrayList;
import java.util.List;
public class ControllerWithImplicitlyAddedModels extends EpoxyController {
@AutoModel Model_ model1;
@AutoModel Model_ model2;
@AutoModel Model_ model3;
@AutoModel Model_ model4;
@AutoModel Model_ model5;
@AutoModel Model_ model6;
@AutoModel Model_ model7;
@AutoModel Model_ model8;
@AutoModel Model_ model9;
private List<Model_> expectedModels;
@Override
protected void buildModels() {
expectedModels = new ArrayList<>();
model1
.value(3);
expectedModels.add(model1);
add(model2);
expectedModels.add(model2);
model3
.addTo(this);
expectedModels.add(model3);
model4
.value(4)
.addTo(this);
expectedModels.add(model4);
model5
.value(34)
.addIf(false, this);
model6
.value(34)
.addIf(new AddPredicate() {
@Override
public boolean addIf() {
return false;
}
}, this);
model7
.addIf(true, this);
expectedModels.add(model7);
model8
.value(2)
.addIf(true, this);
expectedModels.add(model8);
model9
.value(34);
expectedModels.add(model9);
}
public List<Model_> getExpectedModels() {
return expectedModels;
}
}
| 8,880 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/autoaddautomodels/PackageConfig.java | package com.airbnb.epoxy.integrationtest.autoaddautomodels;
import com.airbnb.epoxy.PackageEpoxyConfig;
@PackageEpoxyConfig(implicitlyAddAutoModels = true)
public interface PackageConfig {
}
| 8,881 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/autoaddautomodels/ControllerWithImplicitlyAddedModels2.java | package com.airbnb.epoxy.integrationtest.autoaddautomodels;
import com.airbnb.epoxy.AutoModel;
import com.airbnb.epoxy.EpoxyController;
import com.airbnb.epoxy.integrationtest.Model_;
import java.util.ArrayList;
import java.util.List;
public class ControllerWithImplicitlyAddedModels2 extends EpoxyController {
@AutoModel Model_ model1;
@AutoModel Model_ model2;
@AutoModel Model_ model3;
@AutoModel Model_ model4;
@AutoModel Model_ model5;
@AutoModel Model_ model6;
@AutoModel Model_ model7;
@AutoModel Model_ model8;
@AutoModel Model_ model9;
private List<Model_> expectedModels;
@Override
protected void buildModels() {
expectedModels = new ArrayList<>();
add(model1);
expectedModels.add(model1);
add(model2.value(2));
expectedModels.add(model2);
add(model3.value(3));
expectedModels.add(model3);
model4.value(4);
expectedModels.add(model4);
model5.value(5);
expectedModels.add(model5);
model6.addIf(false, this);
model7.addIf(false, this);
model8.addIf(true, this);
expectedModels.add(model8);
add(model9);
expectedModels.add(model9);
}
public List<Model_> getExpectedModels() {
return expectedModels;
}
}
| 8,882 |
0 | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest | Create_ds/epoxy/epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/autoaddautomodels/ControllerWithImplicitlyAddedModels3.java | package com.airbnb.epoxy.integrationtest.autoaddautomodels;
import com.airbnb.epoxy.AutoModel;
import com.airbnb.epoxy.EpoxyController;
import com.airbnb.epoxy.integrationtest.Model_;
import java.util.ArrayList;
import java.util.List;
public class ControllerWithImplicitlyAddedModels3 extends EpoxyController {
@AutoModel Model_ model1;
@AutoModel Model_ model2;
@AutoModel Model_ model3;
@AutoModel Model_ model4;
private List<Model_> expectedModels;
@Override
protected void buildModels() {
expectedModels = new ArrayList<>();
model1.value(1);
expectedModels.add(model1);
Model_ localModel = new Model_();
add(localModel.id(1));
expectedModels.add(localModel);
localModel = new Model_();
add(localModel.id(2).value(2));
expectedModels.add(localModel);
model2.value(2);
expectedModels.add(model2);
localModel = new Model_();
localModel.id(3).value(3).addTo(this);
expectedModels.add(localModel);
model3.addIf(false, this);
add(model4);
expectedModels.add(model4);
}
public List<Model_> getExpectedModels() {
return expectedModels;
}
}
| 8,883 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/TestObserver.java | package com.airbnb.epoxy;
import java.util.ArrayList;
import java.util.List;
import androidx.recyclerview.widget.RecyclerView;
class TestObserver extends RecyclerView.AdapterDataObserver
{
List<TestModel> modelsAfterDiffing = new ArrayList<>();
List<TestModel> initialModels = new ArrayList<>();
int operationCount = 0;
private boolean showLogs;
TestObserver(boolean showLogs) {
this.showLogs = showLogs;
}
TestObserver() {
this(false);
}
void setUpForNextDiff(List<TestModel> models) {
initialModels = new ArrayList<>(models);
modelsAfterDiffing = new ArrayList<>(models);
}
@Override
public void onItemRangeChanged(int positionStart, int itemCount) {
if (showLogs) {
System.out.println("Item range changed. Start: " + positionStart + " Count: " + itemCount);
}
for (int i = positionStart; i < positionStart + itemCount; i++) {
modelsAfterDiffing.get(i).updated = true;
}
operationCount++;
}
@Override
public void onItemRangeInserted(int positionStart, int itemCount) {
if (showLogs) {
System.out.println("Item range inserted. Start: " + positionStart + " Count: " + itemCount);
}
List<TestModel> modelsToAdd = new ArrayList<>(itemCount);
for (int i = 0; i < itemCount; i++) {
modelsToAdd.add(InsertedModel.INSTANCE);
}
modelsAfterDiffing.addAll(positionStart, modelsToAdd);
operationCount++;
}
@Override
public void onItemRangeRemoved(int positionStart, int itemCount) {
if (showLogs) {
System.out.println("Item range removed. Start: " + positionStart + " Count: " + itemCount);
}
modelsAfterDiffing.subList(positionStart, positionStart + itemCount).clear();
operationCount++;
}
@Override
public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
if (showLogs) {
System.out.println("Item moved. From: " + fromPosition + " To: " + toPosition);
}
TestModel itemToMove = modelsAfterDiffing.remove(fromPosition);
modelsAfterDiffing.add(toPosition, itemToMove);
operationCount++;
}
}
| 8,884 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/UpdateOpHelperTest.java | package com.airbnb.epoxy;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.util.List;
import static org.junit.Assert.assertEquals;
@RunWith(RobolectricTestRunner.class)
public class UpdateOpHelperTest {
private final UpdateOpHelper helper = new UpdateOpHelper();
@Test
public void insertionBatch() {
helper.add(0); // New batch
helper.add(1); // Add at the end
helper.add(0); // Add at the start
helper.add(1); // Add in the middle
assertEquals(1, helper.getNumInsertionBatches());
assertEquals(4, helper.getNumInsertions());
List<UpdateOp> opList = helper.opList;
assertEquals(1, opList.size());
assertEquals(0, opList.get(0).positionStart);
assertEquals(4, opList.get(0).itemCount);
assertEquals(0, helper.getNumRemovalBatches());
assertEquals(0, helper.getNumRemovals());
assertEquals(0, helper.getNumMoves());
}
@Test
public void insertionMultipleBatches() {
helper.add(1); // New batch
helper.add(3); // New batch
helper.add(1); // New batch
helper.add(0); // New batch
assertEquals(4, helper.getNumInsertionBatches());
assertEquals(4, helper.getNumInsertions());
List<UpdateOp> opList = helper.opList;
assertEquals(4, opList.size());
assertEquals(1, opList.get(0).positionStart);
assertEquals(1, opList.get(0).itemCount);
assertEquals(3, opList.get(1).positionStart);
assertEquals(1, opList.get(1).itemCount);
assertEquals(1, opList.get(2).positionStart);
assertEquals(1, opList.get(2).itemCount);
assertEquals(0, opList.get(3).positionStart);
assertEquals(1, opList.get(3).itemCount);
}
@Test
public void insertionBatchRanges() {
helper.add(1, 2);
helper.add(1, 1);
helper.add(4, 1);
assertEquals(1, helper.getNumInsertionBatches());
assertEquals(4, helper.getNumInsertions());
List<UpdateOp> opList = helper.opList;
assertEquals(1, opList.size());
assertEquals(1, opList.get(0).positionStart);
assertEquals(4, opList.get(0).itemCount);
}
@Test
public void removeBatch() {
helper.remove(3); // New batch
helper.remove(3); // Remove at the end
helper.remove(2); // Remove at the start
assertEquals(1, helper.getNumRemovalBatches());
assertEquals(3, helper.getNumRemovals());
List<UpdateOp> opList = helper.opList;
assertEquals(1, opList.size());
assertEquals(2, opList.get(0).positionStart);
assertEquals(3, opList.get(0).itemCount);
assertEquals(0, helper.getNumInsertionBatches());
assertEquals(0, helper.getNumInsertions());
assertEquals(0, helper.getNumMoves());
}
@Test
public void removeMultipleBatches() {
helper.remove(3);
helper.remove(4);
helper.remove(2);
assertEquals(3, helper.getNumRemovalBatches());
assertEquals(3, helper.getNumRemovals());
List<UpdateOp> opList = helper.opList;
assertEquals(3, opList.size());
assertEquals(3, opList.get(0).positionStart);
assertEquals(1, opList.get(0).itemCount);
assertEquals(4, opList.get(1).positionStart);
assertEquals(1, opList.get(1).itemCount);
assertEquals(2, opList.get(2).positionStart);
assertEquals(1, opList.get(2).itemCount);
}
@Test
public void removeBatchRange() {
helper.remove(3, 2);
helper.remove(3, 2);
helper.remove(0, 3);
assertEquals(1, helper.getNumRemovalBatches());
assertEquals(7, helper.getNumRemovals());
List<UpdateOp> opList = helper.opList;
assertEquals(1, opList.size());
assertEquals(0, opList.get(0).positionStart);
assertEquals(7, opList.get(0).itemCount);
}
@Test
public void update() {
helper.update(1); // New Batch
helper.update(0); // Update at start of batch
helper.update(2); // Update at end of batch
helper.update(0); // Update same item as before (shouldn't be added to batch length)
List<UpdateOp> opList = helper.opList;
assertEquals(1, opList.size());
assertEquals(0, opList.get(0).positionStart);
assertEquals(3, opList.get(0).itemCount);
assertEquals(0, helper.getNumInsertionBatches());
assertEquals(0, helper.getNumInsertions());
assertEquals(0, helper.getNumRemovalBatches());
assertEquals(0, helper.getNumRemovals());
assertEquals(0, helper.getNumMoves());
}
@Test
public void updateMultipleBatches() {
helper.update(3);
helper.update(5);
helper.update(3);
helper.update(0);
List<UpdateOp> opList = helper.opList;
assertEquals(4, opList.size());
assertEquals(3, opList.get(0).positionStart);
assertEquals(1, opList.get(0).itemCount);
assertEquals(5, opList.get(1).positionStart);
assertEquals(1, opList.get(1).itemCount);
assertEquals(3, opList.get(2).positionStart);
assertEquals(1, opList.get(2).itemCount);
assertEquals(0, opList.get(3).positionStart);
assertEquals(1, opList.get(3).itemCount);
assertEquals(0, helper.getNumInsertionBatches());
assertEquals(0, helper.getNumInsertions());
assertEquals(0, helper.getNumRemovalBatches());
assertEquals(0, helper.getNumRemovals());
assertEquals(0, helper.getNumMoves());
}
@Test
public void moves() {
helper.move(0, 3);
helper.move(0, 4);
assertEquals(2, helper.getNumMoves());
assertEquals(0, helper.getNumInsertionBatches());
assertEquals(0, helper.getNumInsertions());
assertEquals(0, helper.getNumRemovalBatches());
assertEquals(0, helper.getNumRemovals());
List<UpdateOp> opList = helper.opList;
assertEquals(2, opList.size());
assertEquals(0, opList.get(0).positionStart);
assertEquals(3, opList.get(0).itemCount);
assertEquals(0, opList.get(0).positionStart);
assertEquals(3, opList.get(0).itemCount);
}
} | 8,885 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/DifferNotifyTest.java | package com.airbnb.epoxy;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.util.List;
import static com.airbnb.epoxy.ModelTestUtils.addModels;
import static com.airbnb.epoxy.ModelTestUtils.changeValue;
import static com.airbnb.epoxy.ModelTestUtils.remove;
import static junit.framework.Assert.assertEquals;
/**
* Tests that changes to the models via notify calls besides
* {@link EpoxyAdapter#notifyModelsChanged()}
* will properly update the model state maintained by the differ.
*/
@RunWith(RobolectricTestRunner.class)
public class DifferNotifyTest {
private static final int INITIAL_MODEL_COUNT = 20;
private static final boolean SHOW_LOGS = false;
private final TestObserver testObserver = new TestObserver(SHOW_LOGS);
private final TestAdapter adapter = new TestAdapter();
private final List<EpoxyModel<?>> models = adapter.models;
@Test(expected = UnsupportedOperationException.class)
public void notifyChange() {
adapter.notifyDataSetChanged();
}
@Test
public void notifyAddedToEmpty() {
addModels(models);
adapter.notifyItemRangeInserted(0, models.size());
assertCorrectness();
}
@Test
public void notifyAddedToStart() {
addInitialModels();
addModels(models, 0);
adapter.notifyItemRangeInserted(0, models.size() - INITIAL_MODEL_COUNT);
assertCorrectness();
}
@Test
public void notifyAddedToEnd() {
addInitialModels();
addModels(models, INITIAL_MODEL_COUNT);
adapter.notifyItemRangeInserted(INITIAL_MODEL_COUNT, models.size() - INITIAL_MODEL_COUNT);
assertCorrectness();
}
@Test
public void notifyAddedToMiddle() {
addInitialModels();
addModels(models, INITIAL_MODEL_COUNT / 2);
adapter.notifyItemRangeInserted(INITIAL_MODEL_COUNT / 2, models.size() - INITIAL_MODEL_COUNT);
assertCorrectness();
}
@Test
public void notifyRemoveAll() {
addInitialModels();
models.clear();
adapter.notifyItemRangeRemoved(0, INITIAL_MODEL_COUNT);
assertCorrectness();
}
@Test
public void notifyRemoveStart() {
addInitialModels();
remove(models, 0, INITIAL_MODEL_COUNT / 2);
adapter.notifyItemRangeRemoved(0, INITIAL_MODEL_COUNT / 2);
assertCorrectness();
}
@Test
public void notifyRemoveMiddle() {
addInitialModels();
remove(models, INITIAL_MODEL_COUNT / 3, INITIAL_MODEL_COUNT / 3);
adapter.notifyItemRangeRemoved(INITIAL_MODEL_COUNT / 3, INITIAL_MODEL_COUNT / 3);
assertCorrectness();
}
@Test
public void notifyRemoveEnd() {
addInitialModels();
remove(models, INITIAL_MODEL_COUNT / 2, INITIAL_MODEL_COUNT / 2);
adapter.notifyItemRangeRemoved(INITIAL_MODEL_COUNT / 2, INITIAL_MODEL_COUNT / 2);
assertCorrectness();
}
@Test
public void notifyFrontMovedToEnd() {
addInitialModels();
EpoxyModel<?> modelToMove = models.remove(0);
models.add(modelToMove);
adapter.notifyItemMoved(0, INITIAL_MODEL_COUNT - 1);
assertCorrectness();
}
@Test
public void notifyEndMovedToFront() {
addInitialModels();
EpoxyModel<?> modelToMove = models.remove(INITIAL_MODEL_COUNT - 1);
models.add(0, modelToMove);
adapter.notifyItemMoved(INITIAL_MODEL_COUNT - 1, 0);
assertCorrectness();
}
@Test
public void notifyMiddleMovedToEnd() {
addInitialModels();
EpoxyModel<?> modelToMove = models.remove(INITIAL_MODEL_COUNT / 2);
models.add(modelToMove);
adapter.notifyItemMoved(INITIAL_MODEL_COUNT / 2, INITIAL_MODEL_COUNT - 1);
assertCorrectness();
}
@Test
public void notifyMiddleMovedToFront() {
addInitialModels();
EpoxyModel<?> modelToMove = models.remove(INITIAL_MODEL_COUNT / 2);
models.add(0, modelToMove);
adapter.notifyItemMoved(INITIAL_MODEL_COUNT / 2, 0);
assertCorrectness();
}
@Test
public void notifyValuesUpdated() {
addInitialModels();
int numModelsUpdated = 0;
for (int i = INITIAL_MODEL_COUNT / 3; i < INITIAL_MODEL_COUNT * 2 / 3; i++) {
changeValue(models.get(i));
numModelsUpdated++;
}
adapter.notifyItemRangeChanged(INITIAL_MODEL_COUNT / 3, numModelsUpdated);
assertCorrectness();
}
private void addInitialModels() {
addModels(INITIAL_MODEL_COUNT, models);
adapter.notifyModelsChanged();
}
private void assertCorrectness() {
testObserver.operationCount = 0;
adapter.registerAdapterDataObserver(testObserver);
adapter.notifyModelsChanged();
adapter.unregisterAdapterDataObserver(testObserver);
assertEquals("Should not have any operations", 0, testObserver.operationCount);
}
} | 8,886 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/InsertedModel.java | package com.airbnb.epoxy;
class InsertedModel extends TestModel {
static final InsertedModel INSTANCE = new InsertedModel();
@Override
public int getDefaultLayout() {
return 0;
}
}
| 8,887 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/ModelTestUtils.java | package com.airbnb.epoxy;
import java.util.ArrayList;
import java.util.List;
class ModelTestUtils {
private static final int DEFAULT_NUM_MODELS = 20;
static void changeValues(List models) {
changeValues(models, 0, models.size());
}
static void changeValues(List models, int start, int count) {
for (int i = start; i < count; i++) {
models.set(i, ((TestModel) models.get(i)).clone().randomizeValue());
}
}
static void changeValue(EpoxyModel<?> model) {
((TestModel) model).randomizeValue();
}
static void remove(List models, int start, int count) {
models.subList(start, start + count).clear();
}
static void removeModelsAfterPosition(List models, int start) {
remove(models, start, models.size() - start);
}
static void addModels(List list) {
addModels(DEFAULT_NUM_MODELS, list);
}
static void addModels(int count, List list) {
addModels(count, list, list.size());
}
static void addModels(List list, int index) {
addModels(DEFAULT_NUM_MODELS, list, index);
}
static void addModels(int count, List list, int index) {
List<TestModel> modelsToAdd = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
modelsToAdd.add(new TestModel());
}
list.addAll(index, modelsToAdd);
}
static List<EpoxyModel<?>> convertToGenericModels(List<TestModel> list) {
List<EpoxyModel<?>> result = new ArrayList<>(list.size());
for (TestModel testModel : list) {
result.add(testModel);
}
return result;
}
static List<TestModel> convertToTestModels(List<EpoxyModel<?>> list) {
List<TestModel> result = new ArrayList<>(list.size());
for (EpoxyModel<?> model : list) {
result.add((TestModel) model);
}
return result;
}
}
| 8,888 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/DifferCorrectnessTest.java | package com.airbnb.epoxy;
import com.google.common.collect.Collections2;
import junit.framework.Assert;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import static com.airbnb.epoxy.ModelTestUtils.addModels;
import static com.airbnb.epoxy.ModelTestUtils.changeValues;
import static com.airbnb.epoxy.ModelTestUtils.convertToTestModels;
import static com.airbnb.epoxy.ModelTestUtils.remove;
import static com.airbnb.epoxy.ModelTestUtils.removeModelsAfterPosition;
import static junit.framework.Assert.assertEquals;
@RunWith(RobolectricTestRunner.class)
public class DifferCorrectnessTest {
private static final boolean SHOW_LOGS = false;
/**
* If true, will log the time taken on the diff and skip the validation since that takes a long
* time for big change sets.
*/
private static final boolean SPEED_RUN = false;
private final TestObserver testObserver = new TestObserver(SHOW_LOGS);
private final TestAdapter testAdapter = new TestAdapter();
private final List<EpoxyModel<?>> models = testAdapter.models;
private static long totalDiffMillis = 0;
private static long totalDiffOperations = 0;
private static long totalDiffs = 0;
@BeforeClass
public static void beforeClass() {
totalDiffMillis = 0;
totalDiffOperations = 0;
totalDiffs = 0;
}
@AfterClass
public static void afterClass() {
if (SPEED_RUN) {
System.out.println("Total time for all diffs (ms): " + totalDiffMillis);
} else {
System.out.println("Total operations for diffs: " + totalDiffOperations);
double avgOperations = ((double) totalDiffOperations / totalDiffs);
System.out.println("Average operations per diff: " + avgOperations);
}
}
@Before
public void setUp() {
if (!SPEED_RUN) {
testAdapter.registerAdapterDataObserver(testObserver);
}
}
@Test
public void noChange() {
diffAndValidateWithOpCount(0);
}
@Test
public void simpleUpdate() {
addModels(models);
diffAndValidate();
changeValues(models);
diffAndValidateWithOpCount(1);
}
@Test
public void updateStart() {
addModels(models);
diffAndValidate();
changeValues(models, 0, models.size() / 2);
diffAndValidateWithOpCount(1);
}
@Test
public void updateMiddle() {
addModels(models);
diffAndValidate();
changeValues(models, models.size() / 3, models.size() * 2 / 3);
diffAndValidateWithOpCount(1);
}
@Test
public void updateEnd() {
addModels(models);
diffAndValidate();
changeValues(models, models.size() / 2, models.size());
diffAndValidateWithOpCount(1);
}
@Test
public void shuffle() {
// Tries all permutations of item shuffles, with various list sizes. Also randomizes
// item values so that the diff must deal with both item updates and movements
for (int i = 0; i < 9; i++) {
List<EpoxyModel<?>> originalModels = new ArrayList<>();
addModels(i, originalModels);
int permutationNumber = 0;
for (List<EpoxyModel<?>> permutedModels : Collections2.permutations(originalModels)) {
permutationNumber++;
// Resetting to the original models each time, otherwise each subsequent permutation is
// only a small difference
models.clear();
models.addAll(originalModels);
diffAndValidate();
models.clear();
models.addAll(permutedModels);
changeValues(models);
log("\n\n***** Permutation " + permutationNumber + " - List Size: " + i + " ****** \n");
log("old models:\n" + models);
log("\n");
log("new models:\n" + models);
log("\n");
diffAndValidate();
}
}
}
@Test
public void swapEnds() {
addModels(models);
diffAndValidate();
EpoxyModel<?> firstModel = models.remove(0);
EpoxyModel<?> lastModel = models.remove(models.size() - 1);
models.add(0, lastModel);
models.add(firstModel);
diffAndValidateWithOpCount(2);
}
@Test
public void moveFrontToEnd() {
addModels(models);
diffAndValidate();
EpoxyModel<?> firstModel = models.remove(0);
models.add(firstModel);
diffAndValidateWithOpCount(1);
}
@Test
public void moveEndToFront() {
addModels(models);
diffAndValidate();
EpoxyModel<?> lastModel = models.remove(models.size() - 1);
models.add(0, lastModel);
diffAndValidateWithOpCount(1);
}
@Test
public void moveEndToFrontAndChangeValues() {
addModels(models);
diffAndValidate();
EpoxyModel<?> lastModel = models.remove(models.size() - 1);
models.add(0, lastModel);
changeValues(models);
diffAndValidateWithOpCount(2);
}
@Test
public void swapHalf() {
addModels(models);
diffAndValidate();
List<EpoxyModel<?>> firstHalf = models.subList(0, models.size() / 2);
ArrayList<EpoxyModel<?>> firstHalfCopy = new ArrayList<>(firstHalf);
firstHalf.clear();
models.addAll(firstHalfCopy);
diffAndValidateWithOpCount(firstHalfCopy.size());
}
@Test
public void reverse() {
addModels(models);
diffAndValidate();
Collections.reverse(models);
diffAndValidate();
}
@Test
public void removeAll() {
addModels(models);
diffAndValidate();
models.clear();
diffAndValidateWithOpCount(1);
}
@Test
public void removeEnd() {
addModels(models);
diffAndValidate();
int half = models.size() / 2;
ModelTestUtils.remove(models, half, half);
diffAndValidateWithOpCount(1);
}
@Test
public void removeMiddle() {
addModels(models);
diffAndValidate();
int third = models.size() / 3;
ModelTestUtils.remove(models, third, third);
diffAndValidateWithOpCount(1);
}
@Test
public void removeStart() {
addModels(models);
diffAndValidate();
int half = models.size() / 2;
ModelTestUtils.remove(models, 0, half);
diffAndValidateWithOpCount(1);
}
@Test
public void multipleRemovals() {
addModels(models);
diffAndValidate();
int size = models.size();
int tenth = size / 10;
// Remove a tenth of the models at the end, middle, and start
ModelTestUtils.removeModelsAfterPosition(models, size - tenth);
ModelTestUtils.remove(models, size / 2, tenth);
ModelTestUtils.remove(models, 0, tenth);
diffAndValidateWithOpCount(3);
}
@Test
public void simpleAdd() {
addModels(models);
diffAndValidateWithOpCount(1);
}
@Test
public void addToStart() {
addModels(models);
diffAndValidate();
addModels(models, 0);
diffAndValidateWithOpCount(1);
}
@Test
public void addToMiddle() {
addModels(models);
diffAndValidate();
addModels(models, models.size() / 2);
diffAndValidateWithOpCount(1);
}
@Test
public void addToEnd() {
addModels(models);
diffAndValidate();
addModels(models);
diffAndValidateWithOpCount(1);
}
@Test
public void multipleInsertions() {
addModels(models);
diffAndValidate();
addModels(models, 0);
addModels(models, models.size() * 2 / 3);
addModels(models);
diffAndValidateWithOpCount(3);
}
@Test
public void moveTwoInFrontOfInsertion() {
addModels(4, models);
diffAndValidate();
addModels(1, models, 0);
EpoxyModel<?> lastModel = models.remove(models.size() - 1);
models.add(0, lastModel);
lastModel = models.remove(models.size() - 1);
models.add(0, lastModel);
diffAndValidate();
}
@Test
public void randomCombinations() {
int maxBatchSize = 3;
int maxModelCount = 10;
int maxSeed = 100000;
// This modifies the models list in a random way many times, with different size lists.
for (int modelCount = 1; modelCount < maxModelCount; modelCount++) {
for (int randomSeed = 0; randomSeed < maxSeed; randomSeed++) {
log("\n\n*** Combination seed " + randomSeed + " Model Count: " + modelCount + " *** \n");
// We keep the list from the previous loop and keep modifying it. This allows us to test
// that state is maintained properly between diffs. We just make sure the list size
// says the same by adding or removing if necessary
int currentModelCount = models.size();
if (currentModelCount < modelCount) {
addModels(modelCount - currentModelCount, models);
} else if (currentModelCount > modelCount) {
removeModelsAfterPosition(models, modelCount);
}
diffAndValidate();
modifyModelsRandomly(models, maxBatchSize, new Random(randomSeed));
log("\nResulting diff: \n");
diffAndValidate();
}
}
}
private void modifyModelsRandomly(List<EpoxyModel<?>> models, int maxBatchSize, Random random) {
for (int i = 0; i < models.size(); i++) {
int batchSize = randInt(1, maxBatchSize, random);
switch (random.nextInt(4)) {
case 0:
// insert
log("Inserting " + batchSize + " at " + i);
addModels(batchSize, models, i);
i += batchSize;
break;
case 1:
// remove
int numAvailableToRemove = models.size() - i;
batchSize = numAvailableToRemove < batchSize ? numAvailableToRemove : batchSize;
log("Removing " + batchSize + " at " + i);
remove(models, i, batchSize);
break;
case 2:
// change
int numAvailableToChange = models.size() - i;
batchSize = numAvailableToChange < batchSize ? numAvailableToChange : batchSize;
log("Changing " + batchSize + " at " + i);
changeValues(models, i, batchSize);
break;
case 3:
// move
int targetPosition = random.nextInt(models.size());
EpoxyModel<?> currentItem = models.remove(i);
models.add(targetPosition, currentItem);
log("Moving " + i + " to " + targetPosition);
break;
default:
throw new IllegalStateException("unhandled)");
}
}
}
private void diffAndValidate() {
diffAndValidateWithOpCount(-1);
}
private void diffAndValidateWithOpCount(int expectedOperationCount) {
testObserver.operationCount = 0;
long start = System.currentTimeMillis();
testAdapter.notifyModelsChanged();
long end = System.currentTimeMillis();
totalDiffMillis += (end - start);
totalDiffOperations += testObserver.operationCount;
totalDiffs++;
if (!SPEED_RUN) {
if (expectedOperationCount != -1) {
assertEquals("Operation count is incorrect", expectedOperationCount,
testObserver.operationCount);
}
List<TestModel> newModels = convertToTestModels(models);
checkDiff(testObserver.initialModels, testObserver.modelsAfterDiffing, newModels);
testObserver.setUpForNextDiff(newModels);
}
}
private static int randInt(int min, int max, Random rand) {
// nextInt is normally exclusive of the top value,
// so add 1 to make it inclusive
return rand.nextInt((max - min) + 1) + min;
}
private void log(String text) {
log(text, false);
}
private void log(String text, boolean forceShow) {
if (forceShow || SHOW_LOGS) {
System.out.println(text);
}
}
private void checkDiff(List<TestModel> modelsBeforeDiff, List<TestModel> modelsAfterDiff,
List<TestModel> actualModels) {
assertEquals("Diff produces list of different size.", actualModels.size(),
modelsAfterDiff.size());
for (int i = 0; i < modelsAfterDiff.size(); i++) {
TestModel model = modelsAfterDiff.get(i);
final TestModel expected = actualModels.get(i);
if (model == InsertedModel.INSTANCE) {
// If the item at this index is new then it shouldn't exist in the original list
for (TestModel oldModel : modelsBeforeDiff) {
Assert.assertNotSame("The inserted model should not exist in the original list",
oldModel.id(), expected.id());
}
} else {
assertEquals("Models at same index should have same id", expected.id(), model.id());
if (model.updated) {
// If there was a change operation then the item hashcodes should be different
Assert
.assertNotSame("Incorrectly updated an item.", model.hashCode(), expected.hashCode());
} else {
assertEquals("Models should have same hashcode when not updated",
expected.hashCode(), model.hashCode());
}
// Clear state so the model can be used again in another diff
model.updated = false;
}
}
}
} | 8,889 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/EpoxyAdapterTest.java | package com.airbnb.epoxy;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.util.ArrayList;
import java.util.List;
import androidx.recyclerview.widget.RecyclerView;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@RunWith(RobolectricTestRunner.class)
public class EpoxyAdapterTest {
@Rule public ExpectedException thrown = ExpectedException.none();
private final TestAdapter testAdapter = new TestAdapter();
private final TestObserver differObserver = new TestObserver();
@Mock RecyclerView.AdapterDataObserver observer;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
testAdapter.registerAdapterDataObserver(observer);
}
@Test
public void testAddModel() {
testAdapter.addModel(new TestModel());
verify(observer).onItemRangeInserted(0, 1);
assertEquals(1, testAdapter.models.size());
testAdapter.addModel(new TestModel());
verify(observer).onItemRangeInserted(1, 1);
assertEquals(2, testAdapter.models.size());
checkDifferState();
}
@Test
public void testAddModels() {
List<TestModel> list = new ArrayList<>();
list.add(new TestModel());
list.add(new TestModel());
testAdapter.addModels(list);
verify(observer).onItemRangeInserted(0, 2);
assertEquals(2, testAdapter.models.size());
List<TestModel> list2 = new ArrayList<>();
list2.add(new TestModel());
list2.add(new TestModel());
testAdapter.addModels(list2);
verify(observer).onItemRangeInserted(2, 2);
assertEquals(4, testAdapter.models.size());
checkDifferState();
}
@Test
public void testAddModelsVarArgs() {
testAdapter.addModels(new TestModel(), new TestModel());
verify(observer).onItemRangeInserted(0, 2);
assertEquals(2, testAdapter.models.size());
testAdapter.addModels(new TestModel(), new TestModel());
verify(observer).onItemRangeInserted(2, 2);
assertEquals(4, testAdapter.models.size());
checkDifferState();
}
@Test
public void testNotifyModelChanged() {
TestModel testModel = new TestModel();
testAdapter.addModels(testModel);
testAdapter.notifyModelChanged(testModel);
verify(observer).onItemRangeChanged(0, 1, null);
checkDifferState();
}
@Test
public void testNotifyModelChangedWithPayload() {
Object payload = new Object();
TestModel testModel = new TestModel();
testAdapter.addModels(testModel);
testAdapter.notifyModelChanged(testModel, payload);
verify(observer).onItemRangeChanged(0, 1, payload);
checkDifferState();
}
@Test(expected = IllegalStateException.class)
public void testInsertModelBeforeThrowsForInvalidModel() {
testAdapter.insertModelBefore(new TestModel(), new TestModel());
}
@Test()
public void testInsertModelBefore() {
TestModel firstModel = new TestModel();
testAdapter.addModels(firstModel);
testAdapter.insertModelBefore(new TestModel(), firstModel);
verify(observer, times(2)).onItemRangeInserted(0, 1);
assertEquals(2, testAdapter.models.size());
assertEquals(firstModel, testAdapter.models.get(1));
checkDifferState();
}
@Test(expected = IllegalStateException.class)
public void testInsertModelAfterThrowsForInvalidModel() {
testAdapter.insertModelAfter(new TestModel(), new TestModel());
}
@Test()
public void testInsertModelAfter() {
TestModel firstModel = new TestModel();
testAdapter.addModels(firstModel);
testAdapter.insertModelAfter(new TestModel(), firstModel);
verify(observer).onItemRangeInserted(1, 1);
assertEquals(2, testAdapter.models.size());
assertEquals(firstModel, testAdapter.models.get(0));
checkDifferState();
}
@Test
public void testRemoveModels() {
TestModel testModel = new TestModel();
testAdapter.addModels(testModel);
testAdapter.removeModel(testModel);
verify(observer).onItemRangeRemoved(0, 1);
assertEquals(0, testAdapter.models.size());
checkDifferState();
}
@Test
public void testRemoveAllModels() {
for (int i = 0; i < 10; i++) {
TestModel model = new TestModel();
testAdapter.addModels(model);
}
testAdapter.removeAllModels();
verify(observer).onItemRangeRemoved(0, 10);
assertEquals(0, testAdapter.models.size());
checkDifferState();
}
@Test
public void testRemoveAllAfterModels() {
List<TestModel> models = new ArrayList<>();
for (int i = 0; i < 10; i++) {
TestModel model = new TestModel();
models.add(model);
testAdapter.addModels(model);
}
testAdapter.removeAllAfterModel(models.get(5));
verify(observer).onItemRangeRemoved(6, 4);
assertEquals(models.subList(0, 6), testAdapter.models);
checkDifferState();
}
@Test
public void testShowModel() {
TestModel testModel = new TestModel();
testModel.hide();
testAdapter.addModels(testModel);
testAdapter.showModel(testModel);
verify(observer).onItemRangeChanged(0, 1, null);
assertTrue(testModel.isShown());
checkDifferState();
}
@Test
public void testShowModels() {
TestModel testModel1 = new TestModel();
testModel1.hide();
TestModel testModel2 = new TestModel();
testModel2.hide();
testAdapter.addModels(testModel1, testModel2);
testAdapter.showModels(testAdapter.models);
verify(observer).onItemRangeChanged(0, 1, null);
verify(observer).onItemRangeChanged(1, 1, null);
assertTrue(testModel1.isShown());
assertTrue(testModel2.isShown());
checkDifferState();
}
@Test
public void testShowModelsVarArgs() {
TestModel testModel1 = new TestModel();
testModel1.hide();
TestModel testModel2 = new TestModel();
testModel2.hide();
testAdapter.addModels(testModel1, testModel2);
testAdapter.showModels(testModel1, testModel2);
verify(observer).onItemRangeChanged(0, 1, null);
verify(observer).onItemRangeChanged(1, 1, null);
assertTrue(testModel1.isShown());
assertTrue(testModel2.isShown());
checkDifferState();
}
@Test
public void testShowModelsConditionalTrue() {
TestModel testModel1 = new TestModel();
testModel1.hide();
TestModel testModel2 = new TestModel();
testModel2.hide();
testAdapter.addModels(testModel1, testModel2);
testAdapter.showModels(testAdapter.models, true);
verify(observer).onItemRangeChanged(0, 1, null);
verify(observer).onItemRangeChanged(1, 1, null);
assertTrue(testModel1.isShown());
assertTrue(testModel2.isShown());
checkDifferState();
}
@Test
public void testShowModelsVarArgsConditionalTrue() {
TestModel testModel1 = new TestModel();
testModel1.hide();
TestModel testModel2 = new TestModel();
testModel2.hide();
testAdapter.addModels(testModel1, testModel2);
testAdapter.showModels(true, testModel1, testModel2);
verify(observer).onItemRangeChanged(0, 1, null);
verify(observer).onItemRangeChanged(1, 1, null);
assertTrue(testModel1.isShown());
assertTrue(testModel2.isShown());
checkDifferState();
}
@Test
public void testShowModelsConditionalFalse() {
TestModel testModel1 = new TestModel();
TestModel testModel2 = new TestModel();
testAdapter.addModels(testModel1, testModel2);
testAdapter.showModels(testAdapter.models, false);
verify(observer).onItemRangeChanged(0, 1, null);
verify(observer).onItemRangeChanged(1, 1, null);
assertFalse(testModel1.isShown());
assertFalse(testModel2.isShown());
checkDifferState();
}
@Test
public void testShowModelsVarArgsConditionalFalse() {
TestModel testModel1 = new TestModel();
TestModel testModel2 = new TestModel();
testAdapter.addModels(testModel1, testModel2);
testAdapter.showModels(false, testModel1, testModel2);
verify(observer).onItemRangeChanged(0, 1, null);
verify(observer).onItemRangeChanged(1, 1, null);
assertFalse(testModel1.isShown());
assertFalse(testModel2.isShown());
checkDifferState();
}
@Test
public void testShowModelNoopIfAlreadyShown() {
TestModel testModel = new TestModel();
testAdapter.addModels(testModel);
testAdapter.showModel(testModel);
verify(observer, times(0)).onItemRangeChanged(0, 1, null);
assertTrue(testModel.isShown());
}
@Test
public void testHideModel() {
TestModel testModel = new TestModel();
testAdapter.addModels(testModel);
testAdapter.hideModel(testModel);
verify(observer).onItemRangeChanged(0, 1, null);
assertFalse(testModel.isShown());
checkDifferState();
}
@Test
public void testHideModels() {
TestModel testModel1 = new TestModel();
TestModel testModel2 = new TestModel();
testAdapter.addModels(testModel1, testModel2);
testAdapter.hideModels(testAdapter.models);
verify(observer).onItemRangeChanged(0, 1, null);
verify(observer).onItemRangeChanged(1, 1, null);
assertFalse(testModel1.isShown());
assertFalse(testModel2.isShown());
checkDifferState();
}
@Test
public void testHideModelsVarArgs() {
TestModel testModel1 = new TestModel();
TestModel testModel2 = new TestModel();
testAdapter.addModels(testModel1, testModel2);
testAdapter.hideModels(testModel1, testModel2);
verify(observer).onItemRangeChanged(0, 1, null);
verify(observer).onItemRangeChanged(1, 1, null);
assertFalse(testModel1.isShown());
assertFalse(testModel2.isShown());
checkDifferState();
}
@Test
public void testHideAllAfterModel() {
List<TestModel> models = new ArrayList<>();
int modelCount = 10;
for (int i = 0; i < modelCount; i++) {
TestModel model = new TestModel();
models.add(model);
testAdapter.addModels(model);
}
int hideIndex = 5;
testAdapter.hideAllAfterModel(models.get(hideIndex));
for (int i = hideIndex + 1; i < modelCount; i++) {
verify(observer).onItemRangeChanged(i, 1, null);
}
for (int i = 0; i < modelCount; i++) {
assertEquals(i <= hideIndex, models.get(i).isShown());
}
checkDifferState();
}
@Test
public void testThrowIfChangeModelIdAfterNotify() {
TestModel testModel = new TestModel();
testModel.id(100);
testAdapter.addModel(testModel);
thrown.expect(IllegalEpoxyUsage.class);
thrown.expectMessage("Cannot change a model's id after it has been added to the adapter");
testModel.id(200);
}
@Test
public void testAllowSetSameModelIdAfterNotify() {
TestModel testModel = new TestModel();
testModel.id(100);
testAdapter.addModel(testModel);
testModel.id(100);
}
@Test
public void testThrowIfChangeModelIdAfterDiff() {
TestModel testModel = new TestModel();
testModel.id(100);
testAdapter.models.add(testModel);
testAdapter.notifyModelsChanged();
thrown.expect(IllegalEpoxyUsage.class);
thrown.expectMessage("Cannot change a model's id after it has been added to the adapter");
testModel.id(200);
}
/** Make sure that the differ is in a correct state, and then running it produces no changes. */
private void checkDifferState() {
differObserver.operationCount = 0;
testAdapter.registerAdapterDataObserver(differObserver);
testAdapter.notifyModelsChanged();
testAdapter.unregisterAdapterDataObserver(differObserver);
Assert.assertEquals("Should not have any operations", 0, differObserver.operationCount);
}
}
| 8,890 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/DiffPayloadTest.java | package com.airbnb.epoxy;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatcher;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
import static com.airbnb.epoxy.DiffPayload.getModelFromPayload;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@RunWith(RobolectricTestRunner.class)
public class DiffPayloadTest {
private final List<EpoxyModel<?>> models = new ArrayList<>();
private BaseEpoxyAdapter adapter;
private AdapterDataObserver observer;
@Before
public void before() {
adapter = new BaseEpoxyAdapter() {
@Override
List<EpoxyModel<?>> getCurrentModels() {
return models;
}
};
observer = spy(new AdapterDataObserver() {
@Override
public void onItemRangeChanged(int positionStart, int itemCount, Object payload) {
}
});
adapter.registerAdapterDataObserver(observer);
}
@Test
public void payloadsDisabled() {
DiffHelper diffHelper = new DiffHelper(adapter, false);
TestModel firstModel = new TestModel();
models.add(firstModel);
diffHelper.notifyModelChanges();
verify(observer).onItemRangeInserted(0, 1);
TestModel updatedFirstModel = firstModel.clone().incrementValue();
models.clear();
models.add(updatedFirstModel);
diffHelper.notifyModelChanges();
verify(observer).onItemRangeChanged(0, 1, null);
verifyNoMoreInteractions(observer);
}
@Test
public void noPayloadsForNoChanges() {
DiffHelper diffHelper = new DiffHelper(adapter, true);
TestModel firstModel = new TestModel();
models.add(firstModel);
diffHelper.notifyModelChanges();
verify(observer).onItemRangeInserted(0, 1);
models.clear();
diffHelper.notifyModelChanges();
verify(observer).onItemRangeRemoved(0, 1);
verifyNoMoreInteractions(observer);
}
@Test
public void singlePayload() {
DiffHelper diffHelper = new DiffHelper(adapter, true);
TestModel firstModel = new TestModel();
models.add(firstModel);
diffHelper.notifyModelChanges();
verify(observer).onItemRangeInserted(0, 1);
models.clear();
TestModel changedFirstModel = firstModel.clone().incrementValue();
this.models.add(changedFirstModel);
diffHelper.notifyModelChanges();
verify(observer).onItemRangeChanged(eq(0), eq(1), argThat(new DiffPayloadMatcher(firstModel)));
verifyNoMoreInteractions(observer);
}
@Test
public void batchPayload() {
DiffHelper diffHelper = new DiffHelper(adapter, true);
TestModel firstModel = new TestModel();
TestModel secondModel = new TestModel();
models.add(firstModel);
models.add(secondModel);
diffHelper.notifyModelChanges();
TestModel changedFirstModel = firstModel.clone().incrementValue();
TestModel changedSecondModel = secondModel.clone().incrementValue();
models.clear();
models.add(changedFirstModel);
models.add(changedSecondModel);
diffHelper.notifyModelChanges();
verify(observer)
.onItemRangeChanged(eq(0), eq(2), argThat(new DiffPayloadMatcher(firstModel, secondModel)));
}
@Test
public void multiplePayloads() {
DiffHelper diffHelper = new DiffHelper(adapter, true);
TestModel firstModel = new TestModel();
TestModel secondModel = new TestModel();
TestModel thirdModel = new TestModel();
models.add(firstModel);
models.add(thirdModel);
diffHelper.notifyModelChanges();
TestModel changedFirstModel = firstModel.clone().incrementValue();
TestModel changedThirdModel = thirdModel.clone().incrementValue();
models.clear();
models.add(changedFirstModel);
models.add(secondModel);
models.add(changedThirdModel);
diffHelper.notifyModelChanges();
verify(observer).onItemRangeChanged(eq(0), eq(1), argThat(new DiffPayloadMatcher(firstModel)));
verify(observer).onItemRangeChanged(eq(2), eq(1), argThat(new DiffPayloadMatcher(thirdModel)));
}
@Test
public void getSingleModelFromPayload() {
TestModel model = new TestModel();
List<Object> payloads = payloadsWithChangedModels(model);
EpoxyModel<?> modelFromPayload = getModelFromPayload(payloads, model.id());
assertEquals(model, modelFromPayload);
}
@Test
public void returnsNullWhenNoModelFoundInPayload() {
TestModel model = new TestModel();
List<Object> payloads = payloadsWithChangedModels(model);
EpoxyModel<?> modelFromPayload = getModelFromPayload(payloads, model.id() - 1);
assertNull(modelFromPayload);
}
@Test
public void returnsNullForEmptyPayload() {
List<Object> payloads = new ArrayList<>();
EpoxyModel<?> modelFromPayload = getModelFromPayload(payloads, 2);
assertNull(modelFromPayload);
}
@Test
public void getMultipleModelsFromPayload() {
TestModel model1 = new TestModel();
TestModel model2 = new TestModel();
List<Object> payloads = payloadsWithChangedModels(model1, model2);
EpoxyModel<?> modelFromPayload1 = getModelFromPayload(payloads, model1.id());
EpoxyModel<?> modelFromPayload2 = getModelFromPayload(payloads, model2.id());
assertEquals(model1, modelFromPayload1);
assertEquals(model2, modelFromPayload2);
}
@Test
public void getSingleModelsFromMultipleDiffPayloads() {
TestModel model1 = new TestModel();
DiffPayload diffPayload1 = diffPayloadWithModels(model1);
TestModel model2 = new TestModel();
DiffPayload diffPayload2 = diffPayloadWithModels(model2);
List<Object> payloads = payloadsWithDiffPayloads(diffPayload1, diffPayload2);
EpoxyModel<?> modelFromPayload1 = getModelFromPayload(payloads, model1.id());
EpoxyModel<?> modelFromPayload2 = getModelFromPayload(payloads, model2.id());
assertEquals(model1, modelFromPayload1);
assertEquals(model2, modelFromPayload2);
}
@Test
public void getMultipleModelsFromMultipleDiffPayloads() {
TestModel model1Payload1 = new TestModel(1);
TestModel model2Payload1 = new TestModel(2);
DiffPayload diffPayload1 = diffPayloadWithModels(model1Payload1, model2Payload1);
TestModel model1Payload2 = new TestModel(3);
TestModel model2Payload2 = new TestModel(4);
DiffPayload diffPayload2 = diffPayloadWithModels(model1Payload2, model2Payload2);
List<Object> payloads = payloadsWithDiffPayloads(diffPayload1, diffPayload2);
EpoxyModel<?> model1FromPayload1 = getModelFromPayload(payloads, model1Payload1.id());
EpoxyModel<?> model2FromPayload1 = getModelFromPayload(payloads, model2Payload1.id());
EpoxyModel<?> model1FromPayload2 = getModelFromPayload(payloads, model1Payload2.id());
EpoxyModel<?> model2FromPayload2 = getModelFromPayload(payloads, model2Payload2.id());
assertEquals(model1Payload1, model1FromPayload1);
assertEquals(model2Payload1, model2FromPayload1);
assertEquals(model1Payload2, model1FromPayload2);
assertEquals(model2Payload2, model2FromPayload2);
}
static class DiffPayloadMatcher implements ArgumentMatcher<DiffPayload> {
private final DiffPayload expectedPayload;
DiffPayloadMatcher(EpoxyModel<?>... changedModels) {
List<EpoxyModel<?>> epoxyModels = Arrays.asList(changedModels);
expectedPayload = new DiffPayload(epoxyModels);
}
@Override
public boolean matches(DiffPayload argument) {
return expectedPayload.equalsForTesting(argument);
}
}
static DiffPayload diffPayloadWithModels(EpoxyModel<?>... models) {
List<EpoxyModel<?>> epoxyModels = Arrays.asList(models);
return new DiffPayload(epoxyModels);
}
static List<Object> payloadsWithDiffPayloads(DiffPayload... diffPayloads) {
List<DiffPayload> payloads = Arrays.asList(diffPayloads);
return new ArrayList<Object>(payloads);
}
static List<Object> payloadsWithChangedModels(EpoxyModel<?>... models) {
return payloadsWithDiffPayloads(diffPayloadWithModels(models));
}
}
| 8,891 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/ViewTypeManagerIntegrationTest.java | package com.airbnb.epoxy;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import androidx.annotation.NonNull;
import androidx.test.core.app.ApplicationProvider;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@RunWith(RobolectricTestRunner.class)
public class ViewTypeManagerIntegrationTest {
@Before
public void resetViewTypeMap() {
new ViewTypeManager().resetMapForTesting();
}
static class TestModel extends EpoxyModelWithView<View> {
@Override
public View buildView(@NonNull ViewGroup parent) {
return new FrameLayout(ApplicationProvider.getApplicationContext());
}
}
static class ModelWithViewType extends TestModel {
@Override
protected int getViewType() {
return 1;
}
}
static class ModelWithViewType2 extends TestModel {
@Override
protected int getViewType() {
return 2;
}
}
@Test
public void modelWithLayout() {
SimpleEpoxyAdapter adapter = new SimpleEpoxyAdapter();
adapter.addModel(new ModelWithViewType());
adapter.addModel(new ModelWithViewType2());
// The view type should be the value declared in the model
assertEquals(1, adapter.getItemViewType(0));
assertEquals(2, adapter.getItemViewType(1));
}
static class ModelWithoutViewType extends TestModel {}
static class ModelWithoutViewType2 extends TestModel {}
static class ModelWithoutViewType3 extends TestModel {}
@Test
public void modelsWithoutLayoutHaveViewTypesGenerated() {
SimpleEpoxyAdapter adapter = new SimpleEpoxyAdapter();
adapter.addModel(new ModelWithoutViewType());
adapter.addModel(new ModelWithoutViewType2());
adapter.addModel(new ModelWithoutViewType3());
adapter.addModel(new ModelWithoutViewType());
adapter.addModel(new ModelWithoutViewType2());
adapter.addModel(new ModelWithoutViewType3());
// Models with view type 0 should have a view type generated for them
assertEquals(-1, adapter.getItemViewType(0));
assertEquals(-2, adapter.getItemViewType(1));
assertEquals(-3, adapter.getItemViewType(2));
// Models of same class should share the same generated view type
assertEquals(-1, adapter.getItemViewType(3));
assertEquals(-2, adapter.getItemViewType(4));
assertEquals(-3, adapter.getItemViewType(5));
}
@Test
public void fastModelLookupOfLastModel() {
SimpleEpoxyAdapter adapter = spy(new SimpleEpoxyAdapter());
TestModel modelToAdd = spy(new ModelWithoutViewType());
adapter.addModel(modelToAdd);
int itemViewType = adapter.getItemViewType(0);
adapter.onCreateViewHolder(null, itemViewType);
// onExceptionSwallowed is called if the fast model look up failed
verify(adapter, never()).onExceptionSwallowed(any(RuntimeException.class));
verify(modelToAdd).buildView(null);
}
@Test
public void fallbackLookupOfUnknownModel() {
SimpleEpoxyAdapter adapter = spy(new SimpleEpoxyAdapter());
TestModel modelToAdd = spy(new ModelWithViewType());
adapter.addModel(modelToAdd);
// If we pass a view type that hasn't been looked up recently it should fallback to searching
// through all models to find a match.
adapter.onCreateViewHolder(null, 1);
// onExceptionSwallowed is called when the fast model look up fails
verify(adapter).onExceptionSwallowed(any(RuntimeException.class));
verify(modelToAdd).buildView(null);
}
@Test
public void viewTypesSharedAcrossAdapters() {
SimpleEpoxyAdapter adapter1 = new SimpleEpoxyAdapter();
SimpleEpoxyAdapter adapter2 = new SimpleEpoxyAdapter();
adapter1.addModel(new ModelWithoutViewType());
adapter1.addModel(new ModelWithoutViewType2());
adapter2.addModel(new ModelWithoutViewType());
adapter2.addModel(new ModelWithoutViewType2());
assertEquals(adapter1.getItemViewType(0), adapter2.getItemViewType(0));
assertEquals(adapter1.getItemViewType(1), adapter2.getItemViewType(1));
}
}
| 8,892 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/TestModel.java | package com.airbnb.epoxy;
import android.view.View;
import java.util.Random;
public class TestModel extends EpoxyModel<View> {
private static final Random RANDOM = new Random(10);
boolean updated;
private int value;
public TestModel() {
// Uses a random id to make sure the algorithm doesn't have different behavior for
// consecutive or varied ids
super(RANDOM.nextLong());
randomizeValue();
}
public TestModel(long id) {
super(id);
randomizeValue();
}
TestModel randomizeValue() {
value = RANDOM.nextInt();
return this;
}
@Override
public int getDefaultLayout() {
return 0;
}
TestModel value(int value) {
this.value = value;
return this;
}
TestModel incrementValue() {
this.value++;
return this;
}
int value() {
return value;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}
TestModel testModel = (TestModel) o;
return value == testModel.value;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + value;
return result;
}
public TestModel clone() {
TestModel clone = new TestModel()
.value(value);
return (TestModel) clone.id(id())
.layout(getLayout());
}
}
| 8,893 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/TypedEpoxyControllerTest.java | package com.airbnb.epoxy;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.LooperMode;
import org.robolectric.annotation.LooperMode.Mode;
import static junit.framework.Assert.assertEquals;
@RunWith(RobolectricTestRunner.class)
@LooperMode(Mode.LEGACY)
public class TypedEpoxyControllerTest {
static class TestTypedController extends TypedEpoxyController<String> {
int numTimesBuiltModels = 0;
@Override
protected void buildModels(String data) {
assertEquals("data", data);
numTimesBuiltModels++;
}
}
@Test
public void setData() {
TestTypedController controller = new TestTypedController();
controller.setData("data");
controller.setData("data");
controller.cancelPendingModelBuild();
controller.setData("data");
controller.setData("data");
assertEquals(4, controller.numTimesBuiltModels);
}
} | 8,894 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/TestAdapter.java | package com.airbnb.epoxy;
class TestAdapter extends EpoxyAdapter {
TestAdapter() {
enableDiffing();
}
}
| 8,895 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/ModelListTest.java | package com.airbnb.epoxy;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@RunWith(RobolectricTestRunner.class)
public class ModelListTest {
private final ModelList.ModelListObserver observer = mock(ModelList.ModelListObserver.class);
private final ModelList modelList = new ModelList();
@Before
public void before() {
modelList.add(new TestModel());
modelList.add(new TestModel());
modelList.add(new TestModel());
modelList.setObserver(observer);
}
@Test
public void testSet() {
modelList.set(0, new TestModel());
verify(observer).onItemRangeRemoved(0, 1);
verify(observer).onItemRangeInserted(0, 1);
}
@Test
public void testSetSameIdDoesntNotify() {
EpoxyModel<?> newModelWithSameId = new TestModel();
newModelWithSameId.id(modelList.get(0).id());
modelList.set(0, newModelWithSameId);
verifyNoMoreInteractions(observer);
assertEquals(newModelWithSameId, modelList.get(0));
}
@Test
public void testAdd() {
modelList.add(new TestModel());
modelList.add(new TestModel());
verify(observer).onItemRangeInserted(3, 1);
verify(observer).onItemRangeInserted(4, 1);
}
@Test
public void testAddAtIndex() {
modelList.add(0, new TestModel());
modelList.add(2, new TestModel());
verify(observer).onItemRangeInserted(0, 1);
verify(observer).onItemRangeInserted(2, 1);
}
@Test
public void testAddAll() {
List<EpoxyModel<?>> newModels = new ArrayList<>();
newModels.add(new TestModel());
newModels.add(new TestModel());
modelList.addAll(newModels);
verify(observer).onItemRangeInserted(3, 2);
}
@Test
public void testAddAllAtIndex() {
List<EpoxyModel<?>> newModels = new ArrayList<>();
newModels.add(new TestModel());
newModels.add(new TestModel());
modelList.addAll(0, newModels);
verify(observer).onItemRangeInserted(0, 2);
}
@Test
public void testRemoveIndex() {
EpoxyModel<?> removedModel = modelList.remove(0);
assertFalse(modelList.contains(removedModel));
assertEquals(2, modelList.size());
verify(observer).onItemRangeRemoved(0, 1);
}
@Test
public void testRemoveObject() {
EpoxyModel<?> model = modelList.get(0);
boolean model1Removed = modelList.remove(model);
assertEquals(2, modelList.size());
assertTrue(model1Removed);
assertFalse(modelList.contains(model));
verify(observer).onItemRangeRemoved(0, 1);
}
@Test
public void testRemoveObjectNotAdded() {
boolean removed = modelList.remove(new TestModel());
assertFalse(removed);
verifyNoMoreInteractions(observer);
}
@Test
public void testClear() {
modelList.clear();
verify(observer).onItemRangeRemoved(0, 3);
}
@Test
public void testClearWhenAlreadyEmpty() {
modelList.clear();
modelList.clear();
verify(observer).onItemRangeRemoved(0, 3);
verifyNoMoreInteractions(observer);
}
@Test
public void testSublistClear() {
modelList.subList(0, 2).clear();
verify(observer).onItemRangeRemoved(0, 2);
}
@Test
public void testNoClearWhenEmpty() {
modelList.clear();
modelList.clear();
verify(observer).onItemRangeRemoved(0, 3);
verifyNoMoreInteractions(observer);
}
@Test
public void testRemoveRange() {
modelList.removeRange(0, 2);
assertEquals(1, modelList.size());
verify(observer).onItemRangeRemoved(0, 2);
}
@Test
public void testRemoveEmptyRange() {
modelList.removeRange(1, 1);
verifyNoMoreInteractions(observer);
}
@Test
public void testIteratorRemove() {
Iterator<EpoxyModel<?>> iterator = modelList.iterator();
iterator.next();
iterator.remove();
verify(observer).onItemRangeRemoved(0, 1);
}
@Test
public void testRemoveAll() {
List<EpoxyModel<?>> modelsToRemove = new ArrayList<>();
modelsToRemove.add(modelList.get(0));
modelsToRemove.add(modelList.get(1));
modelList.removeAll(modelsToRemove);
verify(observer, times(2)).onItemRangeRemoved(0, 1);
}
@Test
public void testRetainAll() {
List<EpoxyModel<?>> modelsToRetain = new ArrayList<>();
modelsToRetain.add(modelList.get(0));
modelList.retainAll(modelsToRetain);
verify(observer, times(2)).onItemRangeRemoved(1, 1);
}
} | 8,896 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/EpoxyControllerTest.java | package com.airbnb.epoxy;
import com.airbnb.epoxy.EpoxyController.Interceptor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.util.ArrayList;
import java.util.List;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
import static junit.framework.Assert.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@RunWith(RobolectricTestRunner.class)
public class EpoxyControllerTest {
List<EpoxyModel<?>> savedModels;
boolean noExceptionsDuringBasicBuildModels = true;
@Test
public void basicBuildModels() {
AdapterDataObserver observer = mock(AdapterDataObserver.class);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
new TestModel()
.addTo(this);
}
@Override
protected void onExceptionSwallowed(RuntimeException exception) {
noExceptionsDuringBasicBuildModels = false;
}
};
controller.getAdapter().registerAdapterDataObserver(observer);
controller.requestModelBuild();
assertTrue(noExceptionsDuringBasicBuildModels);
assertEquals(1, controller.getAdapter().getItemCount());
verify(observer).onItemRangeInserted(0, 1);
verifyNoMoreInteractions(observer);
}
@Test(expected = IllegalEpoxyUsage.class)
public void addingSameModelTwiceThrows() {
final CarouselModel_ model = new CarouselModel_();
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(model);
add(model);
}
};
controller.requestModelBuild();
}
@Test
public void filterDuplicates() {
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
new TestModel()
.id(1)
.addTo(this);
new TestModel()
.id(1)
.addTo(this);
}
};
controller.setFilterDuplicates(true);
controller.requestModelBuild();
assertEquals(1, controller.getAdapter().getItemCount());
}
boolean exceptionSwallowed;
@Test
public void exceptionSwallowedWhenDuplicateFiltered() {
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
new TestModel()
.id(1)
.addTo(this);
new TestModel()
.id(1)
.addTo(this);
}
@Override
protected void onExceptionSwallowed(RuntimeException exception) {
exceptionSwallowed = true;
}
};
controller.setFilterDuplicates(true);
controller.requestModelBuild();
assertTrue(exceptionSwallowed);
}
boolean interceptorCalled;
@Test
public void interceptorRunsAfterBuildModels() {
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
new TestModel()
.addTo(this);
}
};
controller.addInterceptor(new Interceptor() {
@Override
public void intercept(List<EpoxyModel<?>> models) {
assertEquals(1, models.size());
interceptorCalled = true;
}
});
controller.requestModelBuild();
assertTrue(interceptorCalled);
assertEquals(1, controller.getAdapter().getItemCount());
}
@Test
public void interceptorCanAddModels() {
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
new TestModel()
.addTo(this);
}
};
controller.addInterceptor(new Interceptor() {
@Override
public void intercept(List<EpoxyModel<?>> models) {
models.add(new TestModel());
}
});
controller.requestModelBuild();
assertEquals(2, controller.getAdapter().getItemCount());
}
@Test(expected = IllegalStateException.class)
public void savedModelsCannotBeAddedToLater() {
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
new TestModel()
.addTo(this);
}
};
controller.addInterceptor(new Interceptor() {
@Override
public void intercept(List<EpoxyModel<?>> models) {
savedModels = models;
}
});
controller.requestModelBuild();
savedModels.add(new TestModel());
}
@Test
public void interceptorCanModifyModels() {
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
new TestModel()
.addTo(this);
}
};
controller.addInterceptor(new Interceptor() {
@Override
public void intercept(List<EpoxyModel<?>> models) {
TestModel model = ((TestModel) models.get(0));
model.value(model.value() + 1);
}
});
controller.requestModelBuild();
}
@Test
public void interceptorsRunInOrderAdded() {
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
new TestModel()
.addTo(this);
}
};
controller.addInterceptor(new Interceptor() {
@Override
public void intercept(List<EpoxyModel<?>> models) {
assertEquals(1, models.size());
models.add(new TestModel());
}
});
controller.addInterceptor(new Interceptor() {
@Override
public void intercept(List<EpoxyModel<?>> models) {
assertEquals(2, models.size());
models.add(new TestModel());
}
});
controller.requestModelBuild();
assertEquals(3, controller.getAdapter().getItemCount());
}
@Test
public void moveModel() {
AdapterDataObserver observer = mock(AdapterDataObserver.class);
final List<TestModel> testModels = new ArrayList<>();
testModels.add(new TestModel(1));
testModels.add(new TestModel(2));
testModels.add(new TestModel(3));
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(testModels);
}
};
EpoxyControllerAdapter adapter = controller.getAdapter();
adapter.registerAdapterDataObserver(observer);
controller.requestModelBuild();
verify(observer).onItemRangeInserted(0, 3);
testModels.add(0, testModels.remove(1));
controller.moveModel(1, 0);
verify(observer).onItemRangeMoved(1, 0, 1);
assertEquals(testModels, adapter.getCurrentModels());
controller.requestModelBuild();
assertEquals(testModels, adapter.getCurrentModels());
verifyNoMoreInteractions(observer);
}
@Test
public void moveModelOtherWay() {
AdapterDataObserver observer = mock(AdapterDataObserver.class);
final List<TestModel> testModels = new ArrayList<>();
testModels.add(new TestModel(1));
testModels.add(new TestModel(2));
testModels.add(new TestModel(3));
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(testModels);
}
};
EpoxyControllerAdapter adapter = controller.getAdapter();
adapter.registerAdapterDataObserver(observer);
controller.requestModelBuild();
verify(observer).onItemRangeInserted(0, 3);
testModels.add(2, testModels.remove(1));
controller.moveModel(1, 2);
verify(observer).onItemRangeMoved(1, 2, 1);
assertEquals(testModels, adapter.getCurrentModels());
controller.requestModelBuild();
assertEquals(testModels, adapter.getCurrentModels());
verifyNoMoreInteractions(observer);
}
@Test
public void multipleMoves() {
AdapterDataObserver observer = mock(AdapterDataObserver.class);
final List<TestModel> testModels = new ArrayList<>();
testModels.add(new TestModel(1));
testModels.add(new TestModel(2));
testModels.add(new TestModel(3));
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
add(testModels);
}
};
EpoxyControllerAdapter adapter = controller.getAdapter();
adapter.registerAdapterDataObserver(observer);
controller.requestModelBuild();
testModels.add(0, testModels.remove(1));
controller.moveModel(1, 0);
verify(observer).onItemRangeMoved(1, 0, 1);
testModels.add(2, testModels.remove(1));
controller.moveModel(1, 2);
verify(observer).onItemRangeMoved(1, 2, 1);
assertEquals(testModels, adapter.getCurrentModels());
controller.requestModelBuild();
assertEquals(testModels, adapter.getCurrentModels());
}
@Test
public void testDuplicateFilteringDisabledByDefault() {
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
}
};
assertFalse(controller.isDuplicateFilteringEnabled());
}
@Test
public void testDuplicateFilteringCanBeToggled() {
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
}
};
assertFalse(controller.isDuplicateFilteringEnabled());
controller.setFilterDuplicates(true);
assertTrue(controller.isDuplicateFilteringEnabled());
controller.setFilterDuplicates(false);
assertFalse(controller.isDuplicateFilteringEnabled());
}
@Test
public void testGlobalDuplicateFilteringDefault() {
EpoxyController.setGlobalDuplicateFilteringDefault(true);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
}
};
assertTrue(controller.isDuplicateFilteringEnabled());
controller.setFilterDuplicates(false);
assertFalse(controller.isDuplicateFilteringEnabled());
controller.setFilterDuplicates(true);
assertTrue(controller.isDuplicateFilteringEnabled());
// Reset static field for future tests
EpoxyController.setGlobalDuplicateFilteringDefault(false);
}
@Test
public void testDebugLoggingCanBeToggled() {
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
}
};
assertFalse(controller.isDebugLoggingEnabled());
controller.setDebugLoggingEnabled(true);
assertTrue(controller.isDebugLoggingEnabled());
controller.setDebugLoggingEnabled(false);
assertFalse(controller.isDebugLoggingEnabled());
}
@Test
public void testGlobalDebugLoggingDefault() {
EpoxyController.setGlobalDebugLoggingEnabled(true);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
}
};
assertTrue(controller.isDebugLoggingEnabled());
controller.setDebugLoggingEnabled(false);
assertFalse(controller.isDebugLoggingEnabled());
controller.setDebugLoggingEnabled(true);
assertTrue(controller.isDebugLoggingEnabled());
// Reset static field for future tests
EpoxyController.setGlobalDebugLoggingEnabled(false);
}
@Test
public void testModelBuildListener() {
OnModelBuildFinishedListener observer = mock(OnModelBuildFinishedListener.class);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
new TestModel()
.addTo(this);
}
};
controller.addModelBuildListener(observer);
controller.requestModelBuild();
verify(observer).onModelBuildFinished(any(DiffResult.class));
}
@Test
public void testRemoveModelBuildListener() {
OnModelBuildFinishedListener observer = mock(OnModelBuildFinishedListener.class);
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
new TestModel()
.addTo(this);
}
};
controller.addModelBuildListener(observer);
controller.removeModelBuildListener(observer);
controller.requestModelBuild();
verify(observer, never()).onModelBuildFinished(any(DiffResult.class));
}
@Test
public void testDiffInProgress() {
EpoxyController controller = new EpoxyController() {
@Override
protected void buildModels() {
assertTrue(this.hasPendingModelBuild());
new TestModel()
.addTo(this);
}
};
assertFalse(controller.hasPendingModelBuild());
controller.requestModelBuild();
// Model build should happen synchronously in tests
assertFalse(controller.hasPendingModelBuild());
}
}
| 8,897 |
0 | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy | Create_ds/epoxy/epoxy-adapter/src/test/java/com/airbnb/epoxy/test/CarouselTest.java | package com.airbnb.epoxy.test;
import android.content.Context;
import com.airbnb.epoxy.Carousel;
import com.airbnb.epoxy.Carousel.SnapHelperFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearSnapHelper;
import androidx.recyclerview.widget.SnapHelper;
@RunWith(RobolectricTestRunner.class)
public class CarouselTest {
@Test
public void testOverrideGlobalSnapHelper() {
Carousel.setDefaultGlobalSnapHelperFactory(new SnapHelperFactory() {
@NonNull
@Override
public SnapHelper buildSnapHelper(Context context) {
return new LinearSnapHelper();
}
});
}
@Test
public void testODisableGlobalSnapHelper() {
Carousel.setDefaultGlobalSnapHelperFactory(null);
}
}
| 8,898 |
0 | Create_ds/epoxy/epoxy-adapter/src/main/java/com/airbnb | Create_ds/epoxy/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyDiffLogger.java | package com.airbnb.epoxy;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
/**
* This data observer can be registered with an Epoxy adapter or controller to log all item change
* events. This may be useful to use in debug builds in order to observe model updates and monitor
* for issues.
* <p>
* You may want to look for unexpected item updates to catch improper hashCode/equals
* implementations in your models.
* <p>
* Additionally, you may want to look for frequent or unnecessary updates as an opportunity for
* optimization.
*/
public class EpoxyDiffLogger extends AdapterDataObserver {
private final String tag;
public EpoxyDiffLogger(String tag) {
this.tag = tag;
}
@Override
public void onItemRangeChanged(int positionStart, int itemCount) {
Log.d(tag, "Item range changed. Start: " + positionStart + " Count: " + itemCount);
}
@Override
public void onItemRangeChanged(int positionStart, int itemCount, @Nullable Object payload) {
if (payload == null) {
onItemRangeChanged(positionStart, itemCount);
} else {
Log.d(tag,
"Item range changed with payloads. Start: " + positionStart + " Count: " + itemCount);
}
}
@Override
public void onItemRangeInserted(int positionStart, int itemCount) {
Log.d(tag, "Item range inserted. Start: " + positionStart + " Count: " + itemCount);
}
@Override
public void onItemRangeRemoved(int positionStart, int itemCount) {
Log.d(tag, "Item range removed. Start: " + positionStart + " Count: " + itemCount);
}
@Override
public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
Log.d(tag, "Item moved. From: " + fromPosition + " To: " + toPosition);
}
}
| 8,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.