/** * Returns a finder which can be used for looking up unidentified objects. The default * implementation delegates the lookups to the primary factory, and fallback on the second one * if the primary factory can't find a match. * * @since 2.4 */ @Override public IdentifiedObjectFinder getIdentifiedObjectFinder(Class<? extends IdentifiedObject> type) throws FactoryException { return new Finder(type); }
/** Returns the identifier of the specified object, or {@code null} if none. */ @Override public String findIdentifier(final IdentifiedObject object) throws FactoryException { String candidate = finder.findIdentifier(object); if (candidate != null) { return candidate; } ensureFallback(); candidate = fallback.findIdentifier(object); return candidate; } }
/** Makes sure that {@link #fallback} is initialized. */ private void ensureFallback() throws FactoryException { if (fallback == null) { fallback = FallbackAuthorityFactory.this.fallback.getIdentifiedObjectFinder( getProxy().getType()); } fallback.setFullScanAllowed(isFullScanAllowed()); }
/** Lookups for the specified object. */ @Override public IdentifiedObject find(final IdentifiedObject object) throws FactoryException { IdentifiedObject candidate = finder.find(object); if (candidate != null) { return candidate; } ensureFallback(); candidate = fallback.find(object); return candidate; }