private Long convertToLongIfNotNull(Double number) { if (number == null) { return null; } return number.longValue(); }
public Long toLong(Double self) { return self.longValue(); }
void add(EffortSum other) { Double otherValue = other.newEffort; if (otherValue != null) { add(otherValue.longValue()); } } }
/** * The value of this measure as a long if the type is {@link Measure.ValueType#LONG}. * * @throws IllegalStateException if the value type of the measure is not {@link Measure.ValueType#LONG} */ public long getLongValue() { checkValueType(ValueType.LONG); return value.longValue(); }
@Deprecated public final long getElapsedTimeMillis() { Double v = getTimeTakenMillisIfKnown(); return v == null ? UNKNOWN : v.longValue(); }
protected Timestamp convertNumberToTimestamp( Double d ) { if ( d == null ) { return null; } long nanos = d.longValue(); return convertIntegerToTimestamp( nanos ); }
protected InetAddress convertNumberToInternetAddress( Double d ) throws KettleValueException { if ( d == null ) { return null; } long nanos = d.longValue(); return convertIntegerToInternetAddress( nanos ); }
public long evaluate(String xml, String path) { return xpath.evalNumber(xml, path).longValue(); } }
@Override public long getLongValue(int dictId) { return ((Double) get(dictId)).longValue(); }
public static Function<Number, DateTime> createNumericTimestampParser( final String format ) { if ("posix".equalsIgnoreCase(format)) { return input -> DateTimes.utc(TimeUnit.SECONDS.toMillis(input.longValue())); } else if ("micro".equalsIgnoreCase(format)) { return input -> DateTimes.utc(TimeUnit.MICROSECONDS.toMillis(input.longValue())); } else if ("nano".equalsIgnoreCase(format)) { return input -> DateTimes.utc(TimeUnit.NANOSECONDS.toMillis(input.longValue())); } else if ("ruby".equalsIgnoreCase(format)) { return input -> DateTimes.utc(Double.valueOf(input.doubleValue() * 1000).longValue()); } else { return input -> DateTimes.utc(input.longValue()); } }
@Override public void run() { if (jarNumbers > 0) { String info = getInfo(currentLine); String sizeWithUnit = byteCountToDisplaySize(new Double(sizeInKb * 1000).longValue()); String status = String.format("%d jar%s, %s downloaded at %s %s", jarNumbers, getPluralFormWhenNumberOfJarGreaterThanOne(), sizeWithUnit, speed, info); widget.setValue(status + "</br>" + formatCurrentLine()); widget.setDomClasses(asList("text-ellipsis")); } } }, 0, PERIOD);
private static Optional<Measure> toLongMeasure(LiveMeasureDto measureDto, @Nullable Double value, @Nullable String data) { if (value == null) { return toNoValueMeasure(measureDto); } return of(setCommonProperties(Measure.newMeasureBuilder(), measureDto).create(value.longValue(), data)); }
protected long limitInMb() { ServerConfig serverConfig = goConfigService.serverConfig(); return serverConfig.isArtifactPurgingAllowed() ? new Double(serverConfig.getPurgeStart() * GoConstants.MEGABYTES_IN_GIGABYTE).longValue() : Integer.MAX_VALUE; }
private static Optional<Measure> toLongMeasure(MeasureDto measureDto, @Nullable Double value, String data) { if (value == null) { return toNoValueMeasure(measureDto); } return of(setCommonProperties(Measure.newMeasureBuilder(), measureDto).create(value.longValue(), data)); }
private void addEffortToMaintainabilityRatingAMeasure(Component component, Path<Counter> path) { long developmentCostValue = path.current().devCosts; Optional<Measure> effortMeasure = measureRepository.getRawMeasure(component, maintainabilityRemediationEffortMetric); long effort = effortMeasure.isPresent() ? effortMeasure.get().getLongValue() : 0L; long upperGradeCost = ((Double) (ratingSettings.getDebtRatingGrid().getGradeLowerBound(Rating.B) * developmentCostValue)).longValue(); long effortToRatingA = upperGradeCost < effort ? (effort - upperGradeCost) : 0L; measureRepository.add(component, effortToMaintainabilityRatingAMetric, Measure.newMeasureBuilder().create(effortToRatingA)); }
@Test public void canDoubleToLong() { Double value = 11204.0345612345D; when(item.getValue()).thenReturn(value); when(item.getType()).thenReturn("D"); when(instruction.getOpcode()).thenReturn(Opcode.DOUBLE_TO_LONG); op = (UnaryMathOp) opFactory.create(location, addressToLocation, vm); op.execute(node, mState); verify(mState, times(1)).assignRegister(eq(REGISTER_A), eq(new HeapItem(value.longValue(), "J"))); }
@Test public void testDoubleLastCombiningBufferAggregator() { BufferAggregator agg = combiningAggFactory.factorizeBuffered( colSelectorFactory); ByteBuffer buffer = ByteBuffer.wrap(new byte[doubleLastAggFactory.getMaxIntermediateSizeWithNulls()]); agg.init(buffer, 0); aggregate(agg, buffer, 0); aggregate(agg, buffer, 0); aggregate(agg, buffer, 0); aggregate(agg, buffer, 0); Pair<Long, Double> result = (Pair<Long, Double>) agg.get(buffer, 0); Pair<Long, Double> expected = (Pair<Long, Double>) pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs, 0.0001); Assert.assertEquals(expected.rhs.longValue(), agg.getLong(buffer, 0)); Assert.assertEquals(expected.rhs, agg.getDouble(buffer, 0), 0.0001); }
@Test public void testDoubleFirstCombiningBufferAggregator() { BufferAggregator agg = combiningAggFactory.factorizeBuffered( colSelectorFactory); ByteBuffer buffer = ByteBuffer.wrap(new byte[doubleFirstAggFactory.getMaxIntermediateSizeWithNulls()]); agg.init(buffer, 0); aggregate(agg, buffer, 0); aggregate(agg, buffer, 0); aggregate(agg, buffer, 0); aggregate(agg, buffer, 0); Pair<Long, Double> result = (Pair<Long, Double>) agg.get(buffer, 0); Pair<Long, Double> expected = (Pair<Long, Double>) pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs, 0.0001); Assert.assertEquals(expected.rhs.longValue(), agg.getLong(buffer, 0)); Assert.assertEquals(expected.rhs, agg.getDouble(buffer, 0), 0.0001); }
@Test public void testDoubleFirstCombiningAggregator() { Aggregator agg = combiningAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Double> result = (Pair<Long, Double>) agg.get(); Pair<Long, Double> expected = (Pair<Long, Double>) pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs, 0.0001); Assert.assertEquals(expected.rhs.longValue(), agg.getLong()); Assert.assertEquals(expected.rhs, agg.getDouble(), 0.0001); }
@Test public void testDoubleLastCombiningAggregator() { Aggregator agg = combiningAggFactory.factorize(colSelectorFactory); aggregate(agg); aggregate(agg); aggregate(agg); aggregate(agg); Pair<Long, Double> result = (Pair<Long, Double>) agg.get(); Pair<Long, Double> expected = (Pair<Long, Double>) pairs[2]; Assert.assertEquals(expected.lhs, result.lhs); Assert.assertEquals(expected.rhs, result.rhs, 0.0001); Assert.assertEquals(expected.rhs.longValue(), agg.getLong()); Assert.assertEquals(expected.rhs, agg.getDouble(), 0.0001); }