1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
package java
const msgTpl = `
{{ if not (ignored .) -}}
/**
* Validates {@code {{ simpleName . }}} protobuf objects.
*/
public static class {{ simpleName . }}Validator implements io.envoyproxy.pgv.ValidatorImpl<{{ qualifiedName . }}> {
{{- template "msgInner" . -}}
}
{{- end -}}
`
const msgInnerTpl = `
{{- range .NonOneOfFields }}
{{ renderConstants (context .) }}
{{ end }}
{{ range .SyntheticOneOfFields }}
{{ renderConstants (context .) }}
{{ end }}
{{ range .RealOneOfs }}
{{ template "oneOfConst" . }}
{{ end }}
public void assertValid({{ qualifiedName . }} proto, io.envoyproxy.pgv.ValidatorIndex index) throws io.envoyproxy.pgv.ValidationException {
{{ if disabled . }}
// Validate is disabled for {{ simpleName . }}
return;
{{- else -}}
{{ range .NonOneOfFields -}}
{{ render (context .) }}
{{ end -}}
{{ range .SyntheticOneOfFields }}
if ({{ hasAccessor (context .) }}) {
{{ render (context .) }}
}
{{ end }}
{{ range .RealOneOfs }}
{{ template "oneOf" . }}
{{- end -}}
{{- end }}
}
`
|