<div dir="ltr">I also prefer @PositiveOrZero/@NegativeOrZero over the @Non* annotation names. So +1 for using the @*OrZero naming.</div><div class="gmail_extra"><br><div class="gmail_quote">2017-05-24 18:01 GMT+02:00 Michael Nascimento <span dir="ltr">&lt;<a href="mailto:misterm@gmail.com" target="_blank">misterm@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The non-negative names are the way to go if we go the separate annotations route. I&#39;m not a big fan of simply listening to the masses though and I&#39;m wondering whether these annotations pull their weight, though. I feel more inclined towards orZero, which is the second most popular choice.<div><br></div><div>Regards,</div><div>Michael<div><div class="h5"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 24, 2017 at 6:10 AM, Gunnar Morling <span dir="ltr">&lt;<a href="mailto:gunnar@hibernate.org" target="_blank">gunnar@hibernate.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
We&#39;ve received quite some good feedback on the poll on the behavior of<br>
@Positive and @Negative (98 answers overall, see the original data<br>
below).<br>
<br>
As per question 2), there&#39;s a preference for having separate<br>
annotations instead of an attribute. I think the poll is clear enough<br>
that we should go for the separate annotation route. While I was no<br>
fan originally, it grew on me due to its explicitness.<br>
<br>
The remaining question is on their names. We had asked about<br>
@PositiveOrZero/@NegativeOrZer<wbr>o in the poll, but several people<br>
suggested @NonNegative and @NonPositive.<br>
<br>
Personally I&#39;d prefer to stick to @PositiveOrZero/@NegativeOrZer<wbr>o<br>
because I think negated names should be avoided generally, as<br>
non-negated names are easier to grok (see? ;). And they&#39;ll be easier<br>
to find via auto-completion in the IDE, i.e. when typing @Posit&lt;TAB&gt;,<br>
you&#39;ll get both options shown, unlike when going for the @Non...<br>
approach. But eventually I could live with both.<br>
<br>
Thoughts?<br>
<br>
--Gunnar<br>
<br>
Original poll data<br>
=============<br>
* When validating @Positive/@Negative, should 0 (zero) be considered<br>
as valid by default?<br>
- 58.2%: No, i.e. the following constraint is violated: private<br>
@Positive int myNum= 0<br>
- 41.8%: Yes, i.e. the following constraint is valid: private<br>
@Positive int myNum =0<br>
<br>
* How should we call the constraint attribute for controlling whether<br>
0 is considered valid or not?<br>
- 36.7%: no attribute, but rather add separate annotations:<br>
@PositiveOrZero and@NegativeOrZero<br>
- 28.6%: orZero(), e.g. used like so:@Positive(orZero=true)<br>
- 25.5%: strict(), e.g. used like so:@Positive(strict=false)<br>
- 9.2 %: others:<br>
  - &quot;@NonNegative/@NonPositive&quot; (7x)<br>
  - &quot;Different annotation @Zero&quot;<br>
  - &quot;Either make each explicit or use a @Range(min, max)&quot;<br>
<br>
* Other related remarks:<br>
- I think that 0(zero) should not be default, especially as it is<br>
default for primitives. One should explicitly allow them, otherwise<br>
users can forget to specify it.<br>
- What&#39;s so bad about @Min(0) with inclusive again?<br>
- &quot;non-negative&quot; is a well-established and widely used term for this constraint<br>
- The constraints are to fine a open closed range could do the same thing<br>
- Java&#39;s logic was always from inclusive and to exclusive and that can<br>
also be applied to 0.<br>
- let&#39;s not create confusion by acting like &quot;positive numbers&quot;<br>
includes zero. Developers can get over a little inconvenience of<br>
@Positive not passing on values that aren&#39;t positive, such as 0.<br>
- Do not be tempted to violate Bloch&#39;s api design rules. An API is<br>
long-lived and making it incorrect to please early adopters is a poor<br>
choice. <a href="https://www.infoq.com/articles/API-Design-Joshua-Bloch" rel="noreferrer" target="_blank">https://www.infoq.com/articles<wbr>/API-Design-Joshua-Bloch</a><br>
- <a href="https://math.stackexchange.com/questions/26705/is-zero-positive-or-negative" rel="noreferrer" target="_blank">https://math.stackexchange.com<wbr>/questions/26705/is-zero-posit<wbr>ive-or-negative</a><br>
- Zero is mathematically neither positive not negative so please don&#39;t<br>
throw math principle out. But the idea of attribute is a great thing<br>
for usuability<br>
- I would just use @Positive(&gt; 0), @Negative (&lt; 0), @NonNegative (&gt;=<br>
0) and @NonPositive (&lt;= 0) to make it more explicit, this also follows<br>
the general rules found on sites such as Wikipedia:<br>
<a href="https://en.wikipedia.org/wiki/Sign_(mathematics)#Terminology_for_signs" rel="noreferrer" target="_blank">https://en.wikipedia.org/wiki/<wbr>Sign_(mathematics)#Terminology<wbr>_for_signs</a><br>
______________________________<wbr>_________________<br>
beanvalidation-dev mailing list<br>
<a href="mailto:beanvalidation-dev@lists.jboss.org" target="_blank">beanvalidation-dev@lists.jboss<wbr>.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailma<wbr>n/listinfo/beanvalidation-dev</a><br>
</blockquote></div><br></div></div></div></div></div>
<br>______________________________<wbr>_________________<br>
beanvalidation-dev mailing list<br>
<a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.<wbr>jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/<wbr>beanvalidation-dev</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div>Christian Kaltepoth</div><div>Blog: <a href="http://blog.kaltepoth.de/" target="_blank">http://blog.kaltepoth.de/</a></div><div>Twitter: <a href="http://twitter.com/chkal" target="_blank">http://twitter.com/chkal</a></div><div>GitHub: <a href="https://github.com/chkal" target="_blank">https://github.com/chkal</a></div><div><br></div></div>
</div>