public final class Field<T>
extends java.lang.Object
Value
.
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);
Value
Modifier and Type | Method and Description |
---|---|
static <T> Field<T> |
as(java.lang.Class<T> clazz)
Creates a field that converts its underyling value to the
Class provided. |
static <T> Field<T> |
as(Codec<T> codec)
Creates a field that converts its underlying value using the
Codec provided. |
static <A> Field<java.util.List<A>> |
asListOf(Field<A> field)
|
static <A> Field<java.util.Map<java.lang.String,A>> |
asMapOf(Field<A> field) |
<A> Field<A> |
at(Field<A> other)
Creates a field extractor composed with another nested
Field instance. |
static Field<Value> |
at(int... indexes)
Creates a field that extracts the underlying value from the indexes provided, assuming the
Value instance
is a collection or nested collections. |
static Field<Value> |
at(java.lang.String... keys)
Creates a field that extracts the underlying value from the path provided, assuming the
Value instance
is a key/value map. |
<A> Field<java.util.List<A>> |
collect(Field<A> field)
|
boolean |
equals(java.lang.Object other) |
int |
hashCode() |
<A> Field<A> |
to(java.lang.Class<A> type)
Creates a field extractor that converts its value to the class provided.
|
<A> Field<A> |
to(Codec<A> codec)
Creates a field extractor that converts its value using the codec provided.
|
java.lang.String |
toString() |
public static Field<Value> at(java.lang.String... keys)
Value
instance
is a key/value map.public static Field<Value> at(int... indexes)
Value
instance
is a collection or nested collections.indexes
- the path to the desired fieldField
instancepublic static <T> Field<T> as(Codec<T> codec)
Codec
provided.public static <T> Field<T> as(java.lang.Class<T> clazz)
Class
provided.T
- the desired final typeclazz
- the desired class typeField
instancepublic <A> Field<A> at(Field<A> other)
Field
instance.public <A> Field<A> to(Codec<A> codec)
public <A> Field<A> to(java.lang.Class<A> type)
A
- the desired final typetype
- the class to be used to convert the field's valueField
instancepublic boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object