本文整理汇总了Java中java.time.Duration.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Duration.equals方法的具体用法?Java Duration.equals怎么用?Java Duration.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.Duration
的用法示例。
在下文中一共展示了Duration.equals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkRegularSpacing
import java.time.Duration; //导入方法依赖的package包/类
private Duration checkRegularSpacing() {
if (times.size() < 2) {
throw new TimeSeriesException("At least 2 rows are expected");
}
Duration spacing = null;
for (int i = 1; i < times.size(); i++) {
Duration duration = Duration.between(times.get(i - 1), times.get(i));
if (spacing == null) {
spacing = duration;
} else {
if (!duration.equals(spacing)) {
throw new TimeSeriesException("Time spacing has to be regular");
}
}
}
return spacing;
}
示例2: handle
import java.time.Duration; //导入方法依赖的package包/类
@Override
protected final void handle(DataMemoryMessage msg) {
Duration duration = ofSeconds(msg.getValue1())
.plusMinutes(msg.getValue2())
.plusHours(msg.getValue3());
// If the received duration is the same as before,
// don't send an update.
if (duration.equals(lastDuration))
return;
lastDuration = duration;
onDurationUpdated(duration);
}
示例3: coolFor
import java.time.Duration; //导入方法依赖的package包/类
/**
* Submit a new cooldown for an object.
*/
public void coolFor(Object object, Duration time) {
if(objects.containsKey(object)) {
throw new IllegalStateException(object + " already has an active cooldown");
}
if(!time.equals(Duration.ZERO)) {
objects.put(object, plus(match.getInstantNow(), time));
}
}
示例4: dominateAndFireEvents
import java.time.Duration; //导入方法依赖的package包/类
/**
* Do a cycle of domination on this ControlPoint for the given team over the given duration. The team can be null,
* which means no team is dominating the point, which can cause the state to change in some configurations.
*/
private void dominateAndFireEvents(@Nullable Competitor dominator, Duration duration) {
final Duration oldProgress = progress;
final Competitor oldCapturer = capturer;
final Competitor oldOwner = owner;
dominate(dominator, duration);
if(!Objects.equals(oldCapturer, capturer) || !oldProgress.equals(progress)) {
match.callEvent(new CapturingTimeChangeEvent(match, this));
match.callEvent(new GoalStatusChangeEvent(this));
}
if(!Objects.equals(oldCapturer, capturer)) {
match.callEvent(new CapturingTeamChangeEvent(match, this, oldCapturer, capturer));
}
if(!Objects.equals(oldOwner, owner)) {
match.callEvent(new ControllerChangeEvent(match, this, oldOwner, owner));
match.callEvent(new GoalCompleteEvent(this, owner != null, c -> c.equals(oldOwner), c -> c.equals(owner)));
ScoreMatchModule smm = this.getMatch().getMatchModule(ScoreMatchModule.class);
if (smm != null) {
if (oldOwner != null) smm.incrementScore(oldOwner, getDefinition().getPointsOwned() * -1);
if (owner != null) smm.incrementScore(owner, getDefinition().getPointsOwned());
}
}
}
示例5: handle
import java.time.Duration; //导入方法依赖的package包/类
@Override
protected final void handle(DataMemoryMessage msg) {
Duration duration = ofMillis(msg.getValue1() * 100)
.plusSeconds(intFromHighAndLow(msg.getValue3(), msg.getValue2()));
// If the received duration is the same as before,
// don't send an update.
if (duration.equals(lastClockCountDown))
return;
lastClockCountDown = duration;
onClockCountDownUpdated(duration);
}
示例6: normalize
import java.time.Duration; //导入方法依赖的package包/类
/**
* Converts given TimeSpan to normalized binary representation.
*
* @param value
* Input TimeSpan value.
* @return Normalized array of bytes.
*/
private static byte[] normalize(Duration value) {
if (value.equals(Duration.ZERO)) {
return ShardKey.EMPTY_ARRAY;
}
else {
return normalize(value.getSeconds());
}
}
示例7: daysRoundingUp
import java.time.Duration; //导入方法依赖的package包/类
public static long daysRoundingUp(Duration duration) {
final long days = duration.toDays();
return duration.equals(Duration.ofDays(days)) ? days : days + 1;
}
示例8: matches
import java.time.Duration; //导入方法依赖的package包/类
@Override
public boolean matches(Object argument) {
Duration duration = (Duration) argument;
return (duration.equals(expectedDuration));
}