Package com.faunadb.client.types
Class Field<T>
- java.lang.Object
-
- com.faunadb.client.types.Field<T>
-
public final class Field<T> extends Object
A field extractor for a FaunaDBValue
.The field extractor can be used to extract field's values from key/value maps or collections returned by FaunaDB.
Example:
Field<String> userNameField = Field.at("data", "name").to(String.class); Value result = client.query(getUser).get(); String name = result.get(userNameField);
- See Also:
Value
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Field<T>
as(Codec<T> codec)
Creates a field that converts its underlying value using theCodec
provided.static <T> Field<T>
as(Class<T> clazz)
Creates a field that converts its underyling value to theClass
provided.static <A> Field<List<A>>
asListOf(Field<A> field)
static <A> Field<Map<String,A>>
asMapOf(Field<A> field)
static Field<Value>
at(int... indexes)
Creates a field that extracts the underlying value from the indexes provided, assuming theValue
instance is a collection or nested collections.<A> Field<A>
at(Field<A> other)
Creates a field extractor composed with another nestedField
instance.static Field<Value>
at(String... keys)
Creates a field that extracts the underlying value from the path provided, assuming theValue
instance is a key/value map.<A> Field<List<A>>
collect(Field<A> field)
boolean
equals(Object other)
int
hashCode()
<A> Field<A>
to(Codec<A> codec)
Creates a field extractor that converts its value using the codec provided.<A> Field<A>
to(Class<A> type)
Creates a field extractor that converts its value to the class provided.String
toString()
-
-
-
Method Detail
-
at
public static Field<Value> at(String... keys)
Creates a field that extracts the underlying value from the path provided, assuming theValue
instance is a key/value map.
-
at
public static Field<Value> at(int... indexes)
Creates a field that extracts the underlying value from the indexes provided, assuming theValue
instance is a collection or nested collections.- Parameters:
indexes
- the path to the desired field- Returns:
- a new
Field
instance
-
as
public static <T> Field<T> as(Codec<T> codec)
Creates a field that converts its underlying value using theCodec
provided.
-
as
public static <T> Field<T> as(Class<T> clazz)
Creates a field that converts its underyling value to theClass
provided.- Type Parameters:
T
- the desired final type- Parameters:
clazz
- the desired class type- Returns:
- a new
Field
instance
-
at
public <A> Field<A> at(Field<A> other)
Creates a field extractor composed with another nestedField
instance.
-
to
public <A> Field<A> to(Codec<A> codec)
Creates a field extractor that converts its value using the codec provided.
-
to
public <A> Field<A> to(Class<A> type)
Creates a field extractor that converts its value to the class provided.- Type Parameters:
A
- the desired final type- Parameters:
type
- the class to be used to convert the field's value- Returns:
- a new
Field
instance
-
-