@Override protected Optional<Literal> createTypedLiteral(ValueFactory vf, BigInteger integerValue) throws ArithmeticException { return Optional.of(vf.createLiteral(integerValue.shortValueExact())); } }
@Override protected Optional<Literal> createTypedLiteral(ValueFactory vf, BigInteger integerValue) throws ArithmeticException { return Optional.of(vf.createLiteral(integerValue.shortValueExact())); } }
@Override protected Optional<Literal> createTypedLiteral(ValueFactory vf, BigInteger integerValue) throws ArithmeticException { if (integerValue.compareTo(BigInteger.ZERO) >= 0) { return Optional.of(vf.createLiteral(String.valueOf(integerValue.shortValueExact()), getXsdDatatype())); } return Optional.empty(); }
@Override protected Optional<Literal> createTypedLiteral(ValueFactory vf, BigInteger integerValue) throws ArithmeticException { if (integerValue.compareTo(BigInteger.ZERO) >= 0) { return Optional.of(vf.createLiteral(String.valueOf(integerValue.shortValueExact()), getXsdDatatype())); } return Optional.empty(); }
@AtlasConversionInfo(sourceType = FieldType.DECIMAL, targetType = FieldType.SHORT, concerns = {AtlasConversionConcern.RANGE, AtlasConversionConcern.FRACTIONAL_PART}) public Short toShort(BigDecimal value) throws AtlasConversionException { if (value == null) { return null; } try { return value.toBigInteger().shortValueExact(); } catch (ArithmeticException e) { throw new AtlasConversionException( String.format("BigDecimal %s is greater than Short.MAX_VALUE or less than Short.MIN_VALUE", value)); } }
@Override public Object parseValue(Object input) { if (input instanceof Number || input instanceof String) { try { return new ShortNode(new BigInteger(input.toString()).shortValueExact()); } catch (ArithmeticException e) { throw new CoercingParseValueException(input + " does not fit into a short without a loss of precision"); } } if (input instanceof ShortNode) { return input; } throw valueParsingException(input, Number.class, String.class, ShortNode.class); }
@AtlasConversionInfo(sourceType = FieldType.BIG_INTEGER, targetType = FieldType.SHORT, concerns = AtlasConversionConcern.RANGE) public Short toShort(BigInteger value) throws AtlasConversionException { if (value == null) { return null; } try { return value.shortValueExact(); } catch (ArithmeticException e) { throw new AtlasConversionException( String.format("BigInteger %s is greater than Short.MAX_VALUE or less than Short.MIN_VALUE", value)); } }
return Byte.valueOf(value.byteValueExact()); if (short.class.equals(type) || Short.class.equals(type)) return Short.valueOf(value.shortValueExact()); if (int.class.equals(type) || Integer.class.equals(type)) return Integer.valueOf(value.intValueExact());
return Short.valueOf(bigInt.shortValueExact()); }catch ( ArithmeticException e ){
@Override public Object parseLiteral(Object input) { if (input instanceof IntValue) { try { return new ShortNode(((IntValue) input).getValue().shortValueExact()); } catch (ArithmeticException e) { throw new CoercingParseLiteralException(input + " does not fit into a short without a loss of precision"); } } else { throw new CoercingParseLiteralException(errorMessage(input, IntValue.class)); } } });