code: public static <E> List<E> constrainedList(List<E> list, Constraint<? super E> constraint) {
      return (list instanceof RandomAccess)
          ? new ConstrainedRandomAccessList<E>(list, constraint)
          : new ConstrainedList<E>(list, constraint);
    }
docs: Returns a constrained view of the specified list, using the specified
  constraint. Any operations that add new elements to the list will call the
  provided constraint. However, this method does not verify that existing
  elements satisfy the constraint.
  
  <p>If {@code list} implements {@link RandomAccess}, so will the returned
  list. The returned list is not serializable.
  
  @param list the list to constrain
  @param constraint the constraint that validates added elements
  @return a constrained view of the list