Retrieves an existing resource assignment if one is present,
to prevent duplicate resource assignments being added.

@param resource resource to test for
@return existing resource assignment
349875
private ResourceAssignment getExistingResourceAssignment(Resource resource)
   {
      ResourceAssignment assignment = null;
      Integer resourceUniqueID = null;

      if (resource != null)
      {
         Iterator<ResourceAssignment> iter = m_assignments.iterator();
         resourceUniqueID = resource.getUniqueID();

         while (iter.hasNext() == true)
         {
            assignment = iter.next();
            Integer uniqueID = assignment.getResourceUniqueID();
            if (uniqueID != null && uniqueID.equals(resourceUniqueID) == true)
            {
               break;
            }
            assignment = null;
         }
      }

      return assignment;
   }
33056
@Override
	public LinkRelation getCollectionResourceRelFor(Class<?> resource) {

		LookupContext context = LookupContext.forCollectionResourceRelLookup(entityType);

		return providers.getRequiredPluginFor(context).getCollectionResourceRelFor(resource);
	}
1014615
public static List<Resource> getJarContents(@NonNull Resource resource) {
      return getResourcesFromJar(resource, v -> true);
   }
510018
protected Reader createResourceReader(Resource resource) {
        try {
            return new InputStreamReader(resource.getInputStream());
        }
        catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
672703
public static EnumerationIter<URL> getResourceIter(String resource) {
		final Enumeration<URL> resources;
		try {
			resources = ClassLoaderUtil.getClassLoader().getResources(resource);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
		return new EnumerationIter<>(resources);
	}
1277819
public UriMappingResolver addResource(String uri, String resource) {
        uriMap.put(uri, resource);
        return this;
    }
712452
private boolean add(ResourceInternal<T> resource) {
    try {
      mLock.lock();
      if (mResources.size() >= mMaxCapacity) {
        return false;
      } else {
        mResources.put(resource.mResource, resource);
        return true;
      }
    } finally {
      mLock.unlock();
    }
  }
1001848
public Resource getMissingResource(final ResourceList resources) {
        try {
            return _withLock(new Callable<Resource>() {
                @Override
                public Resource call() {
                    return resources.getConflict(inUse);
                }
            });
        } catch (Exception e) {
            throw new IllegalStateException("Inner callable does not throw exception");
        }
    }
612932
public @NotNull List<Resource> getResources() {
    return getResources((Predicate<Resource>)null, (Resource)null);
  }
298681
public I_CmsResourceLoader getLoader(CmsResource resource) throws CmsLoaderException {

        return getLoader(getResourceType(resource.getTypeId()).getLoaderId());
    }
293038
public void setAllocatedResource(final AllocatedResource resource) {

		final Iterator<ExecutionVertex> it = this.vertices.iterator();
		while (it.hasNext()) {
			final ExecutionVertex vertex = it.next();
			vertex.setAllocatedResource(resource);
		}
	}
280123
public ResourceClassLoader getCustomResourceClassLoader(Resource[] resources) throws IOException {

	if (ArrayUtil.isEmpty(resources)) return this;

	String key = hash(resources);
	ResourceClassLoader rcl = (customCLs == null) ? null : customCLs.get(key);

	if (rcl != null) return rcl;

	resources = ResourceUtil.merge(this.getResources(), resources);
	rcl = new ResourceClassLoader(resources, getParent());

	if (customCLs == null) customCLs = new ReferenceMap<String, ResourceClassLoader>();

	customCLs.put(key, rcl);
	return rcl;
    }
1107181
public static Resource wrap(@NotNull Resource resource) {
    return wrap(resource, resource.getValueMap(), resource.getChildren());
  }
803937
public static ResourceHandle use(Resource resource) {
        return resource instanceof ResourceHandle
                ? ((ResourceHandle) resource) : new ResourceHandle(resource);
    }
1067269
@Override
	public LinkRelation getItemResourceRelFor(Class<?> resource) {

		LookupContext context = LookupContext.forItemResourceRelLookup(entityType);

		return providers.getRequiredPluginFor(context).getItemResourceRelFor(resource);
	}
544420
public static boolean doesResourceExist(final Resource res) {
        if (res != null) {
            try {
                IOUtils.read(res.getInputStream(), new byte[1]);
                return res.contentLength() > 0;
            } catch (final FileNotFoundException e) {
                LOGGER.trace(e.getMessage());
                return false;
            } catch (final Exception e) {
                LOGGER.trace(e.getMessage(), e);
                return false;
            }
        }
        return false;
    }
1218226
public static Enumeration<URL> getResources(String resource) {
        Enumeration<URL> urls = null;
        try {
            urls = ClassUtils.getContextClassLoader().getResources(resource);
        } catch (IOException e) {
            //noop
        }
        if (urls == null) {
            try {
                urls = IOUtils.class.getClassLoader().getResources(resource);
            } catch (IOException e) {
                //noop
            }
        }

        if (urls == null) {
            URL url = IOUtils.class.getResource(resource);
            if (url != null) {
                final Iterator<URL> it = Lists.newArrayList(url).iterator();
                urls = new Enumeration<URL>() {
                    public boolean hasMoreElements() {
                        return it.hasNext();
                    }

                    public URL nextElement() {
                        return it.next();
                    }
                };
            }
        }

        if (urls == null) {
            File file = new File(resource);
            if (file.isFile()) {
                try {
                    final Iterator<URL> it = Lists.newArrayList(file.toURI().toURL()).iterator();
                    urls = new Enumeration<URL>() {
                        public boolean hasMoreElements() {
                            return it.hasNext();
                        }

                        public URL nextElement() {
                            return it.next();
                        }
                    };
                } catch (MalformedURLException e) {
                    //no op
                }
            }
        }

        return urls == null ? new Enumeration<URL>() {
            public boolean hasMoreElements() {
                return false;
            }

            public URL nextElement() {
                return null;
            }
        } : urls;
    }