コード例 #1
0
  @Test
  public void firstNAdd() {
    Transformers.<MyObject>firstN(Properties.constant(1)).transform(fromList, toList);

    fromList.add(new MyObject("x"));
    fromList.add(0, new MyObject("y"));

    assertEquals("[y]", toList.toString());
  }
コード例 #2
0
  @Test
  public void targetHasNoMoreThanNElements() {
    ObservableSingleItemList<MyObject> targetList = new ObservableSingleItemList<>();
    fromList.add(new MyObject("x"));

    Transformers.<MyObject>firstN(Properties.constant(1)).transform(fromList, targetList);
    fromList.add(0, new MyObject("y"));

    assertEquals("[y]", targetList.toString());
  }
コード例 #3
0
  @Test
  public void firstNInitial() {
    fromList.add(new MyObject("a"));
    fromList.add(new MyObject("b"));
    fromList.add(new MyObject("c"));

    Transformers.<MyObject>firstN(Properties.constant(2)).transform(fromList, toList);

    assertEquals("[a, b]", toList.toString());
  }
コード例 #4
0
  @Test
  public void firstNRemove() {
    fromList.add(new MyObject("a"));
    fromList.add(new MyObject("b"));
    fromList.add(new MyObject("c"));

    Transformers.<MyObject>firstN(Properties.constant(1)).transform(fromList, toList);

    fromList.remove(2);
    fromList.remove(0);

    assertEquals("[b]", toList.toString());
  }
コード例 #5
0
  @Test
  public void firstNdecreaseN() {
    fromList.add(new MyObject("a"));
    fromList.add(new MyObject("b"));
    fromList.add(new MyObject("c"));

    ValueProperty<Integer> prop = new ValueProperty<>(2);

    Transformers.<MyObject>firstN(prop).transform(fromList, toList);

    prop.set(0);

    assertEquals("[]", toList.toString());
  }