简体   繁体   中英

Reflection and annotation that doesn't define

I have programmed an app that gets name of an entity class and based on it, makes a UI. For doing so I created a few annotations and used them for the entity fields. One of these annotations is @Label that holds the name field and others are @IntType , @StringType ,... that hold the field types.

I want to know, if I write an entity for creating a UI that doesn't have one or both of the annotations, how do I handle these exception? Just with a try/catch block?

You can make a custom exception like AnotationNotFoundException , and throw it where you control the anotations of entity. Then catch it in your main method of app. You can log it somewhere like ui or log files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM