/** * Returns the default set of hints used for the various utility classes. This default set is * determined by: * * <p> * * <ul> * <li>The {@linplain System#getProperties system properties} available. Some property keys * are enumerated in the {@link GeoTools} class. * <li>Any hints added by call to the {@link Hints#putSystemDefault} or {@link #init} method. * </ul> * * <p><b>Long term plan:</b> We would like to transition the utility classes to being injected * with their required factories, either by taking Hints as part of their constructor, or * otherwise. Making this change would be a three step process 1) create instance methods for * each static final class method 2) create an singleton instance of the class 3) change each * static final class method into a call to the singleton. With this in place we could then * encourage client code to make use of utility class instances before eventually retiring the * static final methods. * * @return A copy of the default hints. It is safe to add to it. */ public static Hints getDefaultHints() { return Hints.getDefaults(false); } /**
/** * Returns new hints that combine user supplied hints with the {@linkplain * GeoTools#getDefaultHints defaults hints}. If a hint is specified in both user and default * hints, then user hints have precedence. * * <p>The returned hints should live only the time needed for invoking {@link FactoryRegistry} * methods. No long-term reference should be held. * * @param hints The user hints, or {@code null} if none. * @return New hints (never {@code null}). */ public static Hints mergeSystemHints(final Hints hints) { if (hints instanceof StrictHints) { /* * The hints have already been merged in a previous call to this method and we don't * want to merge them again. This case happen typically in factory constructor fetching * for dependencies. The constructor may have removed some hints. For example the * "URN:OGC" factory may looks for the "EPSG" factory with FORCE_LONGITUDE_FIRST * forced to FALSE. */ return hints; } final Hints merged = Hints.getDefaults(true); if (hints != null) { merged.add(hints); } return merged; } }