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


Java Amount.equals方法代码示例

本文整理汇总了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);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:28,代码来源:AmountUtils.java

示例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);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:40,代码来源:OffsetsConsistencyMaintenanceListener.java

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

示例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);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:6,代码来源:SPIFePlanIntegrationOperation.java


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