use of com.google.api.ads.adwords.jaxws.v201809.cm.Predicate in project googleads-java-lib by googleads.
the class SelectorBuilderImpl method singleValuePredicate.
/**
* Adds a predicate for the specified field, property value, and operator.
*/
private SelectorBuilderImpl singleValuePredicate(String field, String propertyValue, PredicateOperator operator) {
Predicate predicate = new Predicate();
predicate.setField(field);
predicate.setOperator(operator);
String[] values = new String[1];
values[0] = propertyValue;
predicate.setValues(values);
this.predicates.add(predicate);
return this;
}
use of com.google.api.ads.adwords.jaxws.v201809.cm.Predicate in project googleads-java-lib by googleads.
the class SelectorBuilderTest method testUniqueInternalPredicateState.
/**
* Tests that the built selectors don't share internal Predicate state.
*/
@Test
public void testUniqueInternalPredicateState() {
SelectorBuilder builder = new SelectorBuilder();
Selector selectorOne = builder.equals("Id", "test").build();
Selector selectorTwo = builder.build();
Predicate predicateTwo = selectorTwo.getPredicates().get(0);
predicateTwo.setField("Status");
assertEquals("Id", selectorOne.getPredicates().get(0).getField());
assertEquals("Status", selectorTwo.getPredicates().get(0).getField());
checkUtilitiesState(false);
}
use of com.google.api.ads.adwords.jaxws.v201809.cm.Predicate in project googleads-java-lib by googleads.
the class SelectorBuilderTest method testPredicatesInBuild.
/**
* Tests the predicate with the IN clause.
*/
@Test
public void testPredicatesInBuild() {
SelectorBuilder builder = new SelectorBuilder();
builder = builder.in("Status", CampaignStatus.ENABLED.toString(), CampaignStatus.REMOVED.toString());
Selector selector = builder.build();
assertNotNull(selector.getPredicates());
assertEquals(1, selector.getPredicates().size());
Predicate predicate = selector.getPredicates().get(0);
assertEquals("Status", predicate.getField());
assertEquals(PredicateOperator.IN, predicate.getOperator());
assertNotNull(predicate.getValues());
assertEquals(2, predicate.getValues().size());
assertEquals(CampaignStatus.ENABLED.toString(), predicate.getValues().get(0));
assertEquals(CampaignStatus.REMOVED.toString(), predicate.getValues().get(1));
checkUtilitiesState(false);
}
use of com.google.api.ads.adwords.jaxws.v201809.cm.Predicate in project googleads-java-lib by googleads.
the class SelectorBuilderImpl method copyPredicatesSet.
/**
* Copies the whole set of predicates, by creating new instances of each one in the given set.
*
* @return the new set of Predicate objects with different instance for each of the Predicate
*/
private Set<Predicate> copyPredicatesSet() {
Set<Predicate> predicatesCopy = Sets.newLinkedHashSet();
for (Predicate predicate : this.predicates) {
Predicate copyPredicate = new Predicate();
copyPredicate.setField(predicate.getField());
copyPredicate.setOperator(predicate.getOperator());
copyPredicate.getValues().addAll(predicate.getValues());
predicatesCopy.add(copyPredicate);
}
return predicatesCopy;
}
use of com.google.api.ads.adwords.jaxws.v201809.cm.Predicate in project googleads-java-lib by googleads.
the class SelectorBuilderImpl method multipleValuePredicate.
/**
* Adds a predicate for the specified field, property values, and operator.
*/
private SelectorBuilderImpl multipleValuePredicate(String field, String[] propertyValues, PredicateOperator operator) {
if (propertyValues == null) {
return this;
}
Predicate predicate = new Predicate();
predicate.setOperator(operator);
predicate.setField(field);
for (String propertyValue : propertyValues) {
predicate.getValues().add(propertyValue);
}
this.predicates.add(predicate);
return this;
}
Aggregations