use of com.google.api.ads.admanager.jaxws.v202205.NumberValue in project googleads-java-lib by googleads.
the class PqlTest method testCreateValue_numberSet.
@Test
public void testCreateValue_numberSet() {
Set<Long> numberSet = new LinkedHashSet<Long>();
numberSet.add(1L);
Value value1 = ((SetValue) Pql.createValue(numberSet)).getValues(0);
assertEquals("1", ((NumberValue) value1).getValue());
}
use of com.google.api.ads.admanager.jaxws.v202205.NumberValue in project osate-plugin by sireum.
the class Visitor method getPropertyExpressionValue.
protected List<org.sireum.hamr.ir.PropertyValue> getPropertyExpressionValue(PropertyExpression pe, List<String> path) {
if (pe instanceof BooleanLiteral) {
final String b = Boolean.toString(((BooleanLiteral) pe).getValue());
return VisitorUtil.toIList(factory.valueProp(b));
} else if (pe instanceof NumberValue) {
return VisitorUtil.toIList(getUnitProp((NumberValue) pe));
} else if (pe instanceof StringLiteral) {
final String v = ((StringLiteral) pe).getValue();
return VisitorUtil.toIList(factory.valueProp(v));
} else if (pe instanceof RangeValue) {
final RangeValue rv = (RangeValue) pe;
return VisitorUtil.toIList(factory.rangeProp(getUnitProp(rv.getMinimumValue()), getUnitProp(rv.getMaximumValue())));
} else if (pe instanceof ClassifierValue) {
final Classifier cv = ((ClassifierValue) pe).getClassifier();
if (cv instanceof DataClassifier) {
processDataType((DataClassifier) cv);
}
if (cv.getQualifiedName() != null) {
return VisitorUtil.toIList(factory.classifierProp(cv.getQualifiedName()));
} else {
return VisitorUtil.iList();
}
// return VisitorUtil.toIList(factory.classifierProp(cv.getQualifiedName()));
} else if (pe instanceof ListValue) {
final ListValue lv = (ListValue) pe;
List<org.sireum.hamr.ir.PropertyValue> elems = VisitorUtil.iList();
for (PropertyExpression e : lv.getOwnedListElements()) {
elems = VisitorUtil.addAll(elems, getPropertyExpressionValue(e, path));
}
return elems;
} else if (pe instanceof NamedValue) {
final NamedValue nv = (NamedValue) pe;
final AbstractNamedValue nv2 = nv.getNamedValue();
if (nv2 instanceof EnumerationLiteral) {
final EnumerationLiteral el = (EnumerationLiteral) nv2;
return VisitorUtil.toIList(factory.valueProp(el.getFullName()));
} else if (nv2 instanceof Property) {
final Property _p = (Property) nv2;
if (_p.getDefaultValue() != null) {
return getPropertyExpressionValue(_p.getDefaultValue(), path);
} else {
return VisitorUtil.toIList(factory.valueProp(_p.getQualifiedName()));
}
} else if (nv2 instanceof PropertyConstant) {
final PropertyConstant pc = (PropertyConstant) nv2;
return getPropertyExpressionValue(pc.getConstantValue(), path);
} else {
java.lang.System.err.println("Not handling " + pe.eClass().getClassifierID() + " " + nv2);
return VisitorUtil.iList();
}
} else if (pe instanceof RecordValue) {
final RecordValue rvy = (RecordValue) pe;
final List<org.sireum.hamr.ir.Property> properties = rvy.getOwnedFieldValues().stream().map(fv -> factory.property(factory.name(VisitorUtil.add(path, fv.getProperty().getQualifiedName()), VisitorUtil.buildPosInfo(fv.getProperty())), getPropertyExpressionValue(fv.getOwnedValue(), path), VisitorUtil.iList())).collect(Collectors.toList());
return VisitorUtil.toIList(factory.recordProp(properties));
} else if (pe instanceof ReferenceValue) {
final ReferenceValue rvx = (ReferenceValue) pe;
final org.sireum.hamr.ir.Name refName = factory.name(VisitorUtil.toIList(rvx.toString()), VisitorUtil.buildPosInfo(rvx.getPath().getNamedElement()));
return VisitorUtil.toIList(factory.referenceProp(refName));
} else if (pe instanceof InstanceReferenceValue) {
final InstanceReferenceValue irv = (InstanceReferenceValue) pe;
final String t = irv.getReferencedInstanceObject().getInstanceObjectPath();
return VisitorUtil.toIList(factory.referenceProp(factory.name(Arrays.asList(t.split("\\.")), VisitorUtil.buildPosInfo(irv.getReferencedInstanceObject()))));
} else {
java.lang.System.err.println("Need to handle " + pe + " " + pe.eClass().getClassifierID());
if (pe.getClass().getName() != null) {
return VisitorUtil.toIList(factory.classifierProp(pe.getClass().getName()));
} else {
return VisitorUtil.iList();
}
}
}
use of com.google.api.ads.admanager.jaxws.v202205.NumberValue in project googleads-java-lib by googleads.
the class PqlTest method setUp.
@Before
public void setUp() throws Exception {
column1 = new ColumnType();
column1.setLabelName("column1");
column2 = new ColumnType();
column2.setLabelName("column2");
column3 = new ColumnType();
column3.setLabelName("column3");
textValue1 = new TextValue();
textValue1.setValue("value1");
textValue2 = new TextValue();
textValue2.setValue("value2");
textValue3 = new TextValue();
textValue3.setValue("value3");
textValue4 = new TextValue();
textValue4.setValue("comma,separated");
booleanValue1 = new BooleanValue();
booleanValue1.setValue(false);
booleanValue2 = new BooleanValue();
booleanValue2.setValue(true);
booleanValue3 = new BooleanValue();
booleanValue3.setValue(false);
numberValue1 = new NumberValue();
numberValue1.setValue("1");
numberValue2 = new NumberValue();
numberValue2.setValue("1.02");
numberValue3 = new NumberValue();
numberValue3.setValue("-1");
numberValue4 = new NumberValue();
numberValue4.setValue("");
numberValue5 = new NumberValue();
numberValue5.setValue(null);
dateTime1 = new DateTime();
date1 = new Date();
date1.setYear(2012);
date1.setMonth(12);
date1.setDay(2);
dateTime1.setDate(date1);
dateTime1.setHour(12);
dateTime1.setMinute(45);
dateTime1.setSecond(0);
dateTime1.setTimeZoneId(TIME_ZONE_ID1);
dateTimeValue1 = new DateTimeValue();
dateTimeValue1.setValue(dateTime1);
dateValue1 = new DateValue();
dateValue1.setValue(date1);
AdUnitTargeting adUnitTargeting = new AdUnitTargeting();
adUnitTargeting.setAdUnitId("100");
InventoryTargeting inventoryTargeting = new InventoryTargeting();
inventoryTargeting.setTargetedAdUnits(new AdUnitTargeting[] { adUnitTargeting });
targeting1 = new Targeting();
targeting1.setInventoryTargeting(inventoryTargeting);
targetingValue1 = new TargetingValue();
targetingValue1.setValue(targeting1);
numberSetValue = new SetValue();
numberSetValue.setValues(new Value[] { numberValue1, numberValue3 });
textSetValue = new SetValue();
textSetValue.setValues(new Value[] { textValue1, textValue2 });
dateSetValue = new SetValue();
dateSetValue.setValues(new Value[] { dateValue1 });
dateTimeSetValue = new SetValue();
dateTimeSetValue.setValues(new Value[] { dateTimeValue1 });
mixedSetValue = new SetValue();
mixedSetValue.setValues(new Value[] { textValue1, dateTimeValue1 });
commaTextSetValue = new SetValue();
commaTextSetValue.setValues(new Value[] { textValue1, textValue4 });
}
use of com.google.api.ads.admanager.jaxws.v202205.NumberValue in project googleads-java-lib by googleads.
the class PqlTest method testCreateValue_numberSet.
@Test
public void testCreateValue_numberSet() {
Set<Long> numberSet = new LinkedHashSet<Long>();
numberSet.add(1L);
Value value1 = ((SetValue) Pql.createValue(numberSet)).getValues().get(0);
assertEquals("1", ((NumberValue) value1).getValue());
}
use of com.google.api.ads.admanager.jaxws.v202205.NumberValue in project googleads-java-lib by googleads.
the class PqlTest method setUp.
@Before
public void setUp() throws Exception {
column1 = new ColumnType();
column1.setLabelName("column1");
column2 = new ColumnType();
column2.setLabelName("column2");
column3 = new ColumnType();
column3.setLabelName("column3");
textValue1 = new TextValue();
textValue1.setValue("value1");
textValue2 = new TextValue();
textValue2.setValue("value2");
textValue3 = new TextValue();
textValue3.setValue("value3");
textValue4 = new TextValue();
textValue4.setValue("comma,separated");
booleanValue1 = new BooleanValue();
booleanValue1.setValue(false);
booleanValue2 = new BooleanValue();
booleanValue2.setValue(true);
booleanValue3 = new BooleanValue();
booleanValue3.setValue(false);
numberValue1 = new NumberValue();
numberValue1.setValue("1");
numberValue2 = new NumberValue();
numberValue2.setValue("1.02");
numberValue3 = new NumberValue();
numberValue3.setValue("-1");
dateTime1 = new DateTime();
date1 = new Date();
date1.setYear(2012);
date1.setMonth(12);
date1.setDay(2);
dateTime1.setDate(date1);
dateTime1.setHour(12);
dateTime1.setMinute(45);
dateTime1.setSecond(0);
dateTime1.setTimeZoneId(TIME_ZONE_ID1);
dateTimeValue1 = new DateTimeValue();
dateTimeValue1.setValue(dateTime1);
dateValue1 = new DateValue();
dateValue1.setValue(date1);
AdUnitTargeting adUnitTargeting = new AdUnitTargeting();
adUnitTargeting.setAdUnitId("100");
InventoryTargeting inventoryTargeting = new InventoryTargeting();
inventoryTargeting.getTargetedAdUnits().add(adUnitTargeting);
targeting1 = new Targeting();
targeting1.setInventoryTargeting(inventoryTargeting);
targetingValue1 = new TargetingValue();
targetingValue1.setValue(targeting1);
numberSetValue = new SetValue();
numberSetValue.getValues().add(numberValue1);
numberSetValue.getValues().add(numberValue3);
textSetValue = new SetValue();
textSetValue.getValues().add(textValue1);
textSetValue.getValues().add(textValue2);
dateSetValue = new SetValue();
dateSetValue.getValues().add(dateValue1);
dateTimeSetValue = new SetValue();
dateTimeSetValue.getValues().add(dateTimeValue1);
mixedSetValue = new SetValue();
mixedSetValue.getValues().add(textValue1);
mixedSetValue.getValues().add(dateTimeValue1);
commaTextSetValue = new SetValue();
commaTextSetValue.getValues().add(textValue1);
commaTextSetValue.getValues().add(textValue4);
}
Aggregations