@Test public void testCreateValue_null() { assertEquals(null, ((TextValue) Pql.createValue(null)).getValue()); }
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() + "]"); } } }
Pql { 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() + "]"); } } } }
Pql { 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() + "]"); } } } private  Pql(); }
Pql { 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() + "]"); } } } private  Pql(); static Value createValue(Object value); static String toString(Value value); static Object getApiValue(Value value); static Object getNativeValue(Value value); static Object getCsvValue(Value value); static List<String[]> resultSetToStringArrayList(ResultSet resultSet); static String resultSetToString(ResultSet resultSet); static List<String> getColumnLabels(ResultSet resultSet); static List<String> getRowStringValues(Row row); static ResultSet combineResultSets(ResultSet first, ResultSet second); }
Pql { 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() + "]"); } } } private  Pql(); static Value createValue(Object value); static String toString(Value value); static Object getApiValue(Value value); static Object getNativeValue(Value value); static Object getCsvValue(Value value); static List<String[]> resultSetToStringArrayList(ResultSet resultSet); static String resultSetToString(ResultSet resultSet); static List<String> getColumnLabels(ResultSet resultSet); static List<String> getRowStringValues(Row row); static ResultSet combineResultSets(ResultSet first, ResultSet second);  }