private void setCurrentImports(ImportDeclarationsContext imports) { Map<String, Name> importsBySimpleName = new HashMap<String, Name>(); for (ImportDeclarationContext importDecl: imports.importDeclaration()) { String importedFullname = importDecl.type.value; Name importedName = new Name(importedFullname); String importedSimpleName = importedName.getName(); if (importsBySimpleName.containsKey(importedSimpleName)) { startErrorMessage(importDecl) .append("'") .append(importsBySimpleName.get(importedSimpleName)) .append("' is already defined in an import.") .append("\n"); } importsBySimpleName.put(importedSimpleName, importedName); } this.currentImports = importsBySimpleName; } }
private static DataSchemaResolver createResolverFromSnapshot(AbstractSnapshot snapshot, String resolverPath) { final DataSchemaResolver resolver = CompatibilityUtil.getDataSchemaResolver(resolverPath); for (Map.Entry<String, NamedDataSchema> entry : snapshot.getModels().entrySet()) { Name name = new Name(entry.getKey()); NamedDataSchema schema = entry.getValue(); resolver.bindNameToSchema(name, schema, DataSchemaLocation.NO_LOCATION); } return resolver; }
private void setCurrentImports(ImportDeclarationsContext imports) { Map<String, Name> importsBySimpleName = new HashMap<>(); for (ImportDeclarationContext importDecl: imports.importDeclaration()) { String importedFullname = importDecl.type.value; Name importedName = new Name(importedFullname); String importedSimpleName = importedName.getName(); if (importsBySimpleName.containsKey(importedSimpleName)) { startErrorMessage(importDecl) .append("'") .append(importsBySimpleName.get(importedSimpleName)) .append("' is already defined in an import.") .append(NEWLINE); } importsBySimpleName.put(importedSimpleName, importedName); } this.currentImports = importsBySimpleName; }
private Name toName(String name) { return new Name(name, getCurrentNamespace(), errorMessageBuilder()); }
/** * Build the schema of a {@link DynamicRecordTemplate}. * * @param name the name of the record. * @param fieldDefs the fields of the record. * @throws IllegalArgumentException if the {@link com.linkedin.data.schema.RecordDataSchema.Field} of the fieldDefs * are already set. */ public static RecordDataSchema buildSchema(String name, Collection<? extends FieldDef<?>> fieldDefs) { StringBuilder errorMessageBuilder = new StringBuilder(); RecordDataSchema schema = new RecordDataSchema(new Name(name, errorMessageBuilder), RecordDataSchema.RecordType.RECORD); List<RecordDataSchema.Field> fields = new ArrayList<RecordDataSchema.Field>(fieldDefs.size()); for (FieldDef<?> fieldDef: fieldDefs) { RecordDataSchema.Field paramField = fieldDef.getField(); if (paramField.getRecord() != null) { throw new IllegalArgumentException("Attempt to assign field "+ fieldDef.getName() + " to record " + schema.getName() + "failed: " + "Record of field is already set to " + paramField.getRecord().getName() ); } paramField.setRecord(schema); fields.add(paramField); } schema.setFields(fields, errorMessageBuilder); return schema; }
if (primitiveSchema == null) Name name = new Name(text, getCurrentNamespace(), errorMessageBuilder()); _references.add(name);
@Override public RecordDataSchema schema() { synchronized (this) { // Don't use double-checked locking because _schema isn't volatile if (_schema == null) { final StringBuilder errorMessageBuilder = new StringBuilder(10); final Name elementSchemaName = new Name(_valueClass.getSimpleName(), errorMessageBuilder); final MapDataSchema resultsSchema = new MapDataSchema(new RecordDataSchema(elementSchemaName, RecordDataSchema.RecordType.RECORD)); final RecordDataSchema.Field resultsField = new RecordDataSchema.Field(resultsSchema); resultsField.setName(RESULTS, errorMessageBuilder); final MapDataSchema errorsSchema = new MapDataSchema(DataTemplateUtil.getSchema(ErrorResponse.class)); final RecordDataSchema.Field errorsField = new RecordDataSchema.Field(errorsSchema); errorsField.setName(ERRORS, errorMessageBuilder); final Name name = new Name(BATCH_KV_RESPONSE_CLASSNAME, errorMessageBuilder); _schema = new RecordDataSchema(name, RecordDataSchema.RecordType.RECORD); _schema.setFields(Arrays.asList(resultsField, errorsField), errorMessageBuilder); } } return _schema; }
private RecordDataSchema.Field buildDiscriminatorEnumField( String parentRecordFullName, List<String> memberKeys, StringBuilder errorMessageBuilder) { Name enumName = new Name(parentRecordFullName + SchemaTranslator.CONTAINER_RECORD_DISCRIMINATOR_ENUM_SUFFIX, errorMessageBuilder); EnumDataSchema enumDataSchema = new EnumDataSchema(enumName); enumDataSchema.setSymbols(memberKeys, errorMessageBuilder); RecordDataSchema.Field field = new RecordDataSchema.Field(enumDataSchema); field.setName(DataSchemaConstants.DISCRIMINATOR_FIELD, errorMessageBuilder); field.setDoc("Contains the name of the field that has its value set."); field.setDeclaredInline(true); field.setOptional(false); return field; } }
Name recordName = new Name(parentRecordFullName + unionFieldName, errorMessageBuilder);
Name n = new Name(); if (name != null && name != SUBSTITUTE_FOR_REQUIRED_STRING)
Name name = new Name(namedSchema.getFullName()); if (name.getNamespace().equals(_namespace))