core/src/main/java/io/tracee/contextlogger/outputgenerator/functions/TraceeContextProviderWrapperFunction.java
public Object apply(ContextLoggerConfiguration contextLoggerConfiguration, Object instanceToWrap) {

		// check for implicit context
		if (IsImplicitContextEnumValuePredicate.getInstance().apply(instanceToWrap)) {
			return createInstance((Class) contextLoggerConfiguration.getImplicitContextProviderClass((ImplicitContext) instanceToWrap));
		}

		// now try to find instance type in known wrapper types map
		Class matchingWrapperType = contextLoggerConfiguration.getContextProviderClass(instanceToWrap.getClass());
		if (matchingWrapperType == null) {

			// now try to find instance type in TypeToWrapper List
			for (TypeToWrapper wrapper : contextLoggerConfiguration.getWrapperList()) {
				if (wrapper.getWrappedInstanceType().isAssignableFrom(instanceToWrap.getClass())) {
					matchingWrapperType = wrapper.getWrapperType();
					break;
				}
			}

		}

		if (matchingWrapperType != null) {
			// now create wrapper instance
			try {
				WrappedContextData wrapperInstance = (WrappedContextData) createInstance(matchingWrapperType);
				wrapperInstance.setContextData(instanceToWrap);

				return wrapperInstance;
			} catch (Exception e) {
				// continue

			}
		}

		return instanceToWrap;
	}
public Object apply(ContextLoggerConfiguration contextLoggerConfiguration, Object instanceToWrap) {

		// check for implicit context
		if (IsImplicitContextEnumValuePredicate.getInstance().apply(instanceToWrap)) {
			return createInstance((Class) contextLoggerConfiguration.getImplicitContextProviderClass((ImplicitContext) instanceToWrap));
		}

		// now try to find instance type in known wrapper types map
		Class matchingWrapperType = contextLoggerConfiguration.getContextProviderClass(instanceToWrap.getClass());
		if (matchingWrapperType == null) {

			// now try to find instance type in TypeToWrapper List
			for (TypeToWrapper wrapper : contextLoggerConfiguration.getWrapperList()) {
				if (wrapper.getWrappedInstanceType().isAssignableFrom(instanceToWrap.getClass())) {
					matchingWrapperType = wrapper.getWrapperType();
					break;
				}
			}

		}

		if (matchingWrapperType != null) {
			// now create wrapper instance
			try {
				WrappedContextData wrapperInstance = (WrappedContextData) createInstance(matchingWrapperType);
				wrapperInstance.setContextData(instanceToWrap);

				return wrapperInstance;
			} catch (Exception e) {
				// continue

			}
		}

		return instanceToWrap;
	}
Wraps the passed instance inside a matching tracee context logging provider instance.
Will return the passed instance, if no matching tracee context logging provider exists.

@param contextLoggerConfiguration the configuration to use
@param instanceToWrap             the instance to wrap
@return either a tracee context provider that encapsulates the passed instance or the instance itself if no matching context provider exists