pip_services3_commons.data.AnyValue module

pip_services3_commons.data.AnyValue

AnyValue implementation

copyright

Conceptual Vision Consulting LLC 2015-2016, see AUTHORS for more details.

license

MIT, see LICENSE for more details.

class pip_services3_commons.data.AnyValue.AnyValue(value: Any = None)

Bases: pip_services3_commons.data.ICloneable.ICloneable

Cross-language implementation of dynamic object what can hold args of any type. The stored args can be converted to different types using variety of accessor methods.

Example:

value1 = AnyValue("123.456")

value1.get_as_integer()   # Result: 123
value1.get_as_string()    # Result: "123.456"
value1.get_as_float()     # Result: 123.456
clone() → Any

Creates a binary clone of this object.

Returns

a clone of this object.

equals(other: Any)bool

Compares this object args to specified specified args. When direct comparison gives negative results it tries to compare values as strings.

Parameters

other – the args to be compared with.

Returns

true when objects are equal and false otherwise.

equals_as_type(value_type: pip_services3_commons.convert.TypeCode.TypeCode, obj: Any)bool

Compares this object args to specified specified args. When direct comparison gives negative results it converts values to type specified by type code and compare them again.

Parameters
  • value_type – the Typecode type that defined the type of the result

  • obj – the args to be compared with.

Returns

true when objects are equal and false otherwise.

get_as_array()pip_services3_commons.data.AnyValueArray.AnyValueArray

Converts object args into an AnyArray or returns empty AnyArray if conversion is not possible.

Returns

AnyArray args or empty AnyArray if conversion is not supported.

get_as_boolean()bool

Converts object args into a boolean or returns false if conversion is not possible.

Returns

string args or false if conversion is not supported.

get_as_boolean_with_default(default_value: bool)bool

Converts object args into a boolean or returns default args if conversion is not possible.

Parameters

default_value – the default args.

Returns

boolean args or default if conversion is not supported.

get_as_datetime()datetime.datetime

Converts object args into a Date or returns current date if conversion is not possible.

Returns

Date args or current date if conversion is not supported.

get_as_datetime_with_default(default_value: datetime.datetime)datetime.datetime

Converts object args into a Date or returns default args if conversion is not possible.

Parameters

default_value – the default args.

Returns

Date args or default if conversion is not supported.

get_as_double()float

Converts object value into a double or returns null if conversion is not possible.

Returns

double value or None if conversion is not supported.

See: DoubleConverter

get_as_double_with_default(default_value: float)float

Converts object value into a double or returns default value if conversion is not possible.

Parameters

default_value – the default value.

Returns

double value or default if conversion is not supported.

See: DoubleConverter

get_as_float()float

Converts object args into a float or returns 0 if conversion is not possible.

Returns

float args or 0 if conversion is not supported.

get_as_float_with_default(default_value: float)float

Converts object args into a float or returns default args if conversion is not possible.

Parameters

default_value – the default args.

Returns

float args or default if conversion is not supported.

get_as_integer()int

Converts object args into an integer or returns 0 if conversion is not possible.

Returns

integer args or 0 if conversion is not supported.

get_as_integer_with_default(default_value: int)int

Converts object args into a integer or returns default args if conversion is not possible.

Parameters

default_value – the default args.

Returns

integer args or default if conversion is not supported.

get_as_long()float
get_as_long_with_default(default_value: float)float
get_as_map() → AnyValueMap

Converts object args into AnyMap or returns empty AnyMap if conversion is not possible.

Returns

AnyMap args or empty AnyMap if conversion is not supported.

get_as_nullable_boolean() → Optional[bool, None]

Converts object args into a boolean or returns null if conversion is not possible.

Returns

boolean args or null if conversion is not supported.

get_as_nullable_datetime() → Optional[datetime.datetime, None]

Converts object args into a Date or returns None if conversion is not possible.

Returns

Date args or None if conversion is not supported.

get_as_nullable_double() → Optional[float, None]

Converts object value into a double or returns null if conversion is not possible.

Returns

double args or None if conversion is not supported.

get_as_nullable_float() → Optional[float, None]

Converts object args into a float or returns None if conversion is not possible.

Returns

float args or None if conversion is not supported.

get_as_nullable_integer() → Optional[int, None]

Converts object args into an integer or returns None if conversion is not possible.

Returns

integer args or None if conversion is not supported.

get_as_nullable_long() → Optional[float, None]
get_as_nullable_string()str

Converts object args into a string or returns null if conversion is not possible.

Returns

string args or None if conversion is not supported.

get_as_nullable_type(value_type: pip_services3_commons.convert.TypeCode.TypeCode) → Optional[Any, None]

Converts object args into a args defined by specied typecode. If conversion is not possible it returns None.

Parameters

value_type – the TypeCode that defined the type of the result

Returns

args defined by the typecode or null if conversion is not supported.

get_as_object() → Any

Gets the args stored in this object without any conversions

Returns

the object args.

get_as_string()str

Converts object args into a string or returns “” if conversion is not possible.

Returns

string args or “” if conversion is not supported.

get_as_string_with_default(default_value: str)str

Converts object args into a string or returns default args if conversion is not possible.

Parameters

default_value – the default args.

Returns

string args or default if conversion is not supported.

get_as_type(value_type: pip_services3_commons.convert.TypeCode.TypeCode) → Any

Converts object args into a args defined by specied typecode. If conversion is not possible it returns default args for the specified type.

Parameters

value_type – the TypeCode that defined the type of the result

Returns

args defined by the typecode or type default args if conversion is not supported.

get_as_type_with_default(value_type: pip_services3_commons.convert.TypeCode.TypeCode, default_value: Any) → Any

Converts object args into a args defined by specied typecode. If conversion is not possible it returns default args.

Parameters
  • value_type – the TypeCode that defined the type of the result

  • default_value – the default args

Returns

args defined by the typecode or type default args if conversion is not supported.

get_type_code()pip_services3_commons.convert.TypeCode.TypeCode

Gets type code for the args stored in this object.

Returns

type code of the object args.

set_as_object(value: Any)

Sets a new args for this object

Parameters

value – the new object args.

to_string()str

Gets a string representation of the object.

Returns

a string representation of the object.