/** * Creates an array of <tt>Member</tt> instances. * * @param <T> The type of the <tt>Member</tt> subclass to create. * @param array the array to store the instances in * @return the array that was passed in */ @SuppressWarnings("unchecked") protected <T extends Field> T[] array(T[] array) { arrayBegin(); try { Class<?> arrayClass = array.getClass().getComponentType(); Constructor<?> ctor = arrayClass.getDeclaredConstructor(new Class[] { arrayClass.getEnclosingClass() }); Object[] parameters = { StructLayout.this }; for (int i = 0; i < array.length; ++i) { array[i] = (T) ctor.newInstance(parameters); } } catch (Exception ex) { throw new RuntimeException(ex); } arrayEnd(); return array; }
/** * Creates an array of <tt>Member</tt> instances. * * @param <T> The type of the <tt>Member</tt> subclass to create. * @param array the array to store the instances in * @return the array that was passed in */ @SuppressWarnings("unchecked") protected <T extends Field> T[] array(T[] array) { arrayBegin(); try { Class<?> arrayClass = array.getClass().getComponentType(); Constructor<?> ctor = arrayClass.getDeclaredConstructor(new Class[] { arrayClass.getEnclosingClass() }); Object[] parameters = { StructLayout.this }; for (int i = 0; i < array.length; ++i) { array[i] = (T) ctor.newInstance(parameters); } } catch (Exception ex) { throw new RuntimeException(ex); } arrayEnd(); return array; }
/** * Creates an array of <tt>Member</tt> instances. * * @param <T> The type of the <tt>Member</tt> subclass to create. * @param array the array to store the instances in * @return the array that was passed in */ @SuppressWarnings("unchecked") protected <T extends Field> T[] array(T[] array) { arrayBegin(); try { Class<?> arrayClass = array.getClass().getComponentType(); Constructor<?> ctor = arrayClass.getDeclaredConstructor(new Class[] { arrayClass.getEnclosingClass() }); Object[] parameters = { StructLayout.this }; for (int i = 0; i < array.length; ++i) { array[i] = (T) ctor.newInstance(parameters); } } catch (Exception ex) { throw new RuntimeException(ex); } arrayEnd(); return array; }