Guest User

Untitled

a guest
Oct 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. package org.kelvinho.tracking.mutableTracker;
  2.  
  3. import android.support.annotation.NonNull;
  4.  
  5. import org.kelvinho.tracking.functional.Function;
  6.  
  7. import java.util.ArrayList;
  8.  
  9. @SuppressWarnings({"unused", "WeakerAccess"})
  10. public class WArrayList<T> extends Value<ArrayList<T>> {
  11. public WArrayList(@NonNull final Function<ArrayList<T>> updateFunction) {
  12. super(updateFunction);
  13. }
  14.  
  15. public WArrayList(@NonNull final ArrayList<T> value) {
  16. super(value);
  17. }
  18.  
  19. public WArrayList() {
  20. super(new ArrayList<>());
  21. }
  22.  
  23. public void add(@NonNull final T value) {
  24. super.nonNullValue().add(value);
  25. getGlobalGroup().change();
  26. }
  27.  
  28. public void add(final int index, @NonNull final T value) {
  29. super.nonNullValue().add(index, value);
  30. }
  31.  
  32. public void remove(final int index) {
  33. super.nonNullValue().remove(index);
  34. getGlobalGroup().change();
  35. }
  36.  
  37. public int size() {
  38. return super.nonNullValue().size();
  39. }
  40.  
  41. public T get(int index) {
  42. return super.nonNullValue().get(index);
  43. }
  44.  
  45. public T getLastElement() {
  46. return get(size() - 1);
  47. }
  48.  
  49. @SuppressWarnings("MethodDoesntCallSuperMethod")
  50. public WArrayList<T> clone() {
  51. return new WArrayList<>(new ArrayList<>(super.nonNullValue()));
  52. }
  53. }
Add Comment
Please, Sign In to add comment