# Util

`com.jsmacrosce.Util`

Provides numeric-value conversion for reflective calls and proxy argument or return values.  
 ```js
const Util = Java.type("com.jsmacrosce.Util");  
const Integer = Java.type("java.lang.Integer");  
const Double = Java.type("java.lang.Double");  
Chat.log(Util.tryAutoCastNumber(Integer.TYPE, Double.valueOf(3.75)));  
 ```

## Constructors

### new Util {#com.jsmacrosce.Util_constructor-}

```js
new Util()
```

## Methods

### tryAutoCastNumber {#com.jsmacrosce.Util_tryAutoCastNumber-Class-Object-}

```js
static tryAutoCastNumber(Class<?> returnType, Object number): Object
```

Converts a [Number](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Number.html) to the wrapper for a supported primitive or boxed target.  
 Supports `int`, `float`, `double`, `short`, `long`,  
 `char`, and `byte` targets; matching wrapper values are returned unchanged.  
 Numeric conversions use the corresponding [Number](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Number.html) conversion method, so narrowing
 conversions may discard or truncate value. For `char`, the value is converted through
 [Number.intValue()](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Number.html) and cast to `char`. Unsupported targets, including
 `null`, return `number` unchanged; `Boolean` is not converted. For a
 supported target, `null` input or an input that is neither the matching wrapper nor a
 [Number](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Number.html) fails during conversion.

**Parameters:**
- `returnType`: primitive or boxed target class
- `number`: value to convert

**Returns:** the converted wrapper, or the original value when no conversion applies
