@Override public boolean add(ITEM e) { if ( ! permitAddAfterFreeze) throwIfFrozen(); return super.add(e); }
@Override public void add(int index, ITEM e) { throwIfFrozen(); super.add(index, e); }
/** * Adds a hit to this group in the specified index, * all existing hits on this index and higher will have their index increased by one. * * <b>Note:</b> If the group was sorted, it will still be considered sorted after this call. */ public void add(int index, Hit hit) { if (hit instanceof ErrorHit) { // Merge instead add(hit); return; } boolean wasSorted = hitsSorted; handleNewHit(hit); hits.add(index, hit); hitsSorted = wasSorted; }
public HitGroup clone() { HitGroup hitGroupClone = (HitGroup) super.clone(); hitGroupClone.hits = new ListenableArrayList<>(this.hits.size()); hitGroupClone.unmodifiableHits = Collections.unmodifiableList(hitGroupClone.hits); for (Iterator<Hit> i = this.hits.iterator(); i.hasNext();) { Hit hitClone = i.next().clone(); hitGroupClone.hits.add(hitClone); } if (this.errorHit!=null) { // Find the cloned error and assign it for (Hit hit : hitGroupClone.asList()) { if (hit instanceof DefaultErrorHit) hitGroupClone.errorHit=(DefaultErrorHit)hit; } } if (this.getFilledInternal()!=null) { hitGroupClone.setFilledInternal(new HashSet<>(this.getFilledInternal())); } return hitGroupClone; }
/** * Adds a hit to this group. * If the given hit is an ErrorHit and this group already have an error hit, * the errors in the given hit are merged into the errors of this. * * @return the resulting hit - this is usually the input hit, but if an error hit was added, * and there was already an error hit present, that hit, containing the merged information * is returned */ @Override public Hit add(Hit hit) { if (hit.isMeta() && hit instanceof DefaultErrorHit) { if (errorHit != null) { errorHit.addErrors((DefaultErrorHit)hit); return errorHit; // don't add another error hit } else { errorHit = merge(consumeAnyQueryErrors(), (DefaultErrorHit) hit); hit = errorHit; // Add this hit below } } handleNewHit(hit); hits.add(hit); return hit; }