/** * Searches for a resource identified by the given identifier. The given identifier should be the string * representation of the return value of {@link Resource#getIdentifier()} on the desired resource. * Implementation may also accept aliases for convenience. For example if the full name of a resource * is {@code "foo:bar"}, then this method may accept {@code "bar"} as a synonymous of {@code "foo:bar"} * provided that it does not introduce ambiguity. * * <p>The default implementation verifies if above criterion matches to this {@code DataStore} * (which is itself a resource), then iterates recursively over {@link Aggregate} components * if this data store is an aggregate. * If a match is found without ambiguity, the associated resource is returned. Otherwise an exception is thrown. * Subclasses are encouraged to override this method with a more efficient implementation.</p> * * @param identifier identifier of the resource to fetch. Must be non-null. * @return resource associated to the given identifier (never {@code null}). * @throws IllegalNameException if no resource is found for the given identifier, or if more than one resource is found. * @throws DataStoreException if another kind of error occurred while searching resources. * * @see Resource#getIdentifier() * @see FeatureNaming */ public Resource findResource(final String identifier) throws DataStoreException { ArgumentChecks.ensureNonEmpty("identifier", identifier); final Resource resource = findResource(identifier, this, new IdentityHashMap<>()); if (resource != null) { return resource; } throw new IllegalNameException(StoreUtilities.resourceNotFound(this, identifier)); }
final Resource resource = findResource(identifier, this, new IdentityHashMap<Resource,Boolean>()); if (resource != null) { return resource;
Resource result = null; for (final Resource child : ((Aggregate) candidate).components()) { final Resource match = findResource(identifier, child, visited); if (match != null) { if (result == null) {
Resource result = null; for (final Resource child : ((Aggregate) candidate).components()) { final Resource match = findResource(identifier, child, visited); if (match != null) { if (result == null) {