Wrap a single.
@param source The source
@param instrumentations The instrumentations
@param <T> The type
@return The wrapped subscriber
966344
static <T> Single<T> wrap(
            SingleSource<T> source, Collection<ReactiveInstrumenter> instrumentations) {
        if (source instanceof Callable) {
            return new RxInstrumentedCallableSingle<>(source, instrumentations);
        }
        return new RxInstrumentedSingle<>(source, instrumentations);
    }
882632
protected final OnDemandStatsProducer getProducer(Class producerClass, String producerId, String category, String subsystem, boolean tracingSupported){
        OnDemandStatsProducer<T> producer = (OnDemandStatsProducer<T>) ProducerRegistryFactory.getProducerRegistryInstance().getProducer(producerId);

        if (producer == null) {
            producer = new OnDemandStatsProducer<T>(producerId, category, subsystem, getStatsFactory());
            producer.setTracingSupported(tracingSupported);
            ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(producer);

            //check for annotations
            createClassLevelAccumulators(producer, producerClass);

            for (Method method : producerClass.getMethods()){
                createMethodLevelAccumulators(producer, method);
            }
        }

        try {
            return  (OnDemandStatsProducer) ProducerRegistryFactory.getProducerRegistryInstance().getProducer(producerId);
        } catch (ClassCastException e) {
            LOGGER.error("getProducer(): Unexpected producer type", e);
            return null;
        }
    }
175696
protected void registerInstrumentationService(BundleContext systemContext) {
        Instrumentation inst = config.getInstrumentation();
        if (inst != null) {
            // Register a wrapper so we can trace callers.
            inst = (Instrumentation) Proxy.newProxyInstance(TraceInstrumentation.class.getClassLoader(),
                                                            new Class[] { Instrumentation.class },
                                                            new TraceInstrumentation(inst));
            Hashtable<String, String> svcProps = new Hashtable<String, String>();
            systemContext.registerService(Instrumentation.class.getName(), inst, svcProps);
        }
    }
1062449
@Override
    public DataByteInput<T> source(final T source) {
        return (DataByteInput<T>) super.source(source);
    }
802220
public static <T> Supplier<T> supplier(CheckedSupplier<T> supplier) {
        return Unchecked.supplier(supplier, Unchecked.RETHROW_ALL);
    }
444417
public static <T> Subscription listBind(
            List<? super T> target,
            ObservableList<? extends T> source) {
        target.clear();
        target.addAll(source);
        ListChangeListener<? super T> listener = change -> {
            while(change.next()) {
                int from = change.getFrom();
                int to = change.getTo();
                if(change.wasPermutated()) {
                    target.subList(from, to).clear();
                    target.addAll(from, source.subList(from, to));
                } else {
                    target.subList(from, from + change.getRemovedSize()).clear();
                    target.addAll(from, source.subList(from, from + change.getAddedSize()));
                }
            }
        };
        source.addListener(listener);
        return () -> source.removeListener(listener);
    }
45611
public ConstructorDoc wrap(ConstructorDoc source) {
		if (source == null || source instanceof Proxy<?> || !(source instanceof ConstructorDocImpl)) {
			return source;
		}
		return new ConstructorDocWrapper((ConstructorDocImpl) source);
	}
1368748
List<Snippet> sourceToSnippetsWithWrappers(String userSource) {
        List<Snippet> snippets = sourceToSnippets(userSource);
        for (Snippet snip : snippets) {
            if (snip.outerWrap() == null) {
                snip.setOuterWrap(
                        (snip.kind() == Kind.IMPORT)
                                ? state.outerMap.wrapImport(snip.guts(), snip)
                                : state.outerMap.wrapInTrialClass(snip.guts())
                );
            }
        }
        return snippets;
    }
1254520
public static <T> Supplier<Optional<T>> supplier(Iterator<T> adaptee) {
        return new IteratingSupplier<T>(adaptee);
    }
1197731
static <T> Maybe<T> wrap(
            MaybeSource<T> source, Collection<ReactiveInstrumenter> instrumentations) {
        if (source instanceof Callable) {
            return new RxInstrumentedCallableMaybe<>(source, instrumentations);
        }
        return new RxInstrumentedMaybe<>(source, instrumentations);
    }
810940
public static Class<?>[] convertParams(Object[] source) {
        Class<?>[] converted = null;
        if (source != null) {
            converted = new Class<?>[source.length];
            for (int i = 0; i < source.length; i++) {
                if (source[i] != null) {
                    // if the class is not an instance of IConnection use its class
                    //if (!IConnection.class.isInstance(source[i])) {
                    converted[i] = source[i].getClass();
                    //} else {
                    // if it does implement IConnection use the interface
                    //converted[i] = IConnection.class;
                    //}
                } else {
                    converted[i] = null;
                }
            }
        } else {
            converted = new Class<?>[0];
        }
        if (log.isTraceEnabled()) {
            log.trace("Converted parameters: {}", Arrays.toString(converted));
        }
        return converted;
    }
954873
static <T> Flowable<T> wrap(
            Publisher<T> source, Collection<ReactiveInstrumenter> instrumentations) {
        if (source instanceof Callable) {
            return new RxInstrumentedCallableFlowable<>(source, instrumentations);
        }
        return new RxInstrumentedFlowable<>(source, instrumentations);
    }
1293415
@Override
	public <T> Optional<AuditableBeanWrapper<T>> getBeanWrapperFor(T source) {

		return Optional.of(source).flatMap(it -> {

			if (it instanceof Auditable) {
				return super.getBeanWrapperFor(source);
			}

			return entities.mapOnContext(it.getClass(), (context, entity) -> {

				MappingAuditingMetadata metadata = metadataCache.computeIfAbsent(
						it.getClass(),
						key -> new MappingAuditingMetadata(context, it.getClass()));

				return Optional.<AuditableBeanWrapper<T>>ofNullable(metadata.isAuditable() //
						? new MappingMetadataAuditableBeanWrapper<T>(
								entity.getPropertyAccessor(it), metadata)
						: null);

			}).orElseGet(() -> super.getBeanWrapperFor(source));
		});
	}
1122938
public AnnotationTypeElementDoc wrap(AnnotationTypeElementDoc source) {
		if (source == null || source instanceof Proxy<?> || !(source instanceof AnnotationTypeElementDocImpl)) {
			return source;
		}
		return new AnnotationTypeElementDocWrapper((AnnotationTypeElementDocImpl) source);
	}
255567
@SuppressWarnings("unchecked")
	public <T> Optional<AuditableBeanWrapper<T>> getBeanWrapperFor(T source) {

		Assert.notNull(source, "Source must not be null!");

		return Optional.of(source).map(it -> {

			if (it instanceof Auditable) {
				return (AuditableBeanWrapper<T>) new AuditableInterfaceBeanWrapper(
						(Auditable<Object, ?, TemporalAccessor>) it);
			}

			AnnotationAuditingMetadata metadata = AnnotationAuditingMetadata
					.getMetadata(it.getClass());

			if (metadata.isAuditable()) {
				return new ReflectionAuditingBeanWrapper<T>(it);
			}

			return null;
		});
	}
267860
static <WReqT, WRespT> ClientInterceptor wrapClientInterceptor(
      final ClientInterceptor interceptor,
      final Marshaller<WReqT> reqMarshaller,
      final Marshaller<WRespT> respMarshaller) {
    return new ClientInterceptor() {
      @Override
      public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
          final MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) {
        final MethodDescriptor<WReqT, WRespT> wrappedMethod =
            method.toBuilder(reqMarshaller, respMarshaller).build();
        final ClientCall<WReqT, WRespT> wrappedCall =
            interceptor.interceptCall(wrappedMethod, callOptions, next);
        return new PartialForwardingClientCall<ReqT, RespT>() {
          @Override
          public void start(final Listener<RespT> responseListener, Metadata headers) {
            wrappedCall.start(new PartialForwardingClientCallListener<WRespT>() {
              @Override
              public void onMessage(WRespT wMessage) {
                InputStream bytes = respMarshaller.stream(wMessage);
                RespT message = method.getResponseMarshaller().parse(bytes);
                responseListener.onMessage(message);
              }

              @Override
              protected Listener<?> delegate() {
                return responseListener;
              }
            }, headers);
          }

          @Override
          public void sendMessage(ReqT message) {
            InputStream bytes = method.getRequestMarshaller().stream(message);
            WReqT wReq = reqMarshaller.parse(bytes);
            wrappedCall.sendMessage(wReq);
          }

          @Override
          protected ClientCall<?, ?> delegate() {
            return wrappedCall;
          }
        };
      }
    };
  }
1142685
public static RateLimiterExports ofSupplier(String prefix, Supplier<Iterable<RateLimiter>> rateLimitersSupplier) {
        return new RateLimiterExports(prefix, rateLimitersSupplier);
    }