private static Object marshalArg(Class<?> declaredType, Object value) {
		final String sourceMethod = "marshalArg"; //$NON-NLS-1$
		final boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(sourceClass, sourceMethod, new Object[]{declaredType, value});
		}
		Object result = null;
		Class<?> argType = value.getClass();
		if (!fromPrimitive(declaredType).isAssignableFrom(fromPrimitive(argType))) {
			if (declaredType.isAssignableFrom(Set.class) && value instanceof List) {
				// Convert the list to a set
				Set<?> set = new HashSet<Object>((List<?>)value);
				result = set;
			} else if (declaredType.isEnum() && argType.equals(String.class)) {
				// If the declared type is an enum and the provided type is a string,
				// then see if the string matches the name of an enum constant in the declared type.
				@SuppressWarnings("unchecked")
				Class<? extends Enum<?>> enumType = (Class<? extends Enum<?>>)declaredType;
				Object enumValue = getEnumNamesMap(enumType).get(value.toString());
				if (enumValue != null) {
					result = enumValue;
				}
			} else if (declaredType.isAssignableFrom(DiagnosticGroup.class) && argType.equals(String.class)) {
				// If the arg value matches a statically defined DiagnosticGroup in DiagnosticGroups, then
				// return that.
				result = findNamedDiagnosticGroup(value.toString());
			}
		} else {
			result = value;
		}
		if (isTraceLogging) {
			log.exiting(sourceMethod, sourceMethod, result);
		}
		return result;
	}
private static Object marshalArg ( Class < ? > declaredType , Object value ) { final String sourceMethod = "marshalArg" ; final boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( sourceClass , sourceMethod , new Object [ ] { declaredType , value } ) ; } Object result = null ; Class < ? > argType = value . getClass ( ) ; if ( ! fromPrimitive ( declaredType ) . isAssignableFrom ( fromPrimitive ( argType ) ) ) { if ( declaredType . isAssignableFrom ( Set . class ) && value instanceof List ) { Set < ? > set = new HashSet < Object > ( ( List < ? > ) value ) ; result = set ; } else if ( declaredType . isEnum ( ) && argType . equals ( String . class ) ) { @ SuppressWarnings ( "unchecked" ) Class < ? extends Enum < ? > > enumType = ( Class < ? extends Enum < ? > > ) declaredType ; Object enumValue = getEnumNamesMap ( enumType ) . get ( value . toString ( ) ) ; if ( enumValue != null ) { result = enumValue ; } } else if ( declaredType . isAssignableFrom ( DiagnosticGroup . class ) && argType . equals ( String . class ) ) { result = findNamedDiagnosticGroup ( value . toString ( ) ) ; } } else { result = value ; } if ( isTraceLogging ) { log . exiting ( sourceMethod , sourceMethod , result ) ; } return result ; }
Marshals the specified argument to the declared type. May involve conversion. The following
argument conversions may occur:
<ul>
<li>List to Set if the argument type is a List (i.e. NativeArray) and the declared type is Set
</li>
<li>Sting to Enum constant if the declared type is an Enum and the argument is a string which
matches one of the Enum constant names.</li>
</ul>

@param declaredType
the type of the argument declared in the class definition
@param value
the argument value provided in the config
@return the possibly converted argument value, or null if the value cannot be converted to
the declared type