Skip to content

Commit

Permalink
Add @nullable to all public methods of Component.Builder
Browse files Browse the repository at this point in the history
Summary: These methods are all allowed to accept null so should be Nullable.

Reviewed By: IanChilds

Differential Revision: D8848724

fbshipit-source-id: 7df0b80aa338154f3e1d9bd30d555739cd61e4be
  • Loading branch information
thurn authored and facebook-github-bot committed Jul 16, 2018
1 parent caf209b commit d0844fe
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 88 deletions.
72 changes: 40 additions & 32 deletions litho-core/src/main/java/com/facebook/litho/CommonPropsHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public int getDefStyleRes() {
return mDefStyleRes;
}

void positionType(YogaPositionType positionType) {
void positionType(@Nullable YogaPositionType positionType) {
mPrivateFlags |= PFLAG_POSITION_TYPE_IS_SET;
mPositionType = positionType;
}
Expand All @@ -98,7 +98,7 @@ public YogaPositionType getPositionType() {
return mPositionType;
}

void positionPx(YogaEdge edge, @Px int position) {
void positionPx(@Nullable YogaEdge edge, @Px int position) {
mPrivateFlags |= PFLAG_POSITION_IS_SET;
if (mPositions == null) {
mPositions =
Expand Down Expand Up @@ -130,7 +130,7 @@ public int getHeightPx() {
return mHeightPx;
}

void background(Reference<? extends Drawable> background) {
void background(@Nullable Reference<? extends Drawable> background) {
mPrivateFlags |= PFLAG_BACKGROUND_IS_SET;
mBackground = background;
}
Expand Down Expand Up @@ -161,7 +161,7 @@ public boolean isWrapInView() {
return mWrapInView;
}

void layoutDirection(YogaDirection direction) {
void layoutDirection(@Nullable YogaDirection direction) {
getOrCreateOtherProps().layoutDirection(direction);
}

Expand All @@ -171,7 +171,7 @@ public YogaDirection getLayoutDirection() {
return getOrCreateOtherProps().mLayoutDirection;
}

void alignSelf(YogaAlign alignSelf) {
void alignSelf(@Nullable YogaAlign alignSelf) {
getOrCreateOtherProps().alignSelf(alignSelf);
}

Expand Down Expand Up @@ -275,7 +275,7 @@ public Border getBorder() {
return getOrCreateOtherProps().mBorder;
}

void stateListAnimator(StateListAnimator stateListAnimator) {
void stateListAnimator(@Nullable StateListAnimator stateListAnimator) {
getOrCreateOtherProps().stateListAnimator(stateListAnimator);
}

Expand All @@ -295,7 +295,7 @@ public int getStateListAnimatorRes() {
return getOrCreateOtherProps().mStateListAnimatorRes;
}

void positionPercent(YogaEdge edge, float percent) {
void positionPercent(@Nullable YogaEdge edge, float percent) {
getOrCreateOtherProps().positionPercent(edge, percent);
}

Expand Down Expand Up @@ -348,11 +348,11 @@ public float getAspectRatio() {
return getOrCreateOtherProps().mAspectRatio;
}

void touchExpansionPx(YogaEdge edge, @Px int touchExpansion) {
void touchExpansionPx(@Nullable YogaEdge edge, @Px int touchExpansion) {
getOrCreateOtherProps().touchExpansionPx(edge, touchExpansion);
}

void foreground(Drawable foreground) {
void foreground(@Nullable Drawable foreground) {
getOrCreateOtherProps().foreground(foreground);
}

Expand Down Expand Up @@ -507,7 +507,7 @@ public EventHandler<InvisibleEvent> getInvisibleHandler() {
return getOrCreateOtherProps().mInvisibleHandler;
}

void contentDescription(CharSequence contentDescription) {
void contentDescription(@Nullable CharSequence contentDescription) {
getOrCreateNodeInfo().setContentDescription(contentDescription);
}

Expand All @@ -517,7 +517,7 @@ public CharSequence getContentDescription() {
return getOrCreateNodeInfo().getContentDescription();
}

void viewTag(Object viewTag) {
void viewTag(@Nullable Object viewTag) {
getOrCreateNodeInfo().setViewTag(viewTag);
}

Expand All @@ -527,7 +527,7 @@ public Object getViewTag() {
return getOrCreateNodeInfo().getViewTag();
}

void viewTags(SparseArray<Object> viewTags) {
void viewTags(@Nullable SparseArray<Object> viewTags) {
getOrCreateNodeInfo().setViewTags(viewTags);
}

Expand All @@ -547,7 +547,7 @@ public float getShadowElevationPx() {
return getOrCreateNodeInfo().getShadowElevation();
}

void outlineProvider(ViewOutlineProvider outlineProvider) {
void outlineProvider(@Nullable ViewOutlineProvider outlineProvider) {
getOrCreateNodeInfo().setOutlineProvider(outlineProvider);
}

Expand All @@ -566,7 +566,7 @@ public boolean getClipToOutline() {
return getOrCreateNodeInfo().getClipToOutline();
}

void accessibilityRole(@AccessibilityRole.AccessibilityRoleType String role) {
void accessibilityRole(@Nullable @AccessibilityRole.AccessibilityRoleType String role) {
getOrCreateNodeInfo().setAccessibilityRole(role);
}

Expand All @@ -578,8 +578,9 @@ public String getAccessibilityRole() {
}

void dispatchPopulateAccessibilityEventHandler(
EventHandler<DispatchPopulateAccessibilityEventEvent>
dispatchPopulateAccessibilityEventHandler) {
@Nullable
EventHandler<DispatchPopulateAccessibilityEventEvent>
dispatchPopulateAccessibilityEventHandler) {
getOrCreateNodeInfo()
.setDispatchPopulateAccessibilityEventHandler(dispatchPopulateAccessibilityEventHandler);
}
Expand All @@ -592,7 +593,8 @@ void dispatchPopulateAccessibilityEventHandler(
}

void onInitializeAccessibilityEventHandler(
EventHandler<OnInitializeAccessibilityEventEvent> onInitializeAccessibilityEventHandler) {
@Nullable
EventHandler<OnInitializeAccessibilityEventEvent> onInitializeAccessibilityEventHandler) {
getOrCreateNodeInfo()
.setOnInitializeAccessibilityEventHandler(onInitializeAccessibilityEventHandler);
}
Expand All @@ -605,8 +607,9 @@ void onInitializeAccessibilityEventHandler(
}

void onInitializeAccessibilityNodeInfoHandler(
EventHandler<OnInitializeAccessibilityNodeInfoEvent>
onInitializeAccessibilityNodeInfoHandler) {
@Nullable
EventHandler<OnInitializeAccessibilityNodeInfoEvent>
onInitializeAccessibilityNodeInfoHandler) {
getOrCreateNodeInfo()
.setOnInitializeAccessibilityNodeInfoHandler(onInitializeAccessibilityNodeInfoHandler);
}
Expand All @@ -619,7 +622,8 @@ void onInitializeAccessibilityNodeInfoHandler(
}

void onPopulateAccessibilityEventHandler(
EventHandler<OnPopulateAccessibilityEventEvent> onPopulateAccessibilityEventHandler) {
@Nullable
EventHandler<OnPopulateAccessibilityEventEvent> onPopulateAccessibilityEventHandler) {
getOrCreateNodeInfo()
.setOnPopulateAccessibilityEventHandler(onPopulateAccessibilityEventHandler);
}
Expand All @@ -631,7 +635,9 @@ public EventHandler<OnPopulateAccessibilityEventEvent> getOnPopulateAccessibilit
}

void onRequestSendAccessibilityEventHandler(
EventHandler<OnRequestSendAccessibilityEventEvent> onRequestSendAccessibilityEventHandler) {
@Nullable
EventHandler<OnRequestSendAccessibilityEventEvent>
onRequestSendAccessibilityEventHandler) {
getOrCreateNodeInfo()
.setOnRequestSendAccessibilityEventHandler(onRequestSendAccessibilityEventHandler);
}
Expand All @@ -644,7 +650,7 @@ void onRequestSendAccessibilityEventHandler(
}

void performAccessibilityActionHandler(
EventHandler<PerformAccessibilityActionEvent> performAccessibilityActionHandler) {
@Nullable EventHandler<PerformAccessibilityActionEvent> performAccessibilityActionHandler) {
getOrCreateNodeInfo().setPerformAccessibilityActionHandler(performAccessibilityActionHandler);
}

Expand All @@ -655,7 +661,7 @@ public EventHandler<PerformAccessibilityActionEvent> getPerformAccessibilityActi
}

void sendAccessibilityEventHandler(
EventHandler<SendAccessibilityEventEvent> sendAccessibilityEventHandler) {
@Nullable EventHandler<SendAccessibilityEventEvent> sendAccessibilityEventHandler) {
getOrCreateNodeInfo().setSendAccessibilityEventHandler(sendAccessibilityEventHandler);
}

Expand All @@ -666,7 +672,9 @@ public EventHandler<SendAccessibilityEventEvent> getSendAccessibilityEventHandle
}

void sendAccessibilityEventUncheckedHandler(
EventHandler<SendAccessibilityEventUncheckedEvent> sendAccessibilityEventUncheckedHandler) {
@Nullable
EventHandler<SendAccessibilityEventUncheckedEvent>
sendAccessibilityEventUncheckedHandler) {
getOrCreateNodeInfo()
.setSendAccessibilityEventUncheckedHandler(sendAccessibilityEventUncheckedHandler);
}
Expand Down Expand Up @@ -705,7 +713,7 @@ public float getRotation() {
return getOrCreateNodeInfo().getRotation();
}

void transitionKey(String key) {
void transitionKey(@Nullable String key) {
getOrCreateOtherProps().transitionKey(key);
}

Expand Down Expand Up @@ -751,7 +759,7 @@ public void copyInto(ComponentContext c, InternalNode node) {
if ((mPrivateFlags & PFLAG_HEIGHT_IS_SET) != 0L) {
node.heightPx(mHeightPx);
}

if (mWrapInView) {
node.wrapInView();
}
Expand Down Expand Up @@ -891,7 +899,7 @@ private void duplicateParentState(boolean duplicateParentState) {
mDuplicateParentState = duplicateParentState;
}

private void marginPx(YogaEdge edge, @Px int margin) {
private void marginPx(@Nullable YogaEdge edge, @Px int margin) {
mPrivateFlags |= PFLAG_MARGIN_IS_SET;

if (mMargins == null) {
Expand All @@ -903,23 +911,23 @@ private void marginPx(YogaEdge edge, @Px int margin) {
mMargins.add(edge, margin);
}

private void marginPercent(YogaEdge edge, float percent) {
private void marginPercent(@Nullable YogaEdge edge, float percent) {
mPrivateFlags |= PFLAG_MARGIN_PERCENT_IS_SET;
if (mMarginPercents == null) {
mMarginPercents = new YogaEdgesWithFloats();
}
mMarginPercents.add(edge, percent);
}

private void marginAuto(YogaEdge edge) {
private void marginAuto(@Nullable YogaEdge edge) {
mPrivateFlags |= PFLAG_MARGIN_AUTO_IS_SET;
if (mMarginAutos == null) {
mMarginAutos = new ArrayList<>(2);
}
mMarginAutos.add(edge);
}

private void paddingPx(YogaEdge edge, @Px int padding) {
private void paddingPx(@Nullable YogaEdge edge, @Px int padding) {
mPrivateFlags |= PFLAG_PADDING_IS_SET;
if (mPaddings == null) {
mPaddings =
Expand All @@ -930,15 +938,15 @@ private void paddingPx(YogaEdge edge, @Px int padding) {
mPaddings.add(edge, padding);
}

private void paddingPercent(YogaEdge edge, float percent) {
private void paddingPercent(@Nullable YogaEdge edge, float percent) {
mPrivateFlags |= PFLAG_PADDING_PERCENT_IS_SET;
if (mPaddingPercents == null) {
mPaddingPercents = new YogaEdgesWithFloats();
}
mPaddingPercents.add(edge, percent);
}

private void border(Border border) {
private void border(@Nullable Border border) {
mPrivateFlags |= PFLAG_BORDER_IS_SET;
mBorder = border;
}
Expand Down
Loading

0 comments on commit d0844fe

Please sign in to comment.