I believe it'd be great to change signature of the spring's Assert.* static methods so each of them will return the checked value.
So the verified code would look as follows:
or even shorter when using static imports:this.a = Assert.notNull(a, "a can't be null");
this.s = Assert.hasLength(s);
to make code even more nicer the method Assert.nullable(T verifiedValue, T... optionals) can be introduced, that takes verified value and an array of optional values that will be provided in place of verified value if it is null.this.a = notNull(a, "a can't be null");
this.s = hasLength(s);
So the code
will set u as v if v is not null and set it to "Hello" if it is.this.u = nullable(v, "Hello");