本文整理汇总了Java中org.jscience.physics.amount.Amount.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Amount.equals方法的具体用法?Java Amount.equals怎么用?Java Amount.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jscience.physics.amount.Amount
的用法示例。
在下文中一共展示了Amount.equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equals
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
/**
* This utility method will return true in the case where two things have the same dimension and are both zero, regardless of
* the unit of each amount.
*
* NOTE: does not currently work for non-zero based dimensions such
* as temperature, where zero Celsius and zero Kelvin are different.
*
* @param <Q>
* @param q1
* @param q2
* @return boolean
*/
public static <Q extends Quantity> boolean equals(Amount<Q> q1, Amount<Q> q2) {
if (q1 == null) {
return (q2 == null);
}
if (q1.isExact() && q2.isExact()) {
if (q1.getExactValue() == 0 && (q2.getExactValue() == 0)) {
Dimension q1dimension = q1.getUnit().getDimension();
Dimension q2dimension = q2.getUnit().getDimension();
return q1dimension.equals(q2dimension);
}
Amount q3 = q1.to(q2.getUnit());
return q3.approximates(q2);
}
return q1.equals(q2);
}
示例2: updateOffsetsFromTimes
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
public static void updateOffsetsFromTimes(EPlanChild child, EPlanElement parent) {
if (parent == null) {
return;
}
TemporalMember temporal = child.getMember(TemporalMember.class);
TemporalMember parentTemporal = parent.getMember(TemporalMember.class);
Date start = temporal.getStartTime();
Date end = temporal.getEndTime();
Date parentStart = parentTemporal.getStartTime();
Date parentEnd = parentTemporal.getEndTime();
Timepoint startOffsetTimepoint = temporal.getStartOffsetTimepoint();
Amount<Duration> startOffsetAmount = temporal.getStartOffsetAmount();
Timepoint endOffsetTimepoint = temporal.getEndOffsetTimepoint();
Amount<Duration> endOffsetAmount = temporal.getEndOffsetAmount();
Amount<Duration> newStartOffsetAmount = startOffsetAmount;
Amount<Duration> newEndOffsetAmount = endOffsetAmount;
switch (startOffsetTimepoint) {
case START:
newStartOffsetAmount = DateUtils.subtract(start, parentStart);
break;
case END:
newStartOffsetAmount = DateUtils.subtract(start, parentEnd);
break;
}
if (!newStartOffsetAmount.equals(startOffsetAmount)) {
temporal.setStartOffsetAmount(newStartOffsetAmount);
}
switch (endOffsetTimepoint) {
case START:
newEndOffsetAmount = DateUtils.subtract(end, parentStart);
break;
case END:
newEndOffsetAmount = DateUtils.subtract(end, parentEnd);
break;
}
if (!newEndOffsetAmount.equals(endOffsetAmount)) {
temporal.setEndOffsetAmount(newEndOffsetAmount);
}
}
示例3: getPinConstraints
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
private Set<PeriodicTemporalConstraint> getPinConstraints(ConstraintsMember facet) {
Set<PeriodicTemporalConstraint> result = new LinkedHashSet<PeriodicTemporalConstraint>();
for (PeriodicTemporalConstraint constraint : facet.getPeriodicTemporalConstraints()) {
Amount<Duration> earliest = constraint.getEarliest();
Amount<Duration> latest = constraint.getLatest();
if ((earliest != null) && earliest.equals(latest)) {
result.add(constraint);
}
}
return result;
}
示例4: durationsEqual
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
private boolean durationsEqual(Amount<Duration> a, Amount<Duration> b) {
if (a==null && b==null) return true;
if (a==null || b==null) return false;
return a.equals(b);
}