com.google.protobuf
Class ExtensionRegistryLite

java.lang.Object
  extended by com.google.protobuf.ExtensionRegistryLite
Direct Known Subclasses:
ExtensionRegistry

public class ExtensionRegistryLite
extends java.lang.Object

Equivalent to ExtensionRegistry but supports only "lite" types.

If all of your types are lite types, then you only need to use ExtensionRegistryLite. Similarly, if all your types are regular types, then you only need ExtensionRegistry. Typically it does not make sense to mix the two, since if you have any regular types in your program, you then require the full runtime and lose all the benefits of the lite runtime, so you might as well make all your types be regular types. However, in some cases (e.g. when depending on multiple third-patry libraries where one uses lite types and one uses regular), you may find yourself wanting to mix the two. In this case things get more complicated.

There are three factors to consider: Whether the type being extended is lite, whether the embedded type (in the case of a message-typed extension) is lite, and whether the extension itself is lite. Since all three are declared in different files, they could all be different. Here are all the combinations and which type of registry to use:

   Extended type     Inner type    Extension         Use registry
   =======================================================================
   lite              lite          lite              ExtensionRegistryLite
   lite              regular       lite              ExtensionRegistry
   regular           regular       regular           ExtensionRegistry
   all other combinations                            not supported
 

Note that just as regular types are not allowed to contain lite-type fields, they are also not allowed to contain lite-type extensions. This is because regular types must be fully accessible via reflection, which in turn means that all the inner messages must also support reflection. On the other hand, since regular types implement the entire lite interface, there is no problem with embedding regular types inside lite types.

Author:
[email protected] Kenton Varda

Method Summary
 void add(GeneratedMessageLite.GeneratedExtension<?,?> extension)
          Add an extension from a lite generated file to the registry.
<ContainingType extends MessageLite>
GeneratedMessageLite.GeneratedExtension<ContainingType,?>
findLiteExtensionByNumber(ContainingType containingTypeDefaultInstance, int fieldNumber)
          Find an extension by containing type and field number.
static ExtensionRegistryLite getEmptyRegistry()
          Get the unmodifiable singleton empty instance.
 ExtensionRegistryLite getUnmodifiable()
          Returns an unmodifiable view of the registry.
static ExtensionRegistryLite newInstance()
          Construct a new, empty instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static ExtensionRegistryLite newInstance()
Construct a new, empty instance.


getEmptyRegistry

public static ExtensionRegistryLite getEmptyRegistry()
Get the unmodifiable singleton empty instance.


getUnmodifiable

public ExtensionRegistryLite getUnmodifiable()
Returns an unmodifiable view of the registry.


findLiteExtensionByNumber

public <ContainingType extends MessageLite> GeneratedMessageLite.GeneratedExtension<ContainingType,?> findLiteExtensionByNumber(ContainingType containingTypeDefaultInstance,
                                                                                                                                int fieldNumber)
Find an extension by containing type and field number.

Returns:
Information about the extension if found, or null otherwise.

add

public final void add(GeneratedMessageLite.GeneratedExtension<?,?> extension)
Add an extension from a lite generated file to the registry.



Copyright © 2008-2011 Google. All Rights Reserved.