当前位置: 首页>>代码示例>>Java>>正文


Java Duration.equals方法代码示例

本文整理汇总了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;
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:20,代码来源:TimeSeries.java

示例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);
}
 
开发者ID:tbressler,项目名称:waterrower-core,代码行数:17,代码来源:DisplayedDurationSubscription.java

示例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));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:12,代码来源:CooldownPlayerFacet.java

示例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());
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:32,代码来源:ControlPoint.java

示例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);
}
 
开发者ID:tbressler,项目名称:waterrower-core,代码行数:16,代码来源:ClockCountDownSubscription.java

示例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());
    }
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:16,代码来源:ShardKey.java

示例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;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:5,代码来源:TimeUtils.java

示例8: matches

import java.time.Duration; //导入方法依赖的package包/类
@Override
public boolean matches(Object argument) {
    Duration duration = (Duration) argument;
    return (duration.equals(expectedDuration));
}
 
开发者ID:tbressler,项目名称:waterrower-core,代码行数:6,代码来源:TestClockCountDownSubscription.java


注:本文中的java.time.Duration.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。