use of com.google.api.ads.admanager.jaxws.v202205.NumberValue in project osate2 by osate.
the class UnitLiteralImpl method basicSetFactor.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetFactor(NumberValue newFactor, NotificationChain msgs) {
NumberValue oldFactor = factor;
factor = newFactor;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Aadl2Package.UNIT_LITERAL__FACTOR, oldFactor, newFactor);
if (msgs == null) {
msgs = notification;
} else {
msgs.add(notification);
}
}
return msgs;
}
use of com.google.api.ads.admanager.jaxws.v202205.NumberValue in project osate2 by osate.
the class GetProperties method getMinDataRate.
public static double getMinDataRate(RecordValue rate) {
BasicPropertyAssociation vr = GetProperties.getRecordField(rate.getOwnedFieldValues(), "Value_Range");
if (vr == null) {
return 0;
}
RangeValue rv = (RangeValue) vr.getOwnedValue();
PropertyExpression minimum = rv.getMinimum().evaluate(null, 0).first().getValue();
return ((NumberValue) minimum).getScaledValue();
}
use of com.google.api.ads.admanager.jaxws.v202205.NumberValue in project osate2 by osate.
the class PropertyUtils method getScaledRangeMaximum.
/**
* Return the maximum value of a non-modal range property value scaled to a
* given unit. Returns a given default value if no property value exists.
* Throws an exception if an error occurs.
*
* @param ph The property holder from which to retrieve the property value.
* @param pd The property to retrieve.
* @param unit The unit to scale the value to.
* @param defaultVal The value to return if the property has no value.
* @return The maximum of the range value scaled to the given unit.
*/
public static double getScaledRangeMaximum(final NamedElement ne, final Property pd, final UnitLiteral unit, final double defaultVal) {
try {
final PropertyExpression pv = checkUnitsAndGetSimplePropertyValue(ne, pd, unit);
final RangeValue rv = (RangeValue) pv;
PropertyExpression maximum = rv.getMaximum().evaluate(null, 0).first().getValue();
if (maximum instanceof NumberValue) {
return ((NumberValue) maximum).getScaledValue(unit);
} else {
return defaultVal;
}
} catch (PropertyLookupException e) {
return defaultVal;
}
}
Aggregations