/*
(non-Javadoc)
@see javax.money.NumberValue#getNumberValue(java.lang.Class)
322805
@Override
    public <T extends Number> T numberValue(Class<T> numberType) {
        return ConvertNumberValue.of(numberType, number);
    }
605001
@Override
    public String getValue() {
        switch (getSelectedIndex()) {
        case 0:
            if (internVal == null) return null;
            internVal = getValue1();
            return internVal;
        case 1:
            internVal = getValue2();
            return internVal;
        default:
            return null;
        }
    }
586842
public Integer getInt(String name) {
        Object o = get(name);
        if (o instanceof Number) {
            return ((Number)o).intValue();
        }

        if (o != null) {
            try {
                String string = o.toString();
                if (string != null) {
                    return Integer.parseInt(string);
                }
            }
            catch (NumberFormatException e) {}
        }
        return null;
    }
342606
public Number getNumber(String key) throws JSONException {
        Object object = this.get(key);
        try {
            if (object instanceof Number) {
                return (Number)object;
            }
            return stringToNumber(object.toString());
        } catch (Exception e) {
            throw new JSONException("JSONObject[" + quote(key)
                    + "] is not a number.", e);
        }
    }
1226343
@Override
    public Number getNumber(@NonNull String key) {
        if (key == null) { throw new IllegalArgumentException("key cannot be null."); }

        final int index = indexForColumnName(key);
        return index >= 0 ? getNumber(index) : null;
    }
1311134
@Override
    public int intValue() {
	if (Math.abs(amount) <= Integer.MAX_VALUE) {
	    return (int) amount;
	}
	throw new IllegalStateException("Amount of '" + amount + "' cannot be converted into an Integer.");
    }
1058108
public static int getInt(JSONValue value) {
        if (value == null)
            return 0;
        if (!(value instanceof Number))
            throw new JSONException(NOT_A_NUMBER);
        return ((Number)value).intValue();
    }
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;
	}
380077
public java.lang.String getValue() {
    java.lang.Object ref = value_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      if (bs.isValidUtf8()) {
        value_ = s;
      }
      return s;
    }
  }
622638
public Object getValueByPosition(Integer position) throws NoSuchFieldException {
        String name = null;
        Object value = null;

        name = this.getNameByPosition(position);

        if (name != null) {
            value = this.getValue(name);
        } else {
            throw new NoSuchFieldException();
        }

        return value;
    }
1179479
@Override
    public Integer getValue(T context) {

        CalendarSystem<T> calsys = this.getCalendarSystem(context);
        T start = context.with(this.dayOfYear, 1);
        return toGregorianYear(calsys.transform(start));

    }
82692
@Override
    public MonetaryAmountFactory<T> setNumber(Number number) {
        this.number = ConvertBigDecimal.of(number);
        return this;
    }
1022086
public int getInt( String key ) {
      verifyIsNull();
      Object o = get( key );
      if( o != null ){
         return o instanceof Number ? ((Number) o).intValue() : (int) getDouble( key );
      }
      throw new JSONException( "JSONObject[" + JSONUtils.quote( key ) + "] is not a number." );
   }
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();
  }
103128
@Override
	public Long getValue() {
		final JobStatus status = eg.getState();

		if (status == JobStatus.RUNNING) {
			// running right now - report the uptime
			final long runningTimestamp = eg.getStatusTimestamp(JobStatus.RUNNING);
			// we use 'Math.max' here to avoid negative timestamps when clocks change
			return Math.max(System.currentTimeMillis() - runningTimestamp, 0);
		}
		else if (status.isTerminalState()) {
			// not running any more -> finished or not on leader
			return NO_LONGER_RUNNING;
		}
		else {
			// not yet running or not up at the moment
			return 0L;
		}
	}
1207938
@Override
    public NumberType getNumberType() throws IOException, JsonParseException {
    	ConfigValue n = currentNumericNode();
    	if(n == null)
    		return null;
    	
    	Number value = (Number) n.unwrapped();
    	if(value instanceof Double) {
    		return NumberType.DOUBLE;
    	} else if(value instanceof Long) {
    		return NumberType.LONG;
    	} else {
    		return NumberType.INT;
    	}
    }
543945
private static void ensureNumber(Object value) throws ExecutionException {

        if (!isNumber(value)) {
            String message = value.getClass().getCanonicalName() + " can not cast to a Number.";
            LOGGER.error(message);
            throw new ExecutionException(message);
        }
    }