Search in sources :

Example 31 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime in project googleads-java-lib by googleads.

the class Pql method createValue.

/**
 * Creates a {@link Value} from the value i.e. a {@link TextValue} for a value of type {@code
 * String}, {@link BooleanValue} for type {@code Boolean}, {@link NumberValue} for type {@code
 * Double}, {@code Long}, or {@code Integer}, and {@link DateTimeValue} for type {@link DateTime}.
 * If the value is a {@code Value}, the value is returned. If the value is {@code null}, an empty
 * {@link TextValue} is returned.
 *
 * @param value the value to convert
 * @return the constructed value of the appropriate type
 * @throws IllegalArgumentException if value cannot be converted
 */
public static Value createValue(Object value) {
    if (value instanceof Value) {
        return (Value) value;
    } else if (value == null) {
        return new TextValue();
    } else {
        if (value instanceof Boolean) {
            BooleanValue booleanValue = new BooleanValue();
            booleanValue.setValue((Boolean) value);
            return booleanValue;
        } else if (value instanceof Double || value instanceof Long || value instanceof Integer) {
            NumberValue numberValue = new NumberValue();
            numberValue.setValue(value.toString());
            return numberValue;
        } else if (value instanceof String) {
            TextValue textValue = new TextValue();
            textValue.setValue((String) value);
            return textValue;
        } else if (value instanceof DateTime) {
            DateTimeValue dateTimeValue = new DateTimeValue();
            dateTimeValue.setValue((DateTime) value);
            return dateTimeValue;
        } else if (value instanceof Date) {
            DateValue dateValue = new DateValue();
            dateValue.setValue((Date) value);
            return dateValue;
        } else if (value instanceof Targeting) {
            TargetingValue targetingValue = new TargetingValue();
            targetingValue.setValue((Targeting) value);
            return targetingValue;
        } else if (value instanceof Set<?>) {
            SetValue setValue = new SetValue();
            Set<Value> values = new LinkedHashSet<Value>();
            for (Object entry : (Set<?>) value) {
                validateSetValueEntryForSet(createValue(entry), values);
                values.add(createValue(entry));
            }
            setValue.getValues().addAll(values);
            return setValue;
        } else {
            throw new IllegalArgumentException("Unsupported Value type [" + value.getClass() + "]");
        }
    }
}
Also used : Set(java.util.Set) ResultSet(com.google.api.ads.admanager.jaxws.v202111.ResultSet) LinkedHashSet(java.util.LinkedHashSet) DateTimeValue(com.google.api.ads.admanager.jaxws.v202111.DateTimeValue) Targeting(com.google.api.ads.admanager.jaxws.v202111.Targeting) DateTime(com.google.api.ads.admanager.jaxws.v202111.DateTime) Date(com.google.api.ads.admanager.jaxws.v202111.Date) NumberValue(com.google.api.ads.admanager.jaxws.v202111.NumberValue) TextValue(com.google.api.ads.admanager.jaxws.v202111.TextValue) DateValue(com.google.api.ads.admanager.jaxws.v202111.DateValue) BooleanValue(com.google.api.ads.admanager.jaxws.v202111.BooleanValue) DateTimeValue(com.google.api.ads.admanager.jaxws.v202111.DateTimeValue) TextValue(com.google.api.ads.admanager.jaxws.v202111.TextValue) SetValue(com.google.api.ads.admanager.jaxws.v202111.SetValue) NumberValue(com.google.api.ads.admanager.jaxws.v202111.NumberValue) TargetingValue(com.google.api.ads.admanager.jaxws.v202111.TargetingValue) Value(com.google.api.ads.admanager.jaxws.v202111.Value) BooleanValue(com.google.api.ads.admanager.jaxws.v202111.BooleanValue) DateValue(com.google.api.ads.admanager.jaxws.v202111.DateValue) TargetingValue(com.google.api.ads.admanager.jaxws.v202111.TargetingValue) SetValue(com.google.api.ads.admanager.jaxws.v202111.SetValue)

Example 32 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime in project googleads-java-lib by googleads.

the class Pql method createValue.

/**
 * Creates a {@link Value} from the value i.e. a {@link TextValue} for a value of type {@code
 * String}, {@link BooleanValue} for type {@code Boolean}, {@link NumberValue} for type {@code
 * Double}, {@code Long}, or {@code Integer}, and {@link DateTimeValue} for type {@link DateTime}.
 * If the value is a {@code Value}, the value is returned. If the value is {@code null}, an empty
 * {@link TextValue} is returned.
 *
 * @param value the value to convert
 * @return the constructed value of the appropriate type
 * @throws IllegalArgumentException if value cannot be converted
 */
public static Value createValue(Object value) {
    if (value instanceof Value) {
        return (Value) value;
    } else if (value == null) {
        return new TextValue();
    } else {
        if (value instanceof Boolean) {
            BooleanValue booleanValue = new BooleanValue();
            booleanValue.setValue((Boolean) value);
            return booleanValue;
        } else if (value instanceof Double || value instanceof Long || value instanceof Integer) {
            NumberValue numberValue = new NumberValue();
            numberValue.setValue(value.toString());
            return numberValue;
        } else if (value instanceof String) {
            TextValue textValue = new TextValue();
            textValue.setValue((String) value);
            return textValue;
        } else if (value instanceof DateTime) {
            DateTimeValue dateTimeValue = new DateTimeValue();
            dateTimeValue.setValue((DateTime) value);
            return dateTimeValue;
        } else if (value instanceof Date) {
            DateValue dateValue = new DateValue();
            dateValue.setValue((Date) value);
            return dateValue;
        } else if (value instanceof Targeting) {
            TargetingValue targetingValue = new TargetingValue();
            targetingValue.setValue((Targeting) value);
            return targetingValue;
        } else if (value instanceof Set<?>) {
            SetValue setValue = new SetValue();
            Set<Value> values = new LinkedHashSet<Value>();
            for (Object entry : (Set<?>) value) {
                validateSetValueEntryForSet(createValue(entry), values);
                values.add(createValue(entry));
            }
            setValue.getValues().addAll(values);
            return setValue;
        } else {
            throw new IllegalArgumentException("Unsupported Value type [" + value.getClass() + "]");
        }
    }
}
Also used : Set(java.util.Set) ResultSet(com.google.api.ads.admanager.jaxws.v202202.ResultSet) LinkedHashSet(java.util.LinkedHashSet) DateTimeValue(com.google.api.ads.admanager.jaxws.v202202.DateTimeValue) Targeting(com.google.api.ads.admanager.jaxws.v202202.Targeting) DateTime(com.google.api.ads.admanager.jaxws.v202202.DateTime) Date(com.google.api.ads.admanager.jaxws.v202202.Date) NumberValue(com.google.api.ads.admanager.jaxws.v202202.NumberValue) TextValue(com.google.api.ads.admanager.jaxws.v202202.TextValue) DateValue(com.google.api.ads.admanager.jaxws.v202202.DateValue) BooleanValue(com.google.api.ads.admanager.jaxws.v202202.BooleanValue) SetValue(com.google.api.ads.admanager.jaxws.v202202.SetValue) DateValue(com.google.api.ads.admanager.jaxws.v202202.DateValue) TextValue(com.google.api.ads.admanager.jaxws.v202202.TextValue) BooleanValue(com.google.api.ads.admanager.jaxws.v202202.BooleanValue) DateTimeValue(com.google.api.ads.admanager.jaxws.v202202.DateTimeValue) NumberValue(com.google.api.ads.admanager.jaxws.v202202.NumberValue) Value(com.google.api.ads.admanager.jaxws.v202202.Value) TargetingValue(com.google.api.ads.admanager.jaxws.v202202.TargetingValue) TargetingValue(com.google.api.ads.admanager.jaxws.v202202.TargetingValue) SetValue(com.google.api.ads.admanager.jaxws.v202202.SetValue)

Example 33 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime in project googleads-java-lib by googleads.

the class Pql method createValue.

/**
 * Creates a {@link Value} from the value i.e. a {@link TextValue} for a value of type {@code
 * String}, {@link BooleanValue} for type {@code Boolean}, {@link NumberValue} for type {@code
 * Double}, {@code Long}, or {@code Integer}, and {@link DateTimeValue} for type {@link DateTime}.
 * If the value is a {@code Value}, the value is returned. If the value is {@code null}, an empty
 * {@link TextValue} is returned.
 *
 * @param value the value to convert
 * @return the constructed value of the appropriate type
 * @throws IllegalArgumentException if value cannot be converted
 */
public static Value createValue(Object value) {
    if (value instanceof Value) {
        return (Value) value;
    } else if (value == null) {
        return new TextValue();
    } else {
        if (value instanceof Boolean) {
            BooleanValue booleanValue = new BooleanValue();
            booleanValue.setValue((Boolean) value);
            return booleanValue;
        } else if (value instanceof Double || value instanceof Long || value instanceof Integer) {
            NumberValue numberValue = new NumberValue();
            numberValue.setValue(value.toString());
            return numberValue;
        } else if (value instanceof String) {
            TextValue textValue = new TextValue();
            textValue.setValue((String) value);
            return textValue;
        } else if (value instanceof DateTime) {
            DateTimeValue dateTimeValue = new DateTimeValue();
            dateTimeValue.setValue((DateTime) value);
            return dateTimeValue;
        } else if (value instanceof Date) {
            DateValue dateValue = new DateValue();
            dateValue.setValue((Date) value);
            return dateValue;
        } else if (value instanceof Targeting) {
            TargetingValue targetingValue = new TargetingValue();
            targetingValue.setValue((Targeting) value);
            return targetingValue;
        } else if (value instanceof Set<?>) {
            SetValue setValue = new SetValue();
            Set<Value> values = new LinkedHashSet<Value>();
            for (Object entry : (Set<?>) value) {
                validateSetValueEntryForSet(createValue(entry), values);
                values.add(createValue(entry));
            }
            setValue.getValues().addAll(values);
            return setValue;
        } else {
            throw new IllegalArgumentException("Unsupported Value type [" + value.getClass() + "]");
        }
    }
}
Also used : Set(java.util.Set) ResultSet(com.google.api.ads.admanager.jaxws.v202205.ResultSet) LinkedHashSet(java.util.LinkedHashSet) DateTimeValue(com.google.api.ads.admanager.jaxws.v202205.DateTimeValue) Targeting(com.google.api.ads.admanager.jaxws.v202205.Targeting) DateTime(com.google.api.ads.admanager.jaxws.v202205.DateTime) Date(com.google.api.ads.admanager.jaxws.v202205.Date) NumberValue(com.google.api.ads.admanager.jaxws.v202205.NumberValue) TextValue(com.google.api.ads.admanager.jaxws.v202205.TextValue) DateValue(com.google.api.ads.admanager.jaxws.v202205.DateValue) BooleanValue(com.google.api.ads.admanager.jaxws.v202205.BooleanValue) SetValue(com.google.api.ads.admanager.jaxws.v202205.SetValue) TextValue(com.google.api.ads.admanager.jaxws.v202205.TextValue) NumberValue(com.google.api.ads.admanager.jaxws.v202205.NumberValue) Value(com.google.api.ads.admanager.jaxws.v202205.Value) TargetingValue(com.google.api.ads.admanager.jaxws.v202205.TargetingValue) BooleanValue(com.google.api.ads.admanager.jaxws.v202205.BooleanValue) DateValue(com.google.api.ads.admanager.jaxws.v202205.DateValue) DateTimeValue(com.google.api.ads.admanager.jaxws.v202205.DateTimeValue) TargetingValue(com.google.api.ads.admanager.jaxws.v202205.TargetingValue) SetValue(com.google.api.ads.admanager.jaxws.v202205.SetValue)

Example 34 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime in project googleads-java-lib by googleads.

the class PqlTest method testCreateValue_dateTimeSet.

@Test
public void testCreateValue_dateTimeSet() {
    Set<DateTime> dateTimeSet = new LinkedHashSet<DateTime>();
    dateTimeSet.add(dateTime1);
    Value value1 = ((SetValue) Pql.createValue(dateTimeSet)).getValues(0);
    assertEquals("2012-12-02T12:45:00+08:00", DateTimes.toStringWithTimeZone(((DateTimeValue) value1).getValue()));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DateTimeValue(com.google.api.ads.admanager.axis.v202111.DateTimeValue) DateTimeValue(com.google.api.ads.admanager.axis.v202111.DateTimeValue) TextValue(com.google.api.ads.admanager.axis.v202111.TextValue) Value(com.google.api.ads.admanager.axis.v202111.Value) NumberValue(com.google.api.ads.admanager.axis.v202111.NumberValue) TargetingValue(com.google.api.ads.admanager.axis.v202111.TargetingValue) BooleanValue(com.google.api.ads.admanager.axis.v202111.BooleanValue) DateValue(com.google.api.ads.admanager.axis.v202111.DateValue) SetValue(com.google.api.ads.admanager.axis.v202111.SetValue) SetValue(com.google.api.ads.admanager.axis.v202111.SetValue) DateTime(com.google.api.ads.admanager.axis.v202111.DateTime) Test(org.junit.Test)

Example 35 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime

use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime in project googleads-java-lib by googleads.

the class PqlTest method testCreateValue_dateTimeSet.

@Test
public void testCreateValue_dateTimeSet() {
    Set<DateTime> dateTimeSet = new LinkedHashSet<DateTime>();
    dateTimeSet.add(dateTime1);
    Value value1 = ((SetValue) Pql.createValue(dateTimeSet)).getValues(0);
    assertEquals("2012-12-02T12:45:00+08:00", DateTimes.toStringWithTimeZone(((DateTimeValue) value1).getValue()));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DateTimeValue(com.google.api.ads.admanager.axis.v202202.DateTimeValue) BooleanValue(com.google.api.ads.admanager.axis.v202202.BooleanValue) NumberValue(com.google.api.ads.admanager.axis.v202202.NumberValue) TargetingValue(com.google.api.ads.admanager.axis.v202202.TargetingValue) Value(com.google.api.ads.admanager.axis.v202202.Value) DateValue(com.google.api.ads.admanager.axis.v202202.DateValue) SetValue(com.google.api.ads.admanager.axis.v202202.SetValue) DateTimeValue(com.google.api.ads.admanager.axis.v202202.DateTimeValue) TextValue(com.google.api.ads.admanager.axis.v202202.TextValue) SetValue(com.google.api.ads.admanager.axis.v202202.SetValue) DateTime(com.google.api.ads.admanager.axis.v202202.DateTime) Test(org.junit.Test)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)20 Set (java.util.Set)10 Before (org.junit.Before)10 Test (org.junit.Test)10 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Bigint)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Binary)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Blob)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Boolean)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Char)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Clob)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Date)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Datetime)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Decimal)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Double)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Float)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Int (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Int)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Smallint)4 org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time (org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time)4 BooleanValue (com.google.api.ads.admanager.jaxws.v202205.BooleanValue)3 DateTime (com.google.api.ads.admanager.jaxws.v202205.DateTime)3