You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Ernesto Reinaldo Barreiro <re...@gmail.com> on 2016/11/25 11:08:57 UTC

using lambdas fro Args?

Hi,

Does it make sense to use lambdas for things like

https://github.com/apache/wicket/blob/master/wicket-util/src/main/java/org/apache/wicket/util/lang/Args.java#L37

?

-- 
Regards - Ernesto Reinaldo Barreiro

Re: using lambdas fro Args?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
ok.

On Fri, Nov 25, 2016 at 1:16 PM, Martin Grigorov <mg...@apache.org>
wrote:

> What would be the benefit ?
>
> The logging libraries provide such API but there one want to avoid
> calculating the log message unless really needed.
> In our case the "name" is not something expensive to calculate. It is a
> static string (always?!).
>
> What would bring value is using the Java 8 goodies to read the parameter
> name via reflection, but for this the application should use '-parameters'
> compile argument. See https://github.com/isisaddons/
> isis-metamodel-paraname8
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Fri, Nov 25, 2016 at 12:48 PM, Ernesto Reinaldo Barreiro <
> reiern70@gmail.com> wrote:
>
> > *public class *Args
> > {
> >     *public static *<T> T notNull(T argument, Supplier<String> name) {
> >         *if*(argument == *null*) {
> >             *throw new *IllegalArgumentException(name.get() + *" may not
> > be
> > null"*);
> >         } *else *{
> >             *return *argument;
> >         }
> >     }
> >
> >     *public void *test() {
> >         Args.*notNull*(*this*, ()-> *"this"*);
> >     }
> > }
> >
> > On Fri, Nov 25, 2016 at 12:25 PM, Martin Grigorov <mg...@apache.org>
> > wrote:
> >
> > > How the new usage would look like ?
> > >
> > > Martin Grigorov
> > > Wicket Training and Consulting
> > > https://twitter.com/mtgrigorov
> > >
> > > On Fri, Nov 25, 2016 at 12:08 PM, Ernesto Reinaldo Barreiro <
> > > reiern70@gmail.com> wrote:
> > >
> > > > Hi,
> > > >
> > > > Does it make sense to use lambdas for things like
> > > >
> > > > https://github.com/apache/wicket/blob/master/wicket-
> > > > util/src/main/java/org/apache/wicket/util/lang/Args.java#L37
> > > >
> > > > ?
> > > >
> > > > --
> > > > Regards - Ernesto Reinaldo Barreiro
> > > >
> > >
> >
> >
> >
> > --
> > Regards - Ernesto Reinaldo Barreiro
> >
>



-- 
Regards - Ernesto Reinaldo Barreiro

Re: using lambdas fro Args?

Posted by Martin Grigorov <mg...@apache.org>.
What would be the benefit ?

The logging libraries provide such API but there one want to avoid
calculating the log message unless really needed.
In our case the "name" is not something expensive to calculate. It is a
static string (always?!).

What would bring value is using the Java 8 goodies to read the parameter
name via reflection, but for this the application should use '-parameters'
compile argument. See https://github.com/isisaddons/isis-metamodel-paraname8

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Fri, Nov 25, 2016 at 12:48 PM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> *public class *Args
> {
>     *public static *<T> T notNull(T argument, Supplier<String> name) {
>         *if*(argument == *null*) {
>             *throw new *IllegalArgumentException(name.get() + *" may not
> be
> null"*);
>         } *else *{
>             *return *argument;
>         }
>     }
>
>     *public void *test() {
>         Args.*notNull*(*this*, ()-> *"this"*);
>     }
> }
>
> On Fri, Nov 25, 2016 at 12:25 PM, Martin Grigorov <mg...@apache.org>
> wrote:
>
> > How the new usage would look like ?
> >
> > Martin Grigorov
> > Wicket Training and Consulting
> > https://twitter.com/mtgrigorov
> >
> > On Fri, Nov 25, 2016 at 12:08 PM, Ernesto Reinaldo Barreiro <
> > reiern70@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > Does it make sense to use lambdas for things like
> > >
> > > https://github.com/apache/wicket/blob/master/wicket-
> > > util/src/main/java/org/apache/wicket/util/lang/Args.java#L37
> > >
> > > ?
> > >
> > > --
> > > Regards - Ernesto Reinaldo Barreiro
> > >
> >
>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
>

Re: using lambdas fro Args?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
*public class *Args
{
    *public static *<T> T notNull(T argument, Supplier<String> name) {
        *if*(argument == *null*) {
            *throw new *IllegalArgumentException(name.get() + *" may not be
null"*);
        } *else *{
            *return *argument;
        }
    }

    *public void *test() {
        Args.*notNull*(*this*, ()-> *"this"*);
    }
}

On Fri, Nov 25, 2016 at 12:25 PM, Martin Grigorov <mg...@apache.org>
wrote:

> How the new usage would look like ?
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Fri, Nov 25, 2016 at 12:08 PM, Ernesto Reinaldo Barreiro <
> reiern70@gmail.com> wrote:
>
> > Hi,
> >
> > Does it make sense to use lambdas for things like
> >
> > https://github.com/apache/wicket/blob/master/wicket-
> > util/src/main/java/org/apache/wicket/util/lang/Args.java#L37
> >
> > ?
> >
> > --
> > Regards - Ernesto Reinaldo Barreiro
> >
>



-- 
Regards - Ernesto Reinaldo Barreiro

Re: using lambdas fro Args?

Posted by Martin Grigorov <mg...@apache.org>.
How the new usage would look like ?

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Fri, Nov 25, 2016 at 12:08 PM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> Hi,
>
> Does it make sense to use lambdas for things like
>
> https://github.com/apache/wicket/blob/master/wicket-
> util/src/main/java/org/apache/wicket/util/lang/Args.java#L37
>
> ?
>
> --
> Regards - Ernesto Reinaldo Barreiro
>