private static String buildTypeName(StructuredDataType targetType) { return "Reference<" + targetType.getName() + ">"; }
/** * Returns the name of this as a DataTypeName * * @return Return the Documentname of this doumenttype. */ public DataTypeName getDataTypeName() { return new DataTypeName(getName()); }
private static String getTargetDocumentName(ReferenceDataType reference) { return reference.getTargetType().getName(); }
private static void requireIdOfMatchingType(ReferenceDataType referenceType, DocumentId id) { final String expectedTypeName = referenceType.getTargetType().getName(); if (!id.getDocType().equals(expectedTypeName)) { throw new IllegalArgumentException(String.format( "Can't assign document ID '%s' (of type '%s') to reference of document type '%s'", id, id.getDocType(), expectedTypeName)); } }
/** * Overrides the stored temporary data type with a concrete StructuredDataType instance. Should only * be invoked from configuration or model code when resolving temporary types. * * @throws IllegalStateException if the previously stored target type is already a concrete * instance (not TemporaryStructuredDataType). */ public void setTargetType(StructuredDataType targetType) { if (! (this.targetType instanceof TemporaryStructuredDataType)) { throw new IllegalStateException(String.format( "Unexpected attempt to replace already concrete target " + "type in ReferenceDataType instance (type is '%s')", this.targetType.getName())); } this.targetType = targetType; setName(buildTypeName(targetType)); }
@Override protected void doExecute(ExecutionContext ctx) { FieldValue input = ctx.getValue(); if (!(input instanceof StructuredFieldValue)) { throw new IllegalArgumentException("Expected structured input, got " + input.getDataType().getName() + "."); } StructuredFieldValue struct = (StructuredFieldValue)input; Field field = struct.getField(fieldName); if (field == null) { throw new IllegalArgumentException("Field '" + fieldName + "' not found in struct type '" + struct.getDataType().getName() + "'"); } ctx.setValue(struct.getFieldValue(field)); }
private void visit(DataType type) { if (type instanceof StructuredDataType) { StructuredDataType structType = (StructuredDataType) type; SDDocumentType sdDocType = find(structType.getName()); if (sdDocType == null) { throw new IllegalArgumentException("Could not find struct '" + type.getName() + "'.");