@Override
  public boolean contains(Object o) {
    for (M member : members) {
      if (selector.select(member) && o.equals(member)) {
        return true;
      }
    }

    return false;
  }
Ejemplo n.º 2
0
  @Override
  public int getSize(MemberSelector selector) {
    int size = 0;
    for (MemberImpl member : membersRef.get()) {
      if (selector.select(member)) {
        size++;
      }
    }

    return size;
  }
  @Override
  public Object[] toArray() {
    List<Object> result = new ArrayList<Object>();
    for (M member : members) {
      if (selector.select(member)) {
        result.add(member);
      }
    }

    return result.toArray(new Object[result.size()]);
  }
  @Override
  public int size() {
    int size = 0;
    for (M member : members) {
      if (selector.select(member)) {
        size++;
      }
    }

    return size;
  }
  @Override
  public <T> T[] toArray(T[] a) {
    List<Object> result = new ArrayList<Object>();
    for (M member : members) {
      if (selector.select(member)) {
        result.add(member);
      }
    }

    if (a.length != result.size()) {
      a = (T[]) Array.newInstance(a.getClass().getComponentType(), result.size());
    }

    for (int i = 0; i < a.length; i++) {
      a[i] = (T) result.get(i);
    }

    return a;
  }