/** @deprecated Replaced with {@link #setOrdering(Class, boolean, Predicate, Predicate)} */ @Deprecated public <T> boolean setOrdering( final Class<T> base, final boolean set, final ServiceRegistry.Filter filter1, final ServiceRegistry.Filter filter2) { ensureArgumentNonNull("filter1", filter1); ensureArgumentNonNull("filter2", filter2); return setOrdering(base, set, (Predicate<T>) filter1::filter, filter2::filter); }
set |= setOrdering(category, f1, f2); } else if (c < 0) { set |= setOrdering(category, f2, f1);
/** Helper method for the above. */ private <T> boolean setOrUnsetOrdering( final Class<T> category, final boolean set, final Predicate<? super T> filter1, final Predicate<? super T> filter2) { boolean done = false; T impl1 = null; T impl2 = null; Iterable<T> factories = getFactories(category, false)::iterator; for (final T factory : factories) { if (filter1.test(factory)) impl1 = factory; if (filter2.test(factory)) impl2 = factory; if (impl1 != null && impl2 != null && impl1 != impl2) { if (set) done |= setOrdering(category, impl1, impl2); else done |= unsetOrdering(category, impl1, impl2); } } return done; }
final int compare = factory.getPriority(); if (priority > compare) { registry.setOrdering((Class) category, this, factory); } else if (priority < compare) { registry.setOrdering((Class) category, factory, this);
/** * Unsets a pairwise ordering between two vendors. If one or both vendors are not currently * registered, or if the desired ordering is already unset, nothing happens and {@code false} is * returned. * * @param vendor1 The preferred vendor. * @param vendor2 The vendor to which {@code vendor1} is preferred. * @return {@code true} if the ordering was unset for at least one category. */ public static synchronized boolean unsetVendorOrdering( final String vendor1, final String vendor2) { return getServiceRegistry() .setOrdering( Factory.class, false, new VendorFilter(vendor1), new VendorFilter(vendor2)); }
/** * Unsets a pairwise ordering between two authorities. If one or both authorities are not * currently registered, or if the desired ordering is already unset, nothing happens and {@code * false} is returned. * * @param authority1 The preferred authority. * @param authority2 The vendor to which {@code authority1} is preferred. * @return {@code true} if the ordering was unset for at least one category. */ public static synchronized boolean unsetAuthorityOrdering( final String authority1, final String authority2) { return getServiceRegistry() .setOrdering( AuthorityFactory.class, false, new AuthorityFilter(authority1), new AuthorityFilter(authority2)); }
/** * Sets a pairwise ordering between two vendors. If one or both vendors are not currently * registered, or if the desired ordering is already set, nothing happens and {@code false} is * returned. * * <p>The example below said that an ESRI implementation (if available) is preferred over the * Geotools one: * * <blockquote> * * <code>FactoryFinder.setVendorOrdering("ESRI", "Geotools");</code> * * </blockquote> * * @param vendor1 The preferred vendor. * @param vendor2 The vendor to which {@code vendor1} is preferred. * @return {@code true} if the ordering was set for at least one category. */ public static synchronized boolean setVendorOrdering( final String vendor1, final String vendor2) { return getServiceRegistry() .setOrdering( Factory.class, true, new VendorFilter(vendor1), new VendorFilter(vendor2)); }
for (final T other : factories) { if (other != factory) { setOrdering(category, factory, other);
/** * Sets a pairwise ordering between two authorities. If one or both authorities are not * currently registered, or if the desired ordering is already set, nothing happens and {@code * false} is returned. * * <p>The example below said that EPSG {@linkplain AuthorityFactory authority factories} are * preferred over ESRI ones: * * <blockquote> * * <code>FactoryFinder.setAuthorityOrdering("EPSG", "ESRI");</code> * * </blockquote> * * @param authority1 The preferred authority. * @param authority2 The authority to which {@code authority1} is preferred. * @return {@code true} if the ordering was set for at least one category. */ public static synchronized boolean setAuthorityOrdering( final String authority1, final String authority2) { return getServiceRegistry() .setOrdering( AuthorityFactory.class, true, new AuthorityFilter(authority1), new AuthorityFilter(authority2)); }