juneau-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John D. Ament" <johndam...@apache.org>
Subject Re: Adding BeanProperty to constructor arguments
Date Mon, 09 Jan 2017 15:44:23 GMT
No, I would expect it to be both (though maybe it could optimize to find
the right constructor)

@BeanConstructor
MyBean(@BeanParameter int foo, @BeanParameter("baz") String bar)

Foo could be interpolated (if you're using Java 8) and baz goes into bar.
If you're not using Java 8 you would have to add "foo" to BeanParameter.

And why not using value attribute to shorten the use case?

John

On Mon, Jan 9, 2017 at 10:38 AM James Bognar <james.bognar@salesforce.com>
wrote:

> Oh....wait....I think I misunderstood your original question.  Do you
> mean...
>
> MyBean(@BeanProperty(name="foo") int foo, @BeanProperty(name="bar") String
> bar)
>
> ...instead of...
> @BeanConstructor(properties="foo,bar")
> MyBean(int foo, String bar)
>
> ...and then eliminate @BeanConstructor entirely?
>
>
>
>
>
> On Mon, Jan 9, 2017 at 10:32 AM, John D. Ament <johndament@apache.org>
> wrote:
>
> > Isn't that what @BeanConstructor is meant for? Choosing the right
> > constructor to use (when no default constructor exists)?
> >
> > On Mon, Jan 9, 2017 at 9:33 AM James Bognar <james.bognar@salesforce.com
> >
> > wrote:
> >
> > > I see what you mean.  There may be multiple constructors with different
> > > arguments.  However, we could find the one with the correct argument
> > > types.  In the example above, we would be looking for....
> > >
> > > public MyBean(int, String);
> > >
> > > On Mon, Jan 9, 2017 at 9:27 AM, John D. Ament <johndament@apache.org>
> > > wrote:
> > >
> > > > James,
> > > >
> > > > Maybe, however specifically for constructor parsing there are cases
> > where
> > > > the attribute is passed in but not saved as an attribute.  Right now
> > that
> > > > type of solution wouldn't work.
> > > >
> > > > John
> > > >
> > > > On Mon, Jan 9, 2017 at 9:08 AM James Bognar <
> > james.bognar@salesforce.com
> > > >
> > > > wrote:
> > > >
> > > > > Hi John,
> > > > >
> > > > > Do you mean adding an index property on the @BeanProperty
> annotation
> > > that
> > > > > denotes it's constructor parameter index?
> > > > >
> > > > > @BeanProperty(constructorIndex=0)
> > > > > public int foo();
> > > > >
> > > > > @BeanProperty(constructorIndex=1)
> > > > > public String bar();
> > > > >
> > > > >
> > > > >
> > > > > On Sun, Jan 8, 2017 at 9:39 PM, John D. Ament <
> johndament@apache.org
> > >
> > > > > wrote:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I was wondering if there was a reason (or maybe equivalent)
to
> > using
> > > > > > @BeanProperty on a constructor argument?  This way on
> > BeanConstructor
> > > > > > instead of having to list the ordered arguments, the annotation
> > could
> > > > be
> > > > > > used to say which field it covered.
> > > > > >
> > > > > > John
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > James Bognar
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > James Bognar
> > >
> >
>
>
>
> --
> James Bognar
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message