mgarin / weblaf

WebLaF is a fully open-source Look & Feel and component library written in pure Java for cross-platform desktop Swing applications.
http://weblookandfeel.com
GNU General Public License v3.0
1.13k stars 234 forks source link

What is "@NotNull" class role exactly? #641

Closed UltraBurstXD closed 3 years ago

UltraBurstXD commented 3 years ago

Hi. I'm studying those layout managers offered by Oracle for some quite time... They aren't very intuitive or flexible, well maybe except for FlowLayout and GroupLayout (but... it is very verbose...). I've taken interest on your Layout Manager, FormLayout. GridBag and Spring Layout I hate 'em, the rest is trash at some point...

The GridgLayout has some functionalities that GridBagLayout should've inherited, the horizontal gap, hgap and vertical gap, vgap; instead of using insets or others annoying methods to set the gaps manually (Even on Designer it's a big pain...).

I've taken a peek on AbstractLayoutManager, it's very legible and all, but the @NotNull class is giving me some headaches... What does it really do?

mgarin commented 3 years ago

You can always check JavaDoc in any particular class if you have WebLaF sources attached to your project, this might help in many cases as I try to keep everything well-documented. JavaDoc from NotNull class:

/**
 * An element annotated with {@link NotNull} claims to never return/contain/operate with {@code null} values.
 *
 * @author Mikle Garin
 */

It is basically that. Just an annotation that is used to mark methods that cannot return null values, as well as fields, arguments or local variables that cannot have null values. It does nothing in runtime and is simply used at IDE level for realtime code validation.

If you aren't familiar with annotations in Java - I recommend reading official document about them: https://docs.oracle.com/javase/tutorial/java/annotations/

UltraBurstXD commented 3 years ago

Thanks, Got it.