MarshalledObject class

@fileoverview Represents an object as a map where each field is a string so that it is suitable for serialisation. Idea of ella's serialisation framework: Caller provides the type information, via either a factory or calling a specialized method.

Implemented types

Constructors

MarshalledObject(Object? rawValue)
MarshalledObject.emptyArray()
MarshalledObject.emptyObject()
MarshalledObject.fromDartObject(Object? dartObject)
Constructor to create from Dart object. Will marshal all Dart object recursively!
MarshalledObject.marshal(ISerialisable object)
Factory that marshals an ISerialisable object
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

asArray() MarshalledArray
Wraps as intermediate array
asBool() bool
asComplexMap() MarshalledMapKeyPhase
As full-featured Java map.
asDateTime() DateTime
asDouble() double
asEnum<T>(List<T> values) → T
As an enum from index (int) value. Pass the list of enum members typically called (Name of Enum).values
asEnumName<T extends Enum>(Iterable<T> values) → T
As enum frum name (string) value
asInt() int
asJsMap() Map<String, Object?>
Returns as a JS map view
asNull() Null
Conversion methods
asNullable() MarshalledObject?
Return this object as nullable type, flowing through null, if null. Used in RPC code generator to short-circuit unmarshalling logic if return type is null.
asObject<T>(IUnmarshalFactory<T> objFactory) → T
As object. Provide factory with 'Class.create' idiom.
assertIsNotNull() → void
asSimpleMap<T>() Map<String, T>
Returns as map of string keys/T values (copies to convert).
asString() String
createObjectProperty(String property) MarshalledObject
deepClone() MarshalledObject
Deep clones object which is serialisable.
deleteProperty(String property) → void
equals(MarshalledObject? other) bool
Structurally compares object for equality.
get(String property) MarshalledObject?
Get a property, returning null if null
getArray(String property) MarshalledArray
Get as array or empty
getBool(String property) bool
Get as bool or empty if null
getDouble(String property) double
Get as double or empty if null
getInt(String property) int
Get as int or empty if null
getProperties() List<String>
getProperty(String property) MarshalledObject
Get property (returns wrapper object, even if null)
getRawValue() Object?
getRawValueAs<T>() → T
getRequired(String property) MarshalledObject
Get a property, throwing if not set.
getString(String property) String
Get as string or empty if null
has(String property) bool
isArray() bool
Whether object is an array.
isMap() bool
Whether object is a Map
isNotNull() bool
This method should usually not be used for checking whether a property is not null.
isNull() bool
This method should usually not be used for checking whether a property is null.
isObject() bool
Whether is an object.
marshal(MarshalledObject marshalled) → void
serialise to this object.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeProperty(String property) → void
setFromDartObject(Object? dartObject) → void
setPropertiesFrom(MarshalledObject other) → void
Copies all properties from other object to this object
setPropertyFromBool(String property, bool? value) → void
Set bool property with type safety
setPropertyFromComplexMap(String property, Map? mapObject, IValueMarshallerFunction keyMarshaller, IValueMarshallerFunction valueMarshaller) → void
Sets property from complex map.
setPropertyFromDartObject(String property, Object? dartObject) → void
Sets property from Dart object.
setPropertyFromDouble(String property, double? value) → void
Set double property with type safety
setPropertyFromEnum(String property, Enum value) → void
Set property from enum as index
setPropertyFromEnumName(String property, Enum value) → void
Set property from enum name
setPropertyFromInt(String property, int? value) → void
Set int property with type safety
setPropertyFromIterableMarshaller(String property, Iterable<ISerialisable> iterable, ISerialisableValueMarshallerFunction valueMarshaller) → void
Marshalling setter for convenience.
setPropertyFromMarshalledIterable(String property, Iterable<MarshalledObject> iterable) → void
Sets property from Dart iterable of serialised objects. Does not marshal.
setPropertyFromMarshalledObject(String property, MarshalledObject? value) → void
Set from marshalled object property with type safety
setPropertyFromObject(String property, ISerialisable? value) → void
Marshalling setter for convenience.
setPropertyFromObjectIfNotDefault(String property, ISerialisable defaultValue, ISerialisable? value) → void
Set property from serialisable of value is not equal to the default value.
setPropertyFromObjectIterable(String property, Iterable<ISerialisable> iterable) → void
Marshalling setter for convenience.
setPropertyFromSimpleIterable(String property, Iterable<Object?> iterable) → void
setPropertyFromSimpleMap(String property, Map<String, Object?>? mapObject) → void
Sets property from simple map.
setPropertyFromString(String property, String? value) → void
Set string property with type safety
setPropertyUnsafe(String property, Object? value) → void
Setting a property only sets field if value is non-null in order to reduce JSON payload size by excluding null properties.
setPropertyUnsafeIfNotDefault<T>(String property, T? defaultValue, T? value) → void
Set property if not equal to the default value.
setRawValue(Object? newRawValue) → void
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

copyFromObjectToObject<T extends ISerialisableDeserialisable>(T sourceObject, T targetObject) → T
Util method for copying serialisable objects via serialisation/deserialisation cycle to target.
copySerialisableObject<T extends ISerialisable>(T serialisableObject, IUnmarshalFactory<T> objFactory) → T
Util method for copying serialisable objects via serialisation/deserialisation cycle.
marshalComplexMap(Map mapObject, IValueMarshallerFunction keyMarshaller, IValueMarshallerFunction valueMarshaller) MarshalledObject
Helper method.
marshalDartValue(Object? value) MarshalledObject
Helper method for serialisaing Dart objects
marshalList(List<Object?> payload) MarshalledArray
marshalObject(ISerialisable object) MarshalledObject
Helper method.
marshalSimpleMap(Map<Object?, Object?> payload) MarshalledObject
marshalValue(Object? value) MarshalledObject
Helper method. Is a SerialisableValueMarshallerFunction function. Used to marshal when deserialiser code knows statically the type.
unmarshal(MarshalledObject marshalled) MarshalledObject
Unmarshal self (no-op)