src/core/se/jbee/inject/Utils.java
public static <A, B> B[] arrayFlatmap(A[] as, Class<B> to,
			Function<A, B> flatmapOp) {
		B[] bs = newArray(to, as.length);
		int j = 0;
		for (int i = 0; i < as.length; i++) {
			B b = flatmapOp.apply(as[i]);
			if (b != null)
				bs[j++] = b;
		}
		return j == as.length ? bs : copyOf(bs, j);
	}
public static <A, B> B[] arrayFlatmap(A[] as, Class<B> to,
			Function<A, B> flatmapOp) {
		B[] bs = newArray(to, as.length);
		int j = 0;
		for (int i = 0; i < as.length; i++) {
			B b = flatmapOp.apply(as[i]);
			if (b != null)
				bs[j++] = b;
		}
		return j == as.length ? bs : copyOf(bs, j);
	}
public static < A , B > B [ ] arrayFlatmap ( A [ ] as , Class < B > to , Function < A , B > flatmapOp ) { B [ ] bs = newArray ( to , as . length ) ; int j = 0 ; for ( int i = 0 ; i < as . length ; i ++ ) { B b = flatmapOp . apply ( as [ i ] ) ; if ( b != null ) bs [ j ++ ] = b ; } return j == as . length ? bs : copyOf ( bs , j ) ; }
This is a special form of flatmap where the mapping does not return zero
to n Bs but always returns a B. If {@code null} is returned this means
"zero" or remove the B. So length of {@code B[]} is always {@code <=}
length of {@code A[]}.
This is a special form of flatmap where the mapping does not return zero to n Bs but always returns a B . If {