private MetaTypeProviderWrapper[] getMetaTypeProviders() {
   Map<ServiceReference<Object>, Object> services = _tracker.getTracked();
   if (services.isEmpty()) return new MetaTypeProviderWrapper[0];
   Set<ServiceReference<Object>> serviceReferences = services.keySet();
   Set<MetaTypeProviderWrapper> result = new HashSet<MetaTypeProviderWrapper>();
   for (ServiceReference<Object> serviceReference : serviceReferences) {
     if (serviceReference.getBundle() == _bundle) {
       Object service = services.get(serviceReference);
       // If the service is not a MetaTypeProvider, we're not interested in it.
       if (service instanceof MetaTypeProvider) {
         // Include the METATYPE_PID, if present, to return as part of getPids(). Also, include the
         // METATYPE_FACTORY_PID, if present, to return as part of getFactoryPids().
         // The filter ensures at least one of these properties was set for a standalone
         // MetaTypeProvider.
         addMetaTypeProviderWrappers(
             MetaTypeProvider.METATYPE_PID,
             serviceReference,
             (MetaTypeProvider) service,
             false,
             result);
         addMetaTypeProviderWrappers(
             MetaTypeProvider.METATYPE_FACTORY_PID,
             serviceReference,
             (MetaTypeProvider) service,
             true,
             result);
         // If the service is a ManagedService, include the SERVICE_PID to return as part of
         // getPids().
         // The filter ensures the SERVICE_PID property was set.
         if (service instanceof ManagedService) {
           addMetaTypeProviderWrappers(
               Constants.SERVICE_PID, serviceReference, (MetaTypeProvider) service, false, result);
         }
         // If the service is a ManagedServiceFactory, include the SERVICE_PID to return as part of
         // getFactoryPids().
         // The filter ensures the SERVICE_PID property was set.
         else if (service instanceof ManagedServiceFactory) {
           addMetaTypeProviderWrappers(
               Constants.SERVICE_PID, serviceReference, (MetaTypeProvider) service, true, result);
         }
       }
     }
   }
   return result.toArray(new MetaTypeProviderWrapper[result.size()]);
 }
 private void addMetaTypeProviderWrappers(
     String servicePropertyName,
     ServiceReference<Object> serviceReference,
     MetaTypeProvider service,
     boolean factory,
     Set<MetaTypeProviderWrapper> wrappers) {
   String[] pids =
       getStringProperty(servicePropertyName, serviceReference.getProperty(servicePropertyName));
   for (String pid : pids) {
     wrappers.add(new MetaTypeProviderWrapper(service, pid, factory));
   }
 }