GenericTypeIndicator

abstract classGenericTypeIndicator<T>


Due to the way that Java implements generics (type-erasure), it is necessary to use a slightly more complicated method to properly resolve types for generic collections at runtime. To solve this problem, Firebase Database accepts subclasses of this class in calls to getValue (getValue,getValue) and returns a properly-typed generic collection.

As an example, you might do something like this to get a list of Message instances from aDataSnapshot:

classMessage{privateStringauthor;privateStringtext;privateMessage(){}publicMessage(Stringauthor,Stringtext){this.author=author;this.text=text;}publicStringgetAuthor(){returnauthor;}publicStringgetText(){returntext;}}// Later ...GenericTypeIndicator<List<Message>>t=newGenericTypeIndicator<List<Message>>(){};List<Message>messages=snapshot.getValue(t);
Parameters
<T>

The type of generic collection that this instance servers as an indicator for

Summary

Public constructors

Public constructors

GenericTypeIndicator

GenericTypeIndicator()

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-21 UTC.