detect required fields

35 views
Skip to first unread message

Carlos Tasada

unread,
May 30, 2017, 4:54:28 PM5/30/17
to protostuff
Hi everyone,

I've started to use the library recently. Due to some reasons, I need to detect if an Schema field is required or not on the probuff level. I know I could simply try to serialize the Pojo and capture the exception, but I would like to detect it before hand.

Is there anyway of achieving that? I have checked on the Schema and Field classes and I don't see anything informing about this metadata.

Thanks.

David Yu

unread,
May 30, 2017, 4:59:34 PM5/30/17
to protostuff
On Wed, May 31, 2017 at 1:04 AM, Carlos Tasada <cta...@gmail.com> wrote:
Hi everyone,

I've started to use the library recently. Due to some reasons, I need to detect if an Schema field is required or not on the probuff level. I know I could simply try to serialize the Pojo and capture the exception, but I would like to detect it before hand.

Is there anyway of achieving that?
If you're using protostuff-runtime, then no.  All fields are currently treated as optional. 
If you're using the compiler, you can extend the codegen template and add metadata that way.
I have checked on the Schema and Field classes and I don't see anything informing about this metadata.

Thanks.

--
You received this message because you are subscribed to the Google Groups "protostuff" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protostuff+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
When the cat is away, the mouse is alone.
dyuproject.com
Reply all
Reply to author
Forward
0 new messages