Top Description Inners Fields Constructors Methods
com.google.protobuf

public Class ExtensionRegistryLite

extends Object
Class Inheritance
Known Direct Subclasses
com.google.protobuf.ExtensionRegistry
Imports
java.util.Collections, .HashMap, .Map

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-party 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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ExtensionRegistryLite.ObjectIntPair

A (Object, int) pair, used as a map key.

Field Summary

Modifier and TypeField and Description
private static volatile boolean
pack-priv static final ExtensionRegistryLite
pack-priv static final String
private static final Class<?>
private final Map<ExtensionRegistryLite.ObjectIntPair, GeneratedMessageLite.GeneratedExtension<?, ?>>

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
pack-priv
ExtensionRegistryLite(boolean empty)

Method Summary

Modifier and TypeMethod and Description
public final void
add(final GeneratedMessageLite.GeneratedExtension<?, ?> extension)

Add an extension from a lite generated file to the registry.

public final void
add(ExtensionLite<?, ?> extension)

Add an extension from a lite generated file to the registry only if it is a non-lite extension i.e. GeneratedMessageLite.GeneratedExtension.

public <ContainingType extends MessageLite> GeneratedMessageLite.GeneratedExtension<ContainingType, ?>

Returns:

Information about the extension if found, or null otherwise.
findLiteExtensionByNumber
(final ContainingType containingTypeDefaultInstance, final int fieldNumber)

Find an extension by containing type and field number.

public static ExtensionRegistryLite
getEmptyRegistry()

Get the unmodifiable singleton empty instance of either ExtensionRegistryLite or ExtensionRegistry (if the full (non-Lite) proto libraries are available).

public ExtensionRegistryLite
getUnmodifiable()

Returns an unmodifiable view of the registry.

public static boolean
public static ExtensionRegistryLite
newInstance()

Construct a new, empty instance.

pack-priv static Class<?>
public static void
setEagerlyParseMessageSets(boolean isEagerlyParse)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

eagerlyParseMessageSetsback to summary
private static volatile boolean eagerlyParseMessageSets
EMPTY_REGISTRY_LITEback to summary
pack-priv static final ExtensionRegistryLite EMPTY_REGISTRY_LITE
EXTENSION_CLASS_NAMEback to summary
pack-priv static final String EXTENSION_CLASS_NAME
extensionClassback to summary
private static final Class<?> extensionClass
extensionsByNumberback to summary
private final Map<ExtensionRegistryLite.ObjectIntPair, GeneratedMessageLite.GeneratedExtension<?, ?>> extensionsByNumber

Constructor Detail

ExtensionRegistryLiteback to summary
pack-priv ExtensionRegistryLite()
ExtensionRegistryLiteback to summary
pack-priv ExtensionRegistryLite(ExtensionRegistryLite other)
ExtensionRegistryLiteback to summary
pack-priv ExtensionRegistryLite(boolean empty)

Method Detail

addback to summary
public final void add(final GeneratedMessageLite.GeneratedExtension<?, ?> extension)

Add an extension from a lite generated file to the registry.

addback to summary
public final void add(ExtensionLite<?, ?> extension)

Add an extension from a lite generated file to the registry only if it is a non-lite extension i.e. GeneratedMessageLite.GeneratedExtension.

findLiteExtensionByNumberback to summary
public <ContainingType extends MessageLite> GeneratedMessageLite.GeneratedExtension<ContainingType, ?> findLiteExtensionByNumber(final ContainingType containingTypeDefaultInstance, final int fieldNumber)

Find an extension by containing type and field number.

Returns:GeneratedMessageLite.GeneratedExtension<ContainingType, ?>

Information about the extension if found, or null otherwise.

Annotations
@SuppressWarnings:unchecked
getEmptyRegistryback to summary
public static ExtensionRegistryLite getEmptyRegistry()

Get the unmodifiable singleton empty instance of either ExtensionRegistryLite or ExtensionRegistry (if the full (non-Lite) proto libraries are available).

getUnmodifiableback to summary
public ExtensionRegistryLite getUnmodifiable()

Returns an unmodifiable view of the registry.

isEagerlyParseMessageSetsback to summary
public static boolean isEagerlyParseMessageSets()
newInstanceback to summary
public static ExtensionRegistryLite newInstance()

Construct a new, empty instance.

This may be an ExtensionRegistry if the full (non-Lite) proto libraries are available.

resolveExtensionClassback to summary
pack-priv static Class<?> resolveExtensionClass()
setEagerlyParseMessageSetsback to summary
public static void setEagerlyParseMessageSets(boolean isEagerlyParse)
com.google.protobuf back to summary

private final Class ExtensionRegistryLite.ObjectIntPair

extends Object
Class Inheritance

A (Object, int) pair, used as a map key.

Field Summary

Modifier and TypeField and Description
private final int
private final Object

Constructor Summary

AccessConstructor and Description
pack-priv
ObjectIntPair(final Object object, final int number)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

numberback to summary
private final int number
objectback to summary
private final Object object

Constructor Detail

ObjectIntPairback to summary
pack-priv ObjectIntPair(final Object object, final int number)

Method Detail

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override