code: private static BigDecimal getBigDecimalOrNull(Object value) {
              if ( !(value instanceof Number || value instanceof String) ) {
                  return null;
              }
              if ( !BigDecimal.class.isAssignableFrom( value.getClass() ) ) {
                  if ( value instanceof Long || value instanceof Integer || value instanceof Short || value instanceof Byte ||
                       value instanceof AtomicLong || value instanceof AtomicInteger ) {
                      value = new BigDecimal( ((Number) value).longValue(), MathContext.DECIMAL128 );
                  } else if ( value instanceof BigInteger ) {
                      value = new BigDecimal( ((BigInteger) value).toString(), MathContext.DECIMAL128 );
                  } else if ( value instanceof String ) {
                      // we need to remove leading zeros to prevent octal conversion
                      value = new BigDecimal( ((String) value).replaceFirst("^0+(?!$)", ""), MathContext.DECIMAL128 );
                  } else {
                      value = new BigDecimal( ((Number) value).doubleValue(), MathContext.DECIMAL128 );
                  }
              }
              return (BigDecimal) value;
          }
docs: copied from DMN FEEL utils