rythm-android.record.txt Maven / Gradle / Ivy
@args com.linkedin.pegasus.generator.spec.RecordTemplateSpec record, org.coursera.courier.android.JavaSyntax syntax
@import com.linkedin.pegasus.generator.spec.ClassTemplateSpec
@import com.linkedin.pegasus.generator.spec.RecordTemplateSpec.Field
@import com.linkedin.pegasus.generator.spec.PrimitiveTemplateSpec
@import com.linkedin.pegasus.generator.spec.MapTemplateSpec
@import com.linkedin.pegasus.generator.spec.UnionTemplateSpec
@import com.linkedin.pegasus.generator.spec.ArrayTemplateSpec
@import org.coursera.courier.android.JavaSyntax
@import org.coursera.courier.api.ClassTemplateSpecs
@import org.coursera.courier.schema.TypedDefinitions
@import com.linkedin.data.schema.DataSchema.Type
@maybePackageAndImports(record)
@{ String className = syntax.escapeKeyword(record.getClassName()) }
@classAnnotations(record.getSchema())
public final class @className {
@if(record.getFields().size() > 0) {
@(className)() {
@for(Field field: record.getFields()) {
@(syntax.escapeKeyword(field.getSchemaField().getName())) = null;
}
}
}
@recordConstructor(className, record, syntax)
@recordFields(record, syntax, false)
@enclosedTypes(record, syntax)
@* TODO: define a result type *@
public void validate() {
@for(Field field: record.getFields()) {
@if(!field.getSchemaField().getOptional()) {
if(@(syntax.escapeKeyword(field.getSchemaField().getName())) == null) {
@* TODO: add to list of missing required fields *@
}
}
}
}
@recordEqualityMethods(className, record, syntax)
public static class Builder {
@recordFields(record, syntax, true, true)
public @className build() {
return new @(className)(@syntax.fieldList(record.getFields()));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy