public static String getJavaCoercerClassFromSchema(final DataSchema schema) { final Object o = schema.getProperties().get(JAVA_PROPERTY); if (o == null || !(o instanceof Map)) { return null; } @SuppressWarnings("unchecked") final Map<String, Object> map = (Map<String, Object>) o; final Object o2 = map.get(COERCER_CLASS_PROPERTY); if (o2 == null || !(o2 instanceof String)) { return null; } return (String) o2; } }
public static String getJavaCustomTypeClassNameFromSchema(final DataSchema schema) { final Object o = schema.getProperties().get(JAVA_PROPERTY); if (o == null || !(o instanceof Map)) { return null; } @SuppressWarnings("unchecked") final Map<String, Object> map = (Map<String, Object>) o; final Object o2 = map.get(CLASS_PROPERTY); if (o2 == null || !(o2 instanceof String)) { return null; } return (String)o2; }
/** * Encode the properties of the {@link DataSchema} * * @param schema the {@link DataSchema} being encoded. * @throws IOException if there is an error while encoding. */ protected void encodeProperties(DataSchema schema) throws IOException { _builder.writeProperties(schema.getProperties()); }
if (validatorList == null) Object validateObject = schema.getProperties().get(VALIDATE); if (validateObject == null)
public static AndroidProperties lookupAndroidProperties(ClassTemplateSpec templateSpec) { DataSchema schema = templateSpec.getSchema(); if (schema == null) { return DEFAULT; } else { Object android = schema.getProperties().get("android"); if (android == null || !(android instanceof DataMap)) { return DEFAULT; } DataMap properties = ((DataMap) android); String primitiveStyleStr = properties.getString("primitiveStyle"); Optionality optionality = primitiveStyleStr == null ? DEFAULT.optionality : Optionality.valueOf(primitiveStyleStr); return new AndroidProperties(optionality); } } }
public static CustomClasses getCustomClasses(DataSchema schema, String customTypeLanguage) final Map<String, Object> properties = schema.getProperties(); if (customTypeLanguage != null) { final Object java = properties.get(customTypeLanguage);
if (schema.getProperties().get("avro") != null)
private void encodePropertiesWithEmbeddedSchema(DataSchema schema) throws IOException for (Map.Entry<String, Object> entry : schema.getProperties().entrySet())
public TSProperties lookupTSProperties(ClassTemplateSpec templateSpec) { DataSchema schema = templateSpec.getSchema(); if (templateSpec instanceof UnionTemplateSpec && templateSpec.getOriginalTyperefSchema() != null) { schema = templateSpec.getOriginalTyperefSchema(); } if (schema == null) { return defaults; } else { Object typescript = schema.getProperties().get("typescript"); if (typescript == null || !(typescript instanceof DataMap)) { return defaults; } DataMap properties = ((DataMap) typescript); String optionalityString = properties.getString("optionality"); TSProperties.Optionality optionality = optionalityString == null ? defaults.optionality : TSProperties.Optionality.valueOf(optionalityString); Boolean maybeEquatable = properties.getBoolean("equatable"); boolean equatable = maybeEquatable == null ? defaults.equatable : maybeEquatable; Boolean maybeOmit = properties.getBoolean("omit"); boolean omit = maybeOmit == null ? defaults.omit : maybeOmit; return new TSProperties(optionality, equatable, omit); } } }
public SwiftProperties lookupSwiftProperties(ClassTemplateSpec templateSpec) { DataSchema schema = templateSpec.getSchema(); if (templateSpec instanceof UnionTemplateSpec && templateSpec.getOriginalTyperefSchema() != null) { schema = templateSpec.getOriginalTyperefSchema(); } if (schema == null) { return defaults; } else { Object swift = schema.getProperties().get("swift"); if (swift == null || !(swift instanceof DataMap)) { return defaults; } DataMap properties = ((DataMap) swift); String optionalityString = properties.getString("optionality"); SwiftProperties.Optionality optionality = optionalityString == null ? defaults.optionality : SwiftProperties.Optionality.valueOf(optionalityString); Boolean maybeEquatable = properties.getBoolean("equatable"); boolean equatable = maybeEquatable == null ? defaults.equatable : maybeEquatable; Boolean maybeOmit = properties.getBoolean("omit"); boolean omit = maybeOmit == null ? defaults.omit : maybeOmit; return new SwiftProperties(optionality, equatable, omit); } } }
@Override public void callback(List<String> path, DataSchema schema) { if (schema.getType() != DataSchema.Type.RECORD) { return; } // If schema has avro override, do not translate the record's aliased union fields. // These are handled in AvroOverrideFactory#createFromDataSchema() while encoding the Avro schema. if (schema.getProperties().get("avro") != null) { return; } RecordDataSchema recordSchema = (RecordDataSchema) schema; for (RecordDataSchema.Field field : recordSchema.getFields()) { DataSchema fieldSchema = field.getType().getDereferencedDataSchema(); // The conversion from Pegasus union type to an Avro record is performed when the union appears as either the // field's direct type or when the field's type is an array or a map whose (nested) elements is of union type. // This conversion ignores the default value when specified on an array or map typed field. Since the elements in // the default value collection can have conflicting union members, it will be hard to figure out the optionality // property of the fields in the generated Avro record. DataMap modifiedDefaultValue = modifyFieldDefaultValue(field, path); DataSchema modifiedSchema = modifyFieldSchema(recordSchema, field, fieldSchema, modifiedDefaultValue); if (modifiedSchema != null) { overrideUnionFieldSchemaAndDefault(field, modifiedSchema, modifiedDefaultValue); } } }
AvroOverride createFromDataSchema(DataSchema schema) Map<String, Object> properties = schema.getProperties(); Object avro = properties.get("avro"); if (avro != null)
Object dataProperty = dataSchema.getProperties().get(SchemaTranslator.DATA_PROPERTY); if (dataProperty != null && dataProperty.getClass() == DataMap.class)