mapType = ((OptionMapType) option).getType();
}
}
// Create mapper
final Mapper mapper = new Mapper(mapType, size() - 1) {
@Override
public void handle(int i) {
// Get our target-array (if it is already there)
R[] a = (R[]) this.array.get();
// Get the in-value from the source-array
final T ii = CoreObject.this.t[i];
final T jj = CoreObject.this.t[i + 1];
// Convert
if (ii == null || jj == null) return;
final R out = delta.f(ii, jj);
if (out == null) return;
// If we haven't had an in-array, create it now, according to the return type
if (a == null) {
a = (R[]) updateArray(Array.newInstance(out.getClass(), this.size));
}
// Eventually set the out value
a[i] = out;
}
};
// Map ...
map(mapper, options);
// In case we don't have a return array (which happens when the mapper never returned something
// sensible), we create a simple object array of our size, so that the core's size stays
// consistent.
R rval[] = (R[]) mapper.getTargetArray();
if (rval == null) {
rval = (R[]) Array.newInstance(Object.class, Math.max(0, size() - 1));
}
// ... and return result.