Class ResourceUtils

java.lang.Object
aQute.bnd.osgi.resource.ResourceUtils

public class ResourceUtils extends Object
  • Field Details

    • IDENTITY_VERSION_COMPARATOR

      public static final Comparator<? super org.osgi.resource.Resource> IDENTITY_VERSION_COMPARATOR
      A comparator that compares the identity versions
    • RESOURCE_COMPARATOR

      private static final Comparator<? super org.osgi.resource.Resource> RESOURCE_COMPARATOR
    • DUMMY_RESOURCE

      public static final org.osgi.resource.Resource DUMMY_RESOURCE
    • WORKSPACE_NAMESPACE

      public static final String WORKSPACE_NAMESPACE
      See Also:
    • cnv

      private static final Converter cnv
    • ATTR_NAME

      private static final Pattern ATTR_NAME
    • all

      private static final Collection<org.osgi.resource.Requirement> all
    • nullsFirst

      private static final Comparator<Comparable> nullsFirst
  • Constructor Details

    • ResourceUtils

      public ResourceUtils()
  • Method Details

    • capabilityStream

      public static Stream<org.osgi.resource.Capability> capabilityStream(org.osgi.resource.Resource resource, String namespace)
    • capabilityStream

      public static <T extends org.osgi.resource.Capability> Stream<T> capabilityStream(org.osgi.resource.Resource resource, String namespace, Class<T> type)
    • getContentCapability

      public static ResourceUtils.ContentCapability getContentCapability(org.osgi.resource.Resource resource)
    • getURI

      public static Optional<URI> getURI(org.osgi.resource.Resource resource)
    • getContentCapabilities

      public static List<ResourceUtils.ContentCapability> getContentCapabilities(org.osgi.resource.Resource resource)
    • getIdentityCapability

      public static ResourceUtils.IdentityCapability getIdentityCapability(org.osgi.resource.Resource resource)
    • getBundleId

      public static BundleId getBundleId(org.osgi.resource.Resource resource)
    • getIdentityVersion

      public static String getIdentityVersion(org.osgi.resource.Resource resource)
    • getBundleCapability

      public static ResourceUtils.BundleCap getBundleCapability(org.osgi.resource.Resource resource)
    • toVersion

      public static Version toVersion(Object v)
    • getVersion

      public static Version getVersion(org.osgi.resource.Capability cap)
    • getURI

      public static URI getURI(org.osgi.resource.Capability contentCapability)
    • getVersionAttributeForNamespace

      public static String getVersionAttributeForNamespace(String namespace)
    • as

      public static <T extends org.osgi.resource.Capability> T as(org.osgi.resource.Capability cap, Class<T> type)
    • as

      public static <T extends org.osgi.resource.Requirement> T as(org.osgi.resource.Requirement req, Class<T> type)
    • get

      private static Object get(Method method, Map<String,Object> attrs, Map<String,String> directives, Object[] args) throws Exception
      Throws:
      Exception
    • getValue

      private static Object getValue(Map<String,?> attrs, String name)
    • getResources

      public static Set<org.osgi.resource.Resource> getResources(Collection<? extends org.osgi.resource.Capability> providers)
    • getIndexedByResource

      public static Map<org.osgi.resource.Resource,List<org.osgi.resource.Capability>> getIndexedByResource(Collection<? extends org.osgi.resource.Capability> providers)
    • getResources

      private static Set<org.osgi.resource.Resource> getResources(Stream<? extends org.osgi.resource.Capability> providers)
    • createWildcardRequirement

      public static org.osgi.resource.Requirement createWildcardRequirement()
    • isEffective

      public static boolean isEffective(org.osgi.resource.Requirement r, org.osgi.resource.Capability c)
    • filterPredicate

      public static Predicate<Map<String,Object>> filterPredicate(String filterString)
    • matches

      public static boolean matches(org.osgi.resource.Requirement requirement, org.osgi.resource.Resource resource)
    • matches

      public static boolean matches(org.osgi.resource.Requirement requirement, org.osgi.resource.Capability capability)
    • matcher

      public static Predicate<org.osgi.resource.Capability> matcher(org.osgi.resource.Requirement requirement)
    • matcher

      public static Predicate<org.osgi.resource.Capability> matcher(org.osgi.resource.Requirement requirement, Function<String,Predicate<Map<String,Object>>> filter)
    • filterMatcher

      public static Predicate<org.osgi.resource.Capability> filterMatcher(org.osgi.resource.Requirement requirement)
    • filterMatcher

      public static Predicate<org.osgi.resource.Capability> filterMatcher(org.osgi.resource.Requirement requirement, Function<String,Predicate<Map<String,Object>>> filter)
    • getEffective

      public static String getEffective(Map<String,String> directives)
    • getResolution

      public static ResolutionDirective getResolution(org.osgi.resource.Requirement requirement)
    • toRequireCapability

      public static String toRequireCapability(org.osgi.resource.Requirement requirement) throws Exception
      Throws:
      Exception
    • toProvideCapability

      public static String toProvideCapability(org.osgi.resource.Capability capability) throws Exception
      Throws:
      Exception
    • getLocations

      public static Map<URI,String> getLocations(org.osgi.resource.Resource resource)
    • findProviders

      public static List<org.osgi.resource.Capability> findProviders(org.osgi.resource.Requirement requirement, Collection<? extends org.osgi.resource.Capability> capabilities)
    • isFragment

      public static boolean isFragment(org.osgi.resource.Resource resource)
    • stripDirective

      public static String stripDirective(String name)
    • getIdentity

      public static String getIdentity(org.osgi.resource.Capability identityCapability) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • toVersionClause

      public static VersionedClause toVersionClause(org.osgi.resource.Resource resource)
      Create a VersionedClause by applying a version range mask to the resource! Masks are defined by Macro._range(String[]). If the resource should represent a project in the bnd workspace, then instead the VersionClause will refer to it as a snapshot version: e.g. ;version=snapshot
    • toVersionClause

      public static VersionedClause toVersionClause(org.osgi.resource.Resource resource, String mask)
    • toVersionedClauses

      public static List<VersionedClause> toVersionedClauses(Collection<org.osgi.resource.Resource> resources)
    • getAllResources

      public static Set<org.osgi.resource.Resource> getAllResources(org.osgi.service.repository.Repository repository)
      Return all resources from a repository as returned by the wildcard requirement, see createWildcardRequirement()
      Parameters:
      repository - the repository to use
      Returns:
      a set of resources from the repository.
    • compareTo

      public static int compareTo(org.osgi.resource.Resource a, org.osgi.resource.Resource b)
      Compare two resources. This can be used to act as a comparator. The comparison is first done on name and then version.
      Parameters:
      a - the left resource
      b - the right resource
      Returns:
      0 if equal bame and version, 1 if left has a higher name or same name and higher version, -1 otherwise
    • sort

      public static List<org.osgi.resource.Resource> sort(Collection<org.osgi.resource.Resource> resources)
    • sortByNameVersion

      public static List<org.osgi.resource.Resource> sortByNameVersion(Collection<org.osgi.resource.Resource> resources)
      Sort the resources by symbolic name and version
      Parameters:
      resources - the set of resources to sort
      Returns:
      a sorted set of resources
    • isInitialRequirement

      public static boolean isInitialRequirement(org.osgi.resource.Resource resource)
    • toCapabilities

      public static <CAPABILITY extends org.osgi.resource.Capability> Collector<CAPABILITY,List<CAPABILITY>,List<CAPABILITY>> toCapabilities()
    • capabilitiesAccumulator

      public static <CAPABILITY extends org.osgi.resource.Capability, COLLECTION extends Collection<CAPABILITY>> void capabilitiesAccumulator(COLLECTION collection, CAPABILITY capability)
    • capabilitiesCombiner

      public static <CAPABILITY extends org.osgi.resource.Capability, COLLECTION extends Collection<CAPABILITY>> COLLECTION capabilitiesCombiner(COLLECTION leftCollection, COLLECTION rightCollection)