private static int findMatching(Lookup.Template t, Object[] arr, int from) { while (++from < arr.length) { if (arr[from] instanceof AbstractLookup.Pair) { if (AbstractLookup.matches(t, (AbstractLookup.Pair) arr[from], true)) { return from; } } } return -1; }
@SuppressWarnings("unchecked") private Collection<Pair<T>> extractPairs(final ArrayList<Pair<Object>> saferCheck) { TreeSet<Pair<T>> items = new TreeSet<Pair<T>>(ALPairComparator.DEFAULT); for (Pair<Object> i : saferCheck) { if (matches(reference.template, i, false)) { items.add((Pair<T>)i); } } return Collections.unmodifiableCollection(items); }
/** A method that defines matching between Item and Template. * @param item the item to match * @return true if item matches the template requirements, false if not */ private static boolean matches(Template<?> t, AbstractLookup.Pair<?> item) { if (!AbstractLookup.matches(t, item, true)) { return false; } Class<?> type = t.getType(); if ((type != null) && !type.isAssignableFrom(item.getType())) { return false; } return true; }
/** Initializes items. */ private Collection<Pair<T>> initItems(Storage<?> t) { // manipulation with the tree must be synchronized Enumeration<Pair<T>> en = t.lookup(reference.template.getType()); // InheritanceTree is comparator for AbstractLookup.Pairs TreeSet<Pair<T>> items = new TreeSet<Pair<T>>(ALPairComparator.DEFAULT); while (en.hasMoreElements()) { Pair<T> i = en.nextElement(); if (matches(reference.template, i, false)) { items.add(i); } } // create a correctly sorted copy using the tree as the comparator setItemsCache(items); return items; }
private static <T> Pair<T> findSmallest(Enumeration<Pair<T>> en, Lookup.Template<T> template, boolean deepCheck) { int smallest = InheritanceTree.unsorted(en) ? Integer.MAX_VALUE : Integer.MIN_VALUE; Pair<T> res = null; while (en.hasMoreElements()) { Pair<T> item = en.nextElement(); if (matches(template, item, deepCheck)) { if (smallest == Integer.MIN_VALUE) { // ok, sorted enumeration the first that matches is fine return item; } else { // check for the smallest item if (smallest > item.getIndex()) { smallest = item.getIndex(); res = item; } } } } return res; }
AbstractLookup.Pair p = (AbstractLookup.Pair) pairs.next(); if (AbstractLookup.matches(ref.template, p, true)) { modified.add(ref.getResult());
private static int findMatching(Lookup.Template t, Object[] arr, int from) { while (++from < arr.length) { if (arr[from] instanceof AbstractLookup.Pair) { if (AbstractLookup.matches(t, (AbstractLookup.Pair) arr[from], true)) { return from; } } } return -1; }
private static int findMatching (Lookup.Template t, Object[] arr, int from) { while (++from < arr.length) { if (arr[from] instanceof AbstractLookup.Pair) { if (AbstractLookup.matches(t, (AbstractLookup.Pair)arr[from], true)) { return from; } } } return -1; }
private static int findMatching(Lookup.Template t, Object[] arr, int from) { while (++from < arr.length) { if (arr[from] instanceof AbstractLookup.Pair) { if (AbstractLookup.matches(t, (AbstractLookup.Pair) arr[from], true)) { return from; } } } return -1; }
private static int findMatching (Lookup.Template t, Object[] arr, int from) { while (++from < arr.length) { if (arr[from] instanceof AbstractLookup.Pair) { if (AbstractLookup.matches(t, (AbstractLookup.Pair)arr[from], true)) { return from; } } } return -1; }
@SuppressWarnings("unchecked") private Collection<Pair<T>> extractPairs(final ArrayList<Pair<Object>> saferCheck) { TreeSet<Pair<T>> items = new TreeSet<Pair<T>>(ALPairComparator.DEFAULT); for (Pair<Object> i : saferCheck) { if (matches(reference.template, i, false)) { items.add((Pair<T>)i); } } return Collections.unmodifiableCollection(items); }
@SuppressWarnings("unchecked") private Collection<Pair<T>> extractPairs(final ArrayList<Pair<Object>> saferCheck) { TreeSet<Pair<T>> items = new TreeSet<Pair<T>>(ALPairComparator.DEFAULT); for (Pair<Object> i : saferCheck) { if (matches(reference.template, i, false)) { items.add((Pair<T>)i); } } return Collections.unmodifiableCollection(items); }
/** A method that defines matching between Item and Template. * @param item the item to match * @return true if item matches the template requirements, false if not */ private static boolean matches (Template t, AbstractLookup.Pair item) { if ( !AbstractLookup.matches(t, item, true)) { return false; } Class type = t.getType(); if (type != null && !type.isAssignableFrom(item.getType())) { return false; } return true; }
/** A method that defines matching between Item and Template. * @param item the item to match * @return true if item matches the template requirements, false if not */ private static boolean matches(Template<?> t, AbstractLookup.Pair<?> item) { if (!AbstractLookup.matches(t, item, true)) { return false; } Class<?> type = t.getType(); if ((type != null) && !type.isAssignableFrom(item.getType())) { return false; } return true; }
/** A method that defines matching between Item and Template. * @param item the item to match * @return true if item matches the template requirements, false if not */ private static boolean matches (Template t, AbstractLookup.Pair item) { if ( !AbstractLookup.matches(t, item, true)) { return false; } Class type = t.getType(); if (type != null && !type.isAssignableFrom(item.getType())) { return false; } return true; }
/** A method that defines matching between Item and Template. * @param item the item to match * @return true if item matches the template requirements, false if not */ private static boolean matches(Template<?> t, AbstractLookup.Pair<?> item) { if (!AbstractLookup.matches(t, item, true)) { return false; } Class<?> type = t.getType(); if ((type != null) && !type.isAssignableFrom(item.getType())) { return false; } return true; }
/** Initializes items. */ private Collection<Pair<T>> initItems(Storage<?> t) { // manipulation with the tree must be synchronized Enumeration<Pair<T>> en = t.lookup(reference.template.getType()); // InheritanceTree is comparator for AbstractLookup.Pairs TreeSet<Pair<T>> items = new TreeSet<Pair<T>>(ALPairComparator.DEFAULT); while (en.hasMoreElements()) { Pair<T> i = en.nextElement(); if (matches(reference.template, i, false)) { items.add(i); } } // create a correctly sorted copy using the tree as the comparator setItemsCache(items); return items; }
/** Initializes items. */ private Collection<Pair<T>> initItems(Storage<?> t) { // manipulation with the tree must be synchronized Enumeration<Pair<T>> en = t.lookup(reference.template.getType()); // InheritanceTree is comparator for AbstractLookup.Pairs TreeSet<Pair<T>> items = new TreeSet<Pair<T>>(ALPairComparator.DEFAULT); while (en.hasMoreElements()) { Pair<T> i = en.nextElement(); if (matches(reference.template, i, false)) { items.add(i); } } // create a correctly sorted copy using the tree as the comparator setItemsCache(items); return items; }
/** Initializes items. */ private Collection initItems (Storage t) { // manipulation with the tree must be synchronized Enumeration en = t.lookup (reference.template.getType ()); // InheritanceTree is comparator for AbstractLookup.Pairs TreeSet items = new TreeSet (ALPairComparator.DEFAULT); while (en.hasMoreElements ()) { Pair i = (Pair)en.nextElement (); if (matches (reference.template, i, false)) { items.add (i); } } // create a correctly sorted copy using the tree as the comparator setItemsCache (items); return items; }
private static <T> Pair<T> findSmallest(Enumeration<Pair<T>> en, Lookup.Template<T> template, boolean deepCheck) { int smallest = InheritanceTree.unsorted(en) ? Integer.MAX_VALUE : Integer.MIN_VALUE; Pair<T> res = null; while (en.hasMoreElements()) { Pair<T> item = en.nextElement(); if (matches(template, item, deepCheck)) { if (smallest == Integer.MIN_VALUE) { // ok, sorted enumeration the first that matches is fine return item; } else { // check for the smallest item if (smallest > item.getIndex()) { smallest = item.getIndex(); res = item; } } } } return res; }