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 theCodecprovided.static <T> Field<T>as(Class<T> clazz)Creates a field that converts its underyling value to theClassprovided.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 theValueinstance is a collection or nested collections.<A> Field<A>at(Field<A> other)Creates a field extractor composed with another nestedFieldinstance.static Field<Value>at(String... keys)Creates a field that extracts the underlying value from the path provided, assuming theValueinstance is a key/value map.<A> Field<List<A>>collect(Field<A> field)booleanequals(Object other)inthashCode()<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.StringtoString()
-
-
-
Method Detail
-
at
public static Field<Value> at(String... keys)
Creates a field that extracts the underlying value from the path provided, assuming theValueinstance 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 theValueinstance is a collection or nested collections.- Parameters:
indexes- the path to the desired field- Returns:
- a new
Fieldinstance
-
as
public static <T> Field<T> as(Codec<T> codec)
Creates a field that converts its underlying value using theCodecprovided.
-
as
public static <T> Field<T> as(Class<T> clazz)
Creates a field that converts its underyling value to theClassprovided.- Type Parameters:
T- the desired final type- Parameters:
clazz- the desired class type- Returns:
- a new
Fieldinstance
-
at
public <A> Field<A> at(Field<A> other)
Creates a field extractor composed with another nestedFieldinstance.
-
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
Fieldinstance
-
-