public class ReferenceFieldValue extends FieldValue
ReferenceFieldValue
may contain a single document ID which specifies the
instance the field should refer to. This document ID must have a type matching that of the
reference data type of the field itself.
Note that references are not polymorphic. This means that if you have a document type
"foo" inheriting "bar", you cannot have a reference<bar>
field containing
a document ID for a "foo" document.FieldValue.RecursiveIteratorHandler
Modifier and Type | Field and Description |
---|---|
static int |
classId |
private Optional<DocumentId> |
documentId |
private ReferenceDataType |
referenceType |
Constructor and Description |
---|
ReferenceFieldValue(ReferenceDataType referenceType)
Creates an empty reference of the provided reference type.
|
ReferenceFieldValue(ReferenceDataType referenceType,
DocumentId documentId)
Creates a reference pointing to a particular document instance in the document
type referenced by
referenceType . |
Modifier and Type | Method and Description |
---|---|
void |
assign(Object o)
Assign this non-fieldvalue value to this field value.
|
private void |
assignFromFieldValue(ReferenceFieldValue rhs) |
void |
clear() |
static ReferenceFieldValue |
createEmptyWithType(ReferenceDataType referenceType) |
void |
deserialize(Field field,
FieldReader reader)
Read a field value from the specified reader
|
boolean |
equals(Object o) |
DataType |
getDataType() |
Optional<DocumentId> |
getDocumentId() |
DocumentId |
getWrappedValue()
Expose target document ID as this value's wrapped value.
|
int |
hashCode() |
void |
printXml(XmlStream xml) |
private static void |
requireIdOfMatchingType(ReferenceDataType referenceType,
DocumentId id) |
void |
serialize(Field field,
FieldWriter writer)
Write out field value to the specified writer
|
void |
setDocumentId(DocumentId documentId) |
checkAssign, clone, compareTo, create, deserialize, getRecursiveValue, getRecursiveValue, iterateNested, onDeserialize, onSerialize, serialize, toXml
public static final int classId
private final ReferenceDataType referenceType
private Optional<DocumentId> documentId
public ReferenceFieldValue(ReferenceDataType referenceType)
referenceType
- reference target typepublic ReferenceFieldValue(ReferenceDataType referenceType, DocumentId documentId)
referenceType
.referenceType
- reference target typedocumentId
- document ID of the same document type as that given by referenceType
IllegalArgumentException
- if documentId is not of the expected document typepublic static ReferenceFieldValue createEmptyWithType(ReferenceDataType referenceType)
private static void requireIdOfMatchingType(ReferenceDataType referenceType, DocumentId id)
public DataType getDataType()
getDataType
in class FieldValue
public Optional<DocumentId> getDocumentId()
public void setDocumentId(DocumentId documentId)
public void printXml(XmlStream xml)
printXml
in class FieldValue
public void clear()
clear
in class FieldValue
public void assign(Object o)
FieldValue
Override to accept the specific types that should be legal.
assign
in class FieldValue
private void assignFromFieldValue(ReferenceFieldValue rhs)
public boolean equals(Object o)
equals
in class com.yahoo.vespa.objects.Identifiable
public int hashCode()
hashCode
in class com.yahoo.vespa.objects.Identifiable
public void serialize(Field field, FieldWriter writer)
FieldValue
serialize
in class FieldValue
public void deserialize(Field field, FieldReader reader)
FieldValue
deserialize
in class FieldValue
public DocumentId getWrappedValue()
getWrappedValue
in class FieldValue
Copyright © 2017. All rights reserved.