public class Serializer extends Object
This works by walking all referenced values with a ValueVisitor.
Referenced "dynamic" objects (i.e. implementations of AddsToRuleKey) are serialized as simply a hash of their serialized representation. The serialization of a complex object is then effectively a merkle tree. This allows us to share the serialized representation of shared objects (for c++ particularly, there are many shared references to the PreprocessorDelegate and other such fields).
Modifier and Type | Class and Description |
---|---|
static interface |
Serializer.Delegate
The first time a "dynamic" object is encountered (including Buildables themselves),
registerNewValue will be called.
|
Modifier and Type | Field and Description |
---|---|
static int |
TARGET_CONFIGURATION_TYPE_CONFIGURATION |
static int |
TARGET_CONFIGURATION_TYPE_DEFAULT |
static int |
TARGET_CONFIGURATION_TYPE_EMPTY |
Constructor and Description |
---|
Serializer(SourcePathRuleFinder ruleFinder,
CellPathResolver cellResolver,
Serializer.Delegate delegate) |
Modifier and Type | Method and Description |
---|---|
<T extends AddsToRuleKey> |
reserialize(T instance)
Returns the serialized bytes of the instance.
|
<T extends AddsToRuleKey> |
serialize(T instance)
Serializes an object.
|
<T extends AddsToRuleKey> |
serialize(T instance,
ClassInfo<T> classInfo)
See Serialize(T instance) above.
|
public static final int TARGET_CONFIGURATION_TYPE_EMPTY
public static final int TARGET_CONFIGURATION_TYPE_DEFAULT
public static final int TARGET_CONFIGURATION_TYPE_CONFIGURATION
public Serializer(SourcePathRuleFinder ruleFinder, CellPathResolver cellResolver, Serializer.Delegate delegate)
public <T extends AddsToRuleKey> com.google.common.hash.HashCode serialize(T instance) throws IOException
IOException
public <T extends AddsToRuleKey> Either<com.google.common.hash.HashCode,byte[]> serialize(T instance, ClassInfo<T> classInfo) throws IOException
IOException
public <T extends AddsToRuleKey> byte[] reserialize(T instance) throws IOException
IOException