/* (non-Javadoc)
@see com.ibm.ws.sib.matchspace.tools.Evaluator#castToNumberList(java.util.ArrayList)
344018
public ArrayList castToNumberList(ArrayList childNodeList) // was NumericValue
  {
    if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.entry(cclass, "castToNumberList", childNodeList);
 
    ArrayList numberList = new ArrayList();
    
    if(childNodeList != null)
    {
      Iterator iterNode = childNodeList.iterator();
      
      while(iterNode.hasNext())
      {
        String strValue = getStringFromNode(iterNode.next());
        
        // Cast the string to a Number
        Number num = EvaluatorImpl.castToNumber(strValue);
        if (tc.isAnyTracingEnabled() && tc.isDebugEnabled())
          tc.debug(cclass, "Add number to list: ", num);  
        numberList.add(num);
      }              
    }
    
    if (tc.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.exit(cclass, "castToNumberList", numberList);    
    return numberList;
  }
1294952
static List<String> integer(String name, @Nullable Integer value) {
    if (value != null) {
      return Arrays.asList("--" + name, value.toString());
    }
    return Collections.emptyList();
  }
1192185
protected void parseCombineIntegerLists(TokenList tokens) {
        TokenList.Token t = tokens.getFirst();
        if( t == null || t.next == null )
            return;

        int numFound = 0;

        TokenList.Token start = null;
        TokenList.Token end = null;

        while( t != null ) {
            if( t.getType() == Type.VARIABLE && (isVariableInteger(t) ||
                    t.getVariable().getType() == VariableType.INTEGER_SEQUENCE )) {
                if( numFound == 0 ) {
                    numFound = 1;
                    start = end = t;
                } else {
                    numFound++;
                    end = t;
                }
            } else if( numFound > 1 ) {
                IntegerSequence sequence = new IntegerSequence.Combined(start,end);
                VariableIntegerSequence varSequence = functions.getManagerTemp().createIntegerSequence(sequence);
                replaceSequence(tokens, varSequence, start, end);
                numFound = 0;
            } else {
                numFound = 0;
            }
            t = t.next;
        }

        if( numFound > 1 ) {
            IntegerSequence sequence = new IntegerSequence.Combined(start,end);
            VariableIntegerSequence varSequence = functions.getManagerTemp().createIntegerSequence(sequence);
            replaceSequence(tokens, varSequence, start, end);
        }
    }
188302
public static List<String> createSubjectList(int number, String stringFormat) {
                Validate.notNegative(number);
                Validate.notNull(stringFormat);
                List<String> result = new ArrayList<>(number);
                for (int i = 1; i <= number; i++) {
                        result.add(String.format(stringFormat, i));
                }
                return result;
        }
440585
@SuppressWarnings("unchecked")
    private static <T> Set<T> cast(Set<?> set) {
        return (Set<T>)set;
    }
849226
public static <T /*>>> extends @NonNull Object*/> void checkListElementNotNull(
      List<T> list, @javax.annotation.Nullable Object errorMessage) {
    for (T element : list) {
      if (element == null) {
        throw new NullPointerException(String.valueOf(errorMessage));
      }
    }
  }
762275
Number numberFor(Number source, Class<?> destinationType) {
    if (destinationType.equals(source.getClass()))
      return source;

    if (destinationType.equals(Byte.class)) {
      long longValue = source.longValue();
      if (longValue > Byte.MAX_VALUE)
        throw new Errors().errorTooLarge(source, destinationType).toMappingException();
      if (longValue < Byte.MIN_VALUE)
        throw new Errors().errorTooSmall(source, destinationType).toMappingException();
      return Byte.valueOf(source.byteValue());
    }

    if (destinationType.equals(Short.class)) {
      long longValue = source.longValue();
      if (longValue > Short.MAX_VALUE)
        throw new Errors().errorTooLarge(source, destinationType).toMappingException();
      if (longValue < Short.MIN_VALUE)
        throw new Errors().errorTooSmall(source, destinationType).toMappingException();
      return Short.valueOf(source.shortValue());
    }

    if (destinationType.equals(Integer.class)) {
      long longValue = source.longValue();
      if (longValue > Integer.MAX_VALUE)
        throw new Errors().errorTooLarge(source, destinationType).toMappingException();
      if (longValue < Integer.MIN_VALUE)
        throw new Errors().errorTooSmall(source, destinationType).toMappingException();
      return Integer.valueOf(source.intValue());
    }

    if (destinationType.equals(Long.class))
      return Long.valueOf(source.longValue());

    if (destinationType.equals(Float.class)) {
      if (source.doubleValue() > Float.MAX_VALUE)
        throw new Errors().errorTooLarge(source, destinationType).toMappingException();
      return Float.valueOf(source.floatValue());
    }

    if (destinationType.equals(Double.class))
      return Double.valueOf(source.doubleValue());

    if (destinationType.equals(BigDecimal.class)) {
      if (source instanceof Float || source instanceof Double)
        return new BigDecimal(source.toString());
      else if (source instanceof BigInteger)
        return new BigDecimal((BigInteger) source);
      else
        return BigDecimal.valueOf(source.longValue());
    }

    if (destinationType.equals(BigInteger.class)) {
      if (source instanceof BigDecimal)
        return ((BigDecimal) source).toBigInteger();
      else
        return BigInteger.valueOf(source.longValue());
    }

    throw new Errors().errorMapping(source, destinationType).toMappingException();
  }
148607
public PactDslJsonArray numberType(Number number) {
        body.put(number);
        matchers.addRule(rootPath + appendArrayIndex(0), new NumberTypeMatcher(NumberTypeMatcher.NumberType.NUMBER));
        return this;
    }
1101197
static Integer numerator(final String s) {
        if ("".equals(s)) {
            return null;
        }
        String[] tokens = s.split("/");
        return emptyToNullInteger(tokens[0]);
    }
1228117
public final void setNumber(StringBuilder contentBuffer) {
        lineValues[GpxMetadata.LINENUMBER] = Integer.parseInt(contentBuffer.toString());
    }
678844
public static boolean shouldAutoCastTo(PrimitiveType from, PrimitiveType to) {
		InternalType[] castTypes = POSSIBLE_CAST_MAP.get(from);
		if (castTypes != null) {
			for (InternalType type : POSSIBLE_CAST_MAP.get(from)) {
				if (type.equals(to)) {
					return true;
				}
			}
		}
		return false;
	}
247263
public Object castToType(int t, XPathContext support)
          throws javax.xml.transform.TransformerException
  {

    Object result;

    switch (t)
    {
    case CLASS_STRING :
      result = str();
      break;
    case CLASS_NUMBER :
      result = new Double(num());
      break;
    case CLASS_NODESET :
      result = iter();
      break;
    case CLASS_BOOLEAN :
      result = new Boolean(bool());
      break;
    case CLASS_UNKNOWN :
      result = m_obj;
      break;

    // %TBD%  What to do here?
    //    case CLASS_RTREEFRAG :
    //      result = rtree(support);
    //      break;
    default :
      error(XPATHErrorResources.ER_CANT_CONVERT_TO_TYPE,
            new Object[]{ getTypeString(),
                          Integer.toString(t) });  //"Can not convert "+getTypeString()+" to a type#"+t);

      result = null;
    }

    return result;
  }
21827
@Override
    public <T extends Number> T numberValueExact(Class<T> numberType) {
        return ConvertNumberValue.ofExact(numberType, number);
    }
1336201
public static <T> T castOrNull(Object o, Class<T> cls)
	{
		if(o == null)
			return null;
		if(cls.isInstance(o))
			return cls.cast(o);
		return null;
	}
242477
@SuppressWarnings("unchecked")
	public static <T> T parseNumber(String value, Class<T> targetClass){
		if(value == null){
			return null;
		}
		try{
			if(Integer.class == targetClass){
				return (T)Integer.valueOf(value);
			}
			else if(Float.class == targetClass){
				return (T)Float.valueOf(value);
			}
			else if(Double.class == targetClass){
				return (T)Double.valueOf(value);
			}
			else if(Byte.class == targetClass){
				return (T)Byte.valueOf(value);
			}
			else if(Short.class == targetClass){
				return (T)Short.valueOf(value);
			}
			else if(Long.class == targetClass){
				return (T)Long.valueOf(value);
			}
			else{
				return null;
			}
		}
		catch(NumberFormatException e){}
		return null;
	}
419116
@Override
    public GeldbetragFactory setNumber(Number number) {
        this.number = number;
        this.context = getMonetaryContextOf(number);
        return this;
    }
1021034
static <T> List<T> toList(final Class<T> targetClass, final Cursor cursor, final int columnIndex, int offset, int count) {
        if (columnIndex < 0 || columnIndex >= cursor.getColumnCount()) {
            throw new IllegalArgumentException("Invalid column index: " + columnIndex);
        }

        if (offset > 0) {
            cursor.moveToPosition(offset - 1);
        }

        final List<T> resultList = new ArrayList<>();

        if (N.isEntity(targetClass)) {
            final Method propSetMethod = ClassUtil.getPropSetMethod(targetClass, cursor.getColumnName(columnIndex));
            final Type<T> selectColumnType = Type.valueOf(propSetMethod.getParameterTypes()[0]);

            while (count-- > 0 && cursor.moveToNext()) {
                T entity = N.newEntity(targetClass);
                ClassUtil.setPropValue(entity, propSetMethod, selectColumnType.get(cursor, columnIndex));
                resultList.add(entity);
            }

        } else {
            final Type<T> selectColumnType = Type.valueOf(targetClass);

            while (count-- > 0 && cursor.moveToNext()) {
                resultList.add(selectColumnType.get(cursor, columnIndex));
            }
        }

        return resultList;
    }