serialization :: Serializer :: current_object
The object currently serialized byserialized
serialization :: Serializer :: serialize
Entry point method of this service, serialize theobject
serialization :: Serializer :: serialize_attribute
Serialize an attribute to compose a serializable objectserialization :: Serializer :: serialize_core
The method is called when a standardvalue
is serialized
serialization :: Serializer :: serialize_reference
Serialize an object, with full serialization or a simple referenceserialization :: Serializer :: try_to_serialize
Serializevalue
is possible, i.e. it is Serializable
or null
serialization :: Serializer :: warn
Warn of problems and potential errors (such as if an attributeserialization $ Serializer :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
serialization :: Serializer :: current_object
The object currently serialized byserialized
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).serialization :: Serializer :: serialize
Entry point method of this service, serialize theobject
serialization :: Serializer :: serialize_attribute
Serialize an attribute to compose a serializable objectserialization :: Serializer :: serialize_core
The method is called when a standardvalue
is serialized
serialization :: Serializer :: serialize_reference
Serialize an object, with full serialization or a simple referenceserialization :: Serializer :: try_to_serialize
Serializevalue
is possible, i.e. it is Serializable
or null
serialization :: Serializer :: warn
Warn of problems and potential errors (such as if an attributeSerializable
objects
serialization :: RestrictedSerializer
Extends Serializer and adds specific business behaviors when dealing with business objects.serialization :: RestrictedJsonSerializer
Extends JsonSerializer and adds specific business behaviors when dealing with business objects.
# Abstract serialization service to be sub-classed by specialized services.
interface Serializer
# Entry point method of this service, serialize the `object`
#
# This method, and refinements, should handle `null` and probably
# use double dispatch to customize the bahavior per serializable objects.
fun serialize(object: nullable Serializable) is abstract
# The object currently serialized by `serialized`
#
# Can be used by a custom serializer to add domain-specific serialization behavior.
protected fun current_object: nullable Object is abstract
# Serialize an object, with full serialization or a simple reference
protected fun serialize_reference(object: Serializable) is abstract
# Serialize an attribute to compose a serializable object
#
# This method should be called from `Serializable::core_serialize_to`.
fun serialize_attribute(name: String, value: nullable Object)
do
if not try_to_serialize(value) then
assert value != null # null would have been serialized
warn("argument {name} of type {value.class_name} is not serializable.")
end
end
# Serialize `value` is possible, i.e. it is `Serializable` or `null`
fun try_to_serialize(value: nullable Object): Bool
do
if value isa Serializable then
value.serialize_to_or_delay(self)
else if value == null then
serialize value
else return false
return true
end
# The method is called when a standard `value` is serialized
#
# The default behavior is to call `value.core_serialize_to(self)` but it
# can be redefined by a custom serializer to add domain-specific serialization behavior.
fun serialize_core(value: Serializable)
do
value.core_serialize_to(self)
end
# Warn of problems and potential errors (such as if an attribute
# is not serializable)
fun warn(msg: String) do print "Serialization warning: {msg}"
end
lib/serialization/serialization_core.nit:55,1--105,3