Return a new list without null values.
(InstanceScope scope, Object v)
| 1038 | /** Return a new list without {@code null} values. */ |
| 1039 | |
| 1040 | public Object strip(InstanceScope scope, Object v) { |
| 1041 | if ( v==null ) return null; |
| 1042 | v = convertAnythingIteratableToIterator(scope, v); |
| 1043 | if ( v instanceof Iterator ) { |
| 1044 | List<Object> a = new ArrayList<Object>(); |
| 1045 | Iterator<?> it = (Iterator<?>)v; |
| 1046 | while ( it.hasNext() ) { |
| 1047 | Object o = it.next(); |
| 1048 | if ( o!=null ) a.add(o); |
| 1049 | } |
| 1050 | return a; |
| 1051 | } |
| 1052 | return v; // strip(x)==x when x single-valued attribute |
| 1053 | } |
| 1054 | |
| 1055 | /** |
| 1056 | * Return a list with the same elements as {@code v} but in reverse order. |
no test coverage detected