msg.go 839 B

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