org.apache.felix.ipojo.dependency.impl

## Class ServiceReferenceUtils

- java.lang.Object
- - org.apache.felix.ipojo.dependency.impl.ServiceReferenceUtils

    public class ServiceReferenceUtils
    extends java.lang.Object

Some utility methods to handle service references.

### Constructor Summary

Constructors
Constructor and Description
`ServiceReferenceUtils()`

### Method Summary

All Methods Static Methods Concrete Methods
`static boolean` `containsReferenceById(java.util.List<? extends org.osgi.framework.ServiceReference> references, org.osgi.framework.ServiceReference ref)` Checks whether a list of service references contains a reference with the same service.id as the given reference.
`static org.osgi.framework.ServiceReference` `getServiceReferenceById(java.util.List<? extends org.osgi.framework.ServiceReference> references, org.osgi.framework.ServiceReference ref)` Gets a service reference with the same service.id as the given reference from the given list.
`static boolean` `haveSameProperties(org.osgi.framework.ServiceReference ref1, org.osgi.framework.ServiceReference ref2)` Checks whether the two references has the same properties and their value are equals.
`static boolean` `haveSameServiceId(org.osgi.framework.ServiceReference ref1, org.osgi.framework.ServiceReference ref2)` Checks whether two service references have the same service id.
`static boolean` `match(org.osgi.framework.Filter filter, org.osgi.framework.ServiceReference ref)` Checks if the given service reference match the current filter.
`static java.lang.String` `toString(java.util.Collection<? extends org.osgi.framework.ServiceReference> references)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ServiceReferenceUtils

    public ServiceReferenceUtils()

### Method Detail

#### match

    public static boolean match(org.osgi.framework.Filter filter,
                                org.osgi.framework.ServiceReference ref)

Checks if the given service reference match the current filter. This method aims to avoid calling `Filter.match(org.osgi.framework.ServiceReference)` method when manipulating a composite reference. In fact, this method thrown a `ClassCastException` on Equinox.

Parameters:
  `ref` - the service reference to check.
Returns:
  `true` if the service reference matches.

#### containsReferenceById

    public static boolean containsReferenceById(java.util.List<? extends org.osgi.framework.ServiceReference> references,
                                                org.osgi.framework.ServiceReference ref)

Checks whether a list of service references contains a reference with the same service.id as the given reference.

Parameters:
  `references` - the list of reference
  `ref` - the reference
Returns:
  true if references contains a reference with the same service.id as ref.

#### getServiceReferenceById

    public static org.osgi.framework.ServiceReference getServiceReferenceById(java.util.List<? extends org.osgi.framework.ServiceReference> references,
                                                                              org.osgi.framework.ServiceReference ref)

Gets a service reference with the same service.id as the given reference from the given list.

Parameters:
  `references` - the list of references
  `ref` - the reference
Returns:
  the service reference from references having the same service.id as ref. null if there is no such reference in the list.

#### haveSameProperties

    public static boolean haveSameProperties(org.osgi.framework.ServiceReference ref1,
                                             org.osgi.framework.ServiceReference ref2)

Checks whether the two references has the same properties and their value are equals.

Parameters:
  `ref1` - first reference
  `ref2` - second reference
Returns:
  true if the two references have the same properties and their values are equals.

#### haveSameServiceId

    public static boolean haveSameServiceId(org.osgi.framework.ServiceReference ref1,
                                            org.osgi.framework.ServiceReference ref2)

Checks whether two service references have the same service id.

Parameters:
  `ref1` - first reference
  `ref2` - second reference
Returns:
  true if the two references have the same service.id, false otherwise.

#### toString

    public static java.lang.String toString(java.util.Collection<? extends org.osgi.framework.ServiceReference> references)