Skip to content

Commit f5542c3

Browse files
committed
Release 5.0.0
1 parent ed86e5a commit f5542c3

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

flexible-adapter/src/main/java/eu/davidea/flexibleadapter/FlexibleAdapter.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ public void updateDataSet(@Nullable List<T> items, boolean animate) {
620620
}
621621

622622
/**
623-
* Returns the object of type <b>T</b>.
623+
* Returns the object of the generic type <b>T</b>.
624624
* <p>This method cannot be overridden since the entire library relies on it.</p>
625625
*
626626
* @param position the position of the item in the list
@@ -633,6 +633,20 @@ public T getItem(int position) {
633633
return mItems.get(position);
634634
}
635635

636+
/**
637+
* Returns the object of specific type <b>S</b>.
638+
*
639+
* @param position the position of the item in the list
640+
* @param clazz the class type expected
641+
* @return The <b>S</b> object for the position provided or null if item not found
642+
* @throws ClassCastException if the class type doesn't match with the item type requested
643+
* @since 5.0.0
644+
*/
645+
@Nullable
646+
public <S extends T> S getItem(int position, Class<S> clazz) {
647+
return clazz.cast(getItem(position));
648+
}
649+
636650
/**
637651
* This method is mostly used by the adapter if items have stableIds.
638652
*
@@ -3825,8 +3839,11 @@ public void setFilter(@Nullable Serializable filter) {
38253839
}
38263840

38273841
/**
3842+
* Gets the current filter.
3843+
*
38283844
* @param clazz The class type of filter to return (eg. String.class)
38293845
* @return the current filter entity
3846+
* @throws ClassCastException if the class type doesn't match with the filter type previously set
38303847
* @since 5.0.0
38313848
*/
38323849
@Nullable

0 commit comments

Comments
 (0)