/** * Create a new Section by composing with a Section that is reletive to this Section. * * @param want Section reletive to this one. If null, return this. If individual ranges are null, use corresponding Range in this. * @return new Section, composed * @throws InvalidRangeException if want.getRank() not equal to this.getRank(), or invalid component Range */ public Section compose(Section want) throws InvalidRangeException { // all nulls if (want == null) return this; // LOOK maybe a copy ?? if (want.getRank() != getRank()) throw new InvalidRangeException("Invalid Section rank"); // check individual nulls List<Range> results = new ArrayList<>(getRank()); for (int j = 0; j < list.size(); j++) { Range base = list.get(j); Range r = want.getRange(j); if (r == null) results.add(base); else results.add(base.compose(r)); } return new Section(results); }
/** * Create a new Section by composing with a Section that is reletive to this Section. * * @param want Section reletive to this one. If null, return this. If individual ranges are null, use corresponding Range in this. * @return new Section, composed * @throws InvalidRangeException if want.getRank() not equal to this.getRank(), or invalid component Range */ public Section compose(Section want) throws InvalidRangeException { // all nulls if (want == null) return this; // LOOK maybe a copy ?? if (want.getRank() != getRank()) throw new InvalidRangeException("Invalid Section rank"); // check individual nulls List<Range> results = new ArrayList<Range>(getRank()); for (int j = 0; j < list.size(); j++) { Range base = list.get(j); Range r = want.getRange(j); if (r == null) results.add(base); else results.add(base.compose(r)); } return new Section(results); }
/** * Create a new Section by composing with a Section that is reletive to this Section. * * @param want Section reletive to this one. If null, return this. If individual ranges are null, use corresponding Range in this. * @return new Section, composed * @throws InvalidRangeException if want.getRank() not equal to this.getRank(), or invalid component Range */ public Section compose(Section want) throws InvalidRangeException { // all nulls if (want == null) return this; // LOOK maybe a copy ?? if (want.getRank() != getRank()) throw new InvalidRangeException("Invalid Section rank"); // check individual nulls List<Range> results = new ArrayList<>(getRank()); for (int j = 0; j < list.size(); j++) { Range base = list.get(j); Range r = want.getRange(j); if (r == null) results.add(base); else results.add(base.compose(r)); } return new Section(results); }