- Type Parameters:
S
- The serializable type
- All Known Subinterfaces:
S8ExplicitSerialPrototype<S>
Important explanation on why it's coded that way.
Assume you have a -slightly- complex ByteOutflowable object: it's called
ThFluid
and it contains all properties of a given fluid. Let's
ay that they are limite nb of fluids (air, water, methane, etc.) so that you
can simply assign a number to them (CAS number in real life). The trick is
that there is multiple types of fluids (like for instance
ImcompressibleFluid
or PerfetGasThFluid
, eah
bringing it's own formula, equation of state and so on. So when reading the
encoding of the fluid, there is a rot switch that will call sub-factories (on
specialized on perfect gas, another one in incompressible fluid, etc.).
That being said, say you are now building a parsing/composing engine for
serilization/persistency or whatever. You stumble on a field which has a type
that actually implementts the ByteOutflowable
interface, but it
MUST have a method to indicate the PROPER factory to be used for
deserializing this type of field. In the case described in previous
paragraph, the factory cannot be a constant of for instance
ImcompressibleFluid
since type parsing may need to be done at an
higher level (for instance ThFluid
) to enable the possibility to
switch dynamically between differnt types of fluid with a unified encoding
(for instance first type gives the type of fluid and allows to switch to a
give factory, then each factory will continue to read bytes, each one havong
it's own byte pattern). If relying on constant fields, override is extremly
painful since we cannot select from a specific class the right factory. For
instance tf the type of the fiekd is simply Impcoressible, we might want to
restrain encoding to simply the one give by this specific factory.
-
Method Summary
Modifier and TypeMethodDescriptiondeserialize
(ByteInflow inflow) deserialize object from theByteInflow
byte inflow.Class
<?> Get serial typeboolean
Compare two objects to determine if there are deltas.
-
Method Details
-
deserialize
deserialize object from theByteInflow
byte inflow.- Parameters:
inflow
- the inflow- Returns:
- The deserialized object
- Throws:
IOException
- the raised exception when deserializing
-
hasDelta
Compare two objects to determine if there are deltas.- Parameters:
left
- left object for comparisonright
- right object for comparison- Returns:
- true if there is a delta/difference.
-
getSerialType
Class<?> getSerialType()Get serial type- Returns:
- the class of the objects represented by this prototype
-