88/**
99 * Abstract Section to be used with {@link SectionedRecyclerViewAdapter}.
1010 */
11- @ SuppressWarnings ({ "WeakerAccess" , "PMD.AvoidFieldNameMatchingMethodName" } )
11+ @ SuppressWarnings ("WeakerAccess" )
1212public abstract class Section {
1313
1414 public enum State {
@@ -22,7 +22,9 @@ public enum State {
2222
2323 private boolean visible = true ;
2424
25+ @ SuppressWarnings ({"PMD.BeanMembersShouldSerialize" , "PMD.AvoidFieldNameMatchingMethodName" })
2526 private boolean hasHeader ;
27+ @ SuppressWarnings ({"PMD.BeanMembersShouldSerialize" , "PMD.AvoidFieldNameMatchingMethodName" })
2628 private boolean hasFooter ;
2729
2830 @ LayoutRes
@@ -49,7 +51,7 @@ public enum State {
4951 *
5052 * @param sectionParameters section parameters
5153 */
52- public Section (SectionParameters sectionParameters ) {
54+ public Section (final SectionParameters sectionParameters ) {
5355 this .itemResourceId = sectionParameters .itemResourceId ;
5456 this .headerResourceId = sectionParameters .headerResourceId ;
5557 this .footerResourceId = sectionParameters .footerResourceId ;
@@ -63,16 +65,16 @@ public Section(SectionParameters sectionParameters) {
6365 this .failedViewWillBeProvided = sectionParameters .failedViewWillBeProvided ;
6466 this .emptyViewWillBeProvided = sectionParameters .emptyViewWillBeProvided ;
6567
66- this .hasHeader = ( this .headerResourceId != null ) || this .headerViewWillBeProvided ;
67- this .hasFooter = ( this .footerResourceId != null ) || this .footerViewWillBeProvided ;
68+ this .hasHeader = this .headerResourceId != null || this .headerViewWillBeProvided ;
69+ this .hasFooter = this .footerResourceId != null || this .footerViewWillBeProvided ;
6870 }
6971
7072 /**
7173 * Set the State of this Section.
7274 *
7375 * @param state state of this section
7476 */
75- public final void setState (State state ) {
77+ public final void setState (final State state ) {
7678 switch (state ) {
7779 case LOADING :
7880 if (loadingResourceId == null && !loadingViewWillBeProvided ) {
@@ -120,7 +122,7 @@ public final boolean isVisible() {
120122 *
121123 * @param visible true if this Section is visible
122124 */
123- public final void setVisible (boolean visible ) {
125+ public final void setVisible (final boolean visible ) {
124126 this .visible = visible ;
125127 }
126128
@@ -138,7 +140,7 @@ public final boolean hasHeader() {
138140 *
139141 * @param hasHeader true if this Section has a header
140142 */
141- public final void setHasHeader (boolean hasHeader ) {
143+ public final void setHasHeader (final boolean hasHeader ) {
142144 this .hasHeader = hasHeader ;
143145 }
144146
@@ -156,7 +158,7 @@ public final boolean hasFooter() {
156158 *
157159 * @param hasFooter true if this Section has a footer
158160 */
159- public final void setHasFooter (boolean hasFooter ) {
161+ public final void setHasFooter (final boolean hasFooter ) {
160162 this .hasFooter = hasFooter ;
161163 }
162164
@@ -286,7 +288,7 @@ public final Integer getEmptyResourceId() {
286288 * @param holder ViewHolder for the Content of this Section
287289 * @param position position of the item in the Section, not in the RecyclerView
288290 */
289- public final void onBindContentViewHolder (RecyclerView .ViewHolder holder , int position ) {
291+ public final void onBindContentViewHolder (final RecyclerView .ViewHolder holder , final int position ) {
290292 switch (state ) {
291293 case LOADING :
292294 onBindLoadingViewHolder (holder );
@@ -348,7 +350,7 @@ public final int getSectionItemsTotal() {
348350 * @param parent The parent view. Note that there is no need to attach the new view.
349351 * @return View for an Item of this Section.
350352 */
351- public View getItemView (@ SuppressWarnings ("unused" ) ViewGroup parent ) {
353+ public View getItemView (@ SuppressWarnings ("unused" ) final ViewGroup parent ) {
352354 throw new UnsupportedOperationException (
353355 "You need to implement getItemView() if you set itemViewWillBeProvided" );
354356 }
@@ -376,7 +378,7 @@ public View getItemView(@SuppressWarnings("unused") ViewGroup parent) {
376378 * @param parent The parent view. Note that there is no need to attach the new view.
377379 * @return View for the Header of this Section.
378380 */
379- public View getHeaderView (@ SuppressWarnings ("unused" ) ViewGroup parent ) {
381+ public View getHeaderView (@ SuppressWarnings ("unused" ) final ViewGroup parent ) {
380382 throw new UnsupportedOperationException (
381383 "You need to implement getHeaderView() if you set headerViewWillBeProvided" );
382384 }
@@ -387,7 +389,7 @@ public View getHeaderView(@SuppressWarnings("unused") ViewGroup parent) {
387389 * @param view View inflated by resource returned by getHeaderResourceId
388390 * @return ViewHolder for the Header of this Section
389391 */
390- public RecyclerView .ViewHolder getHeaderViewHolder (View view ) {
392+ public RecyclerView .ViewHolder getHeaderViewHolder (final View view ) {
391393 return new SectionedRecyclerViewAdapter .EmptyViewHolder (view );
392394 }
393395
@@ -396,7 +398,8 @@ public RecyclerView.ViewHolder getHeaderViewHolder(View view) {
396398 *
397399 * @param holder ViewHolder for the Header of this Section
398400 */
399- public void onBindHeaderViewHolder (RecyclerView .ViewHolder holder ) {
401+ @ SuppressWarnings ("PMD.EmptyMethodInAbstractClassShouldBeAbstract" )
402+ public void onBindHeaderViewHolder (final RecyclerView .ViewHolder holder ) {
400403 // Nothing to bind here.
401404 }
402405
@@ -407,7 +410,7 @@ public void onBindHeaderViewHolder(RecyclerView.ViewHolder holder) {
407410 * @param parent The parent view. Note that there is no need to attach the new view.
408411 * @return View for the Footer of this Section.
409412 */
410- public View getFooterView (@ SuppressWarnings ("unused" ) ViewGroup parent ) {
413+ public View getFooterView (@ SuppressWarnings ("unused" ) final ViewGroup parent ) {
411414 throw new UnsupportedOperationException (
412415 "You need to implement getFooterView() if you set footerViewWillBeProvided" );
413416 }
@@ -418,7 +421,7 @@ public View getFooterView(@SuppressWarnings("unused") ViewGroup parent) {
418421 * @param view View inflated by resource returned by getFooterResourceId
419422 * @return ViewHolder for the Footer of this Section
420423 */
421- public RecyclerView .ViewHolder getFooterViewHolder (View view ) {
424+ public RecyclerView .ViewHolder getFooterViewHolder (final View view ) {
422425 return new SectionedRecyclerViewAdapter .EmptyViewHolder (view );
423426 }
424427
@@ -427,7 +430,8 @@ public RecyclerView.ViewHolder getFooterViewHolder(View view) {
427430 *
428431 * @param holder ViewHolder for the Footer of this Section
429432 */
430- public void onBindFooterViewHolder (RecyclerView .ViewHolder holder ) {
433+ @ SuppressWarnings ("PMD.EmptyMethodInAbstractClassShouldBeAbstract" )
434+ public void onBindFooterViewHolder (final RecyclerView .ViewHolder holder ) {
431435 // Nothing to bind here.
432436 }
433437
@@ -438,7 +442,7 @@ public void onBindFooterViewHolder(RecyclerView.ViewHolder holder) {
438442 * @param parent The parent view. Note that there is no need to attach the new view.
439443 * @return View for the Loading state of this Section.
440444 */
441- public View getLoadingView (@ SuppressWarnings ("unused" ) ViewGroup parent ) {
445+ public View getLoadingView (@ SuppressWarnings ("unused" ) final ViewGroup parent ) {
442446 throw new UnsupportedOperationException (
443447 "You need to implement getLoadingView() if you set loadingViewWillBeProvided" );
444448 }
@@ -449,7 +453,7 @@ public View getLoadingView(@SuppressWarnings("unused") ViewGroup parent) {
449453 * @param view View inflated by resource returned by getItemResourceId
450454 * @return ViewHolder for the Loading state of this Section
451455 */
452- public RecyclerView .ViewHolder getLoadingViewHolder (View view ) {
456+ public RecyclerView .ViewHolder getLoadingViewHolder (final View view ) {
453457 return new SectionedRecyclerViewAdapter .EmptyViewHolder (view );
454458 }
455459
@@ -458,8 +462,8 @@ public RecyclerView.ViewHolder getLoadingViewHolder(View view) {
458462 *
459463 * @param holder ViewHolder for the Loading state of this Section
460464 */
461- @ SuppressWarnings ("EmptyMethod" )
462- public void onBindLoadingViewHolder (RecyclerView .ViewHolder holder ) {
465+ @ SuppressWarnings ({ "EmptyMethod" , "PMD.EmptyMethodInAbstractClassShouldBeAbstract" } )
466+ public void onBindLoadingViewHolder (final RecyclerView .ViewHolder holder ) {
463467 // Nothing to bind here.
464468 }
465469
@@ -470,7 +474,7 @@ public void onBindLoadingViewHolder(RecyclerView.ViewHolder holder) {
470474 * @param parent The parent view. Note that there is no need to attach the new view.
471475 * @return View for the Failed state of this Section.
472476 */
473- public View getFailedView (@ SuppressWarnings ("unused" ) ViewGroup parent ) {
477+ public View getFailedView (@ SuppressWarnings ("unused" ) final ViewGroup parent ) {
474478 throw new UnsupportedOperationException (
475479 "You need to implement getFailedView() if you set failedViewWillBeProvided" );
476480 }
@@ -481,7 +485,7 @@ public View getFailedView(@SuppressWarnings("unused") ViewGroup parent) {
481485 * @param view View inflated by resource returned by getItemResourceId
482486 * @return ViewHolder for the Failed of this Section
483487 */
484- public RecyclerView .ViewHolder getFailedViewHolder (View view ) {
488+ public RecyclerView .ViewHolder getFailedViewHolder (final View view ) {
485489 return new SectionedRecyclerViewAdapter .EmptyViewHolder (view );
486490 }
487491
@@ -490,8 +494,8 @@ public RecyclerView.ViewHolder getFailedViewHolder(View view) {
490494 *
491495 * @param holder ViewHolder for the Failed state of this Section
492496 */
493- @ SuppressWarnings ("EmptyMethod" )
494- public void onBindFailedViewHolder (RecyclerView .ViewHolder holder ) {
497+ @ SuppressWarnings ({ "EmptyMethod" , "PMD.EmptyMethodInAbstractClassShouldBeAbstract" } )
498+ public void onBindFailedViewHolder (final RecyclerView .ViewHolder holder ) {
495499 // Nothing to bind here.
496500 }
497501
@@ -502,7 +506,7 @@ public void onBindFailedViewHolder(RecyclerView.ViewHolder holder) {
502506 * @param parent The parent view. Note that there is no need to attach the new view.
503507 * @return View for the Empty state of this Section.
504508 */
505- public View getEmptyView (@ SuppressWarnings ("unused" ) ViewGroup parent ) {
509+ public View getEmptyView (@ SuppressWarnings ("unused" ) final ViewGroup parent ) {
506510 throw new UnsupportedOperationException (
507511 "You need to implement getEmptyView() if you set emptyViewWillBeProvided" );
508512 }
@@ -513,7 +517,7 @@ public View getEmptyView(@SuppressWarnings("unused") ViewGroup parent) {
513517 * @param view View inflated by resource returned by getItemResourceId
514518 * @return ViewHolder for the Empty of this Section
515519 */
516- public RecyclerView .ViewHolder getEmptyViewHolder (View view ) {
520+ public RecyclerView .ViewHolder getEmptyViewHolder (final View view ) {
517521 return new SectionedRecyclerViewAdapter .EmptyViewHolder (view );
518522 }
519523
@@ -522,8 +526,8 @@ public RecyclerView.ViewHolder getEmptyViewHolder(View view) {
522526 *
523527 * @param holder ViewHolder for the Empty state of this Section
524528 */
525- @ SuppressWarnings ("EmptyMethod" )
526- public void onBindEmptyViewHolder (RecyclerView .ViewHolder holder ) {
529+ @ SuppressWarnings ({ "EmptyMethod" , "PMD.EmptyMethodInAbstractClassShouldBeAbstract" } )
530+ public void onBindEmptyViewHolder (final RecyclerView .ViewHolder holder ) {
527531 // Nothing to bind here.
528532 }
529533}
0 commit comments