private Boss(int id, long period, ChronoUnit unit, int itemSpriteId) { this.id = id; this.spawnTime = Duration.of(period, unit); this.itemSpriteId = itemSpriteId; }
GameTimer(int imageId, GameTimerImageType idType, String description, Integer graphicId, long time, ChronoUnit unit, long delay, boolean removedOnDeath) { this.description = description; this.graphicId = graphicId; this.duration = Duration.of(time, unit); this.imageId = imageId; this.imageType = idType; this.removedOnDeath = removedOnDeath; this.initialDelay = Duration.of(delay, unit); }
public Timer(long period, ChronoUnit unit, BufferedImage image, Plugin plugin) { super(image, plugin); Preconditions.checkArgument(period > 0, "negative period!"); startTime = Instant.now(); duration = Duration.of(period, unit); endTime = startTime.plus(duration); }
/** * Set the index information polling interval. {@link #call()} waits * at least this long between repeated attempts to read schema information * and determine whether the index has reached its target state. */ public S pollInterval(long poll, TemporalUnit pollUnit) { Preconditions.checkArgument(0 <= poll); this.poll = Duration.of(poll, pollUnit); return self(); }
public static final int getTTLSeconds(long time, TemporalUnit unit) { return getTTLSeconds(Duration.of(time,unit)); }
/** * Set the index information polling interval. {@link #call()} waits * at least this long between repeated attempts to read schema information * and determine whether the index has reached its target state. */ public S pollInterval(long poll, TemporalUnit pollUnit) { Preconditions.checkArgument(0 <= poll); this.poll = Duration.of(poll, pollUnit); return self(); } }
/** * * Gets the duration value associated with the given key. * * @param field the field * @param unit the temporal unit of the duration value * @return the duration value associated with the given key */ default Duration getDuration(Field field, TemporalUnit unit) { return Duration.of(getLong(field), unit); }
public static int getTTLSeconds(long time, TemporalUnit unit) { return getTTLSeconds(Duration.of(time,unit)); }
/** * Set the maximum amount of wallclock time that {@link #call()} will * wait for the index to reach the target status. If the index does * not reach the target state in this interval, then {@link #call()} * will return a report value indicating failure. * <p> * A negative {@code timeout} is interpreted to mean "wait forever" * (no timeout). In this case, the {@code timeoutUnit} is ignored. * * @param timeout the time duration scalar * @param timeoutUnit the time unit * @return this builder */ public S timeout(long timeout, TemporalUnit timeoutUnit) { if (0 > timeout) { this.timeout = null; } else { this.timeout = Duration.of(timeout, timeoutUnit); } return self(); }
@Test public void shouldRangeSeekInOrderAscendingDurationArray() throws Exception { Object o0 = new Duration[]{Duration.of( 0, ChronoUnit.SECONDS )}; Object o1 = new Duration[]{Duration.of( 1, ChronoUnit.SECONDS )}; Object o2 = new Duration[]{Duration.of( 2, ChronoUnit.SECONDS )}; Object o3 = new Duration[]{Duration.of( 3, ChronoUnit.SECONDS )}; Object o4 = new Duration[]{Duration.of( 4, ChronoUnit.SECONDS )}; Object o5 = new Duration[]{Duration.of( 5, ChronoUnit.SECONDS )}; shouldRangeSeekInOrder( IndexOrder.ASCENDING, o0, o1, o2, o3, o4, o5 ); }
@Test public void shouldRangeSeekInOrderAscendingDurationArray() throws Exception { Object o0 = new Duration[]{Duration.of( 0, ChronoUnit.SECONDS )}; Object o1 = new Duration[]{Duration.of( 1, ChronoUnit.SECONDS )}; Object o2 = new Duration[]{Duration.of( 2, ChronoUnit.SECONDS )}; Object o3 = new Duration[]{Duration.of( 3, ChronoUnit.SECONDS )}; Object o4 = new Duration[]{Duration.of( 4, ChronoUnit.SECONDS )}; Object o5 = new Duration[]{Duration.of( 5, ChronoUnit.SECONDS )}; shouldSeekInOrderExactWithRange( IndexOrder.ASCENDING, o0, o1, o2, o3, o4, o5 ); }
@Test public void shouldRangeSeekInOrderDescendingDurationArray() throws Exception { Object o0 = new Duration[]{Duration.of( 0, ChronoUnit.SECONDS )}; Object o1 = new Duration[]{Duration.of( 1, ChronoUnit.SECONDS )}; Object o2 = new Duration[]{Duration.of( 2, ChronoUnit.SECONDS )}; Object o3 = new Duration[]{Duration.of( 3, ChronoUnit.SECONDS )}; Object o4 = new Duration[]{Duration.of( 4, ChronoUnit.SECONDS )}; Object o5 = new Duration[]{Duration.of( 5, ChronoUnit.SECONDS )}; shouldSeekInOrderExactWithRange( IndexOrder.DESCENDING, o0, o1, o2, o3, o4, o5 ); }
@Test public void shouldRangeSeekInOrderDescendingDurationArray() throws Exception { Object o0 = new Duration[]{Duration.of( 0, ChronoUnit.SECONDS )}; Object o1 = new Duration[]{Duration.of( 1, ChronoUnit.SECONDS )}; Object o2 = new Duration[]{Duration.of( 2, ChronoUnit.SECONDS )}; Object o3 = new Duration[]{Duration.of( 3, ChronoUnit.SECONDS )}; Object o4 = new Duration[]{Duration.of( 4, ChronoUnit.SECONDS )}; Object o5 = new Duration[]{Duration.of( 5, ChronoUnit.SECONDS )}; shouldRangeSeekInOrder( IndexOrder.DESCENDING, o0, o1, o2, o3, o4, o5 ); }
static java.time.Duration parse(String value) { Objects.requireNonNull(value, "Null 'value' argument"); if (value.length() == 0) { throw new IllegalArgumentException("Empty 'value' argument"); } Matcher matcher = TOKENIZER.matcher(value); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid Duration format: " + value); } TemporalUnit unit = parseUnit(matcher.group(2)); long amount = parseAmount(matcher.group(1)); return java.time.Duration.of(amount, unit); }
private static TimeType convertToTimeType(Duration duration) { return Stream.of(java.util.concurrent.TimeUnit.values()) .sorted(comparing(unit -> unit.convert(duration.toNanos(), NANOSECONDS))) .filter(unit -> duration.equals(Duration.of(unit.convert(duration.toNanos(), NANOSECONDS), jucTimeUnitToTemporalUnit(unit)))) .findFirst() .map(unit -> new TimeType() .withValue(BigInteger.valueOf(unit.convert(duration.toNanos(), NANOSECONDS))) .withUnit(convertToXmlTimeUnit(unit)) ).orElseThrow(AssertionError::new); } }
public PostgreSQLContainer(final String dockerImageName) { super(dockerImageName); this.waitStrategy = new LogMessageWaitStrategy() .withRegEx(".*database system is ready to accept connections.*\\s") .withTimes(2) .withStartupTimeout(Duration.of(60, SECONDS)); }
private java.time.Duration convertDuration(Duration duration) { if (duration.isEternal()) { return org.ehcache.expiry.ExpiryPolicy.INFINITE; } return java.time.Duration.of(duration.getDurationAmount(), ExpiryUtils.jucTimeUnitToTemporalUnit(duration.getTimeUnit())); } }
/** */ public BrowserWebDriverContainer() { final WaitStrategy logWaitStrategy = new LogMessageWaitStrategy() .withRegEx(".*(RemoteWebDriver instances should connect to|Selenium Server is up and running).*\n") .withStartupTimeout(Duration.of(15, SECONDS)); this.waitStrategy = new WaitAllStrategy() .withStrategy(logWaitStrategy) .withStrategy(new HostPortWaitStrategy()) .withStartupTimeout(Duration.of(15, SECONDS)); this.withRecordingFileFactory(new DefaultRecordingFileFactory()); }
@Test public void shouldSerializeTemporalAsListOfMapsOfProperties() throws Exception { // given ByteArrayOutputStream output = new ByteArrayOutputStream(); ExecutionResultSerializer serializer = getSerializerWith( output ); Result executionResult = mockExecutionResult( map( "temporal", LocalDate.of( 2018, 3, 12 ) ), map( "temporal", ZonedDateTime.of( 2018, 3, 12, 13, 2, 10, 10, ZoneId.of( "UTC+1" ) ) ), map( "temporal", OffsetTime.of( 12, 2, 4, 71, ZoneOffset.UTC ) ), map( "temporal", LocalDateTime.of( 2018, 3, 12, 13, 2, 10, 10 ) ), map( "temporal", LocalTime.of( 13, 2, 10, 10 ) ), map( "temporal", Duration.of( 12, ChronoUnit.HOURS ) ) ); // when serializer.statementResult( executionResult, false ); serializer.finish(); // then String result = output.toString( UTF_8.name() ); assertEquals( "{\"results\":[{\"columns\":[\"temporal\"],\"data\":[" + "{\"row\":[\"2018-03-12\"],\"meta\":[{\"type\":\"date\"}]}," + "{\"row\":[\"2018-03-12T13:02:10.000000010+01:00[UTC+01:00]\"],\"meta\":[{\"type\":\"datetime\"}]}," + "{\"row\":[\"12:02:04.000000071Z\"],\"meta\":[{\"type\":\"time\"}]}," + "{\"row\":[\"2018-03-12T13:02:10.000000010\"],\"meta\":[{\"type\":\"localdatetime\"}]}," + "{\"row\":[\"13:02:10.000000010\"],\"meta\":[{\"type\":\"localtime\"}]}," + "{\"row\":[\"PT12H\"],\"meta\":[{\"type\":\"duration\"}]}" + "]}],\"errors\":[]}", result ); }