You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Maurice Marrink <ma...@gmail.com> on 2007/06/17 14:17:30 UTC

private inner class of compoundpropertymodel

Hi, I am in the process of extending CompoundPropertyModel and its
inner class AttachedCompoundPropertyModel. However since the last is a
private inner class i am forced to copy the class definition in to my
own creating some code duplication. In order to prevent this
duplication it would be helpful if this inner class was made protected
instead of private and provided a method to access the owning
component. These proposed changes are already applied to the attached
patch. So if everybody agrees the change can be made very quickly.

Index: .
===================================================================
--- .	(revision 548032)
+++ .	(working copy)
@@ -149,7 +149,7 @@
 	 *
 	 * @author ivaynberg
 	 */
-	private class AttachedCompoundPropertyModel extends AbstractPropertyModel
+	protected class AttachedCompoundPropertyModel extends AbstractPropertyModel
 			implements  IWrapModel
 	{
 		private static final long serialVersionUID = 1L;
@@ -167,7 +167,14 @@
 			super(CompoundPropertyModel.this);
 			this.owner = owner;
 		}
-
+		/**
+		 * The owning component of this model.
+		 * @return the component owning this model.
+		 */
+		protected final Component getOwner()
+		{
+			return owner;
+		}
 		/**
 		 * @see org.apache.wicket.model.AbstractPropertyModel#propertyExpression()
 		 */


What do you think?

Maurice

Re: private inner class of compoundpropertymodel

Posted by Maurice Marrink <ma...@gmail.com>.
Ok.

Maurice

On 6/17/07, Eelco Hillenius <ee...@gmail.com> wrote:
> > That is exactly what i am doing right now. And i have no problem if it
> > has to stay that way. However I thought i might be helpful for
> > everyone extending CompoundPropertyModel, and given the fact that none
> > of the methods in AttachedCompoundPropertyModel are final or otherwise
> > protected against overriding i though it was an oversight. And like
> > you said there is not much going on in that class so why not make it
> > extendable.
>
> Well, exactly because there isn't much going on in that class: why
> make expose it? It will only increase the API surface and limits our
> future options for refactoring the things internally.
>
> Eelco
>

Re: private inner class of compoundpropertymodel

Posted by Eelco Hillenius <ee...@gmail.com>.
> That is exactly what i am doing right now. And i have no problem if it
> has to stay that way. However I thought i might be helpful for
> everyone extending CompoundPropertyModel, and given the fact that none
> of the methods in AttachedCompoundPropertyModel are final or otherwise
> protected against overriding i though it was an oversight. And like
> you said there is not much going on in that class so why not make it
> extendable.

Well, exactly because there isn't much going on in that class: why
make expose it? It will only increase the API surface and limits our
future options for refactoring the things internally.

Eelco

Re: private inner class of compoundpropertymodel

Posted by Maurice Marrink <ma...@gmail.com>.
That is exactly what i am doing right now. And i have no problem if it
has to stay that way. However I thought i might be helpful for
everyone extending CompoundPropertyModel, and given the fact that none
of the methods in AttachedCompoundPropertyModel are final or otherwise
protected against overriding i though it was an oversight. And like
you said there is not much going on in that class so why not make it
extendable.

just my 2 cents,

Maurice

On 6/17/07, Eelco Hillenius <ee...@gmail.com> wrote:
> Can't you just create your own version of
> AttachedCompoundPropertyModel (you are after all thinking about
> extending it, and there isn't so much going on in that class) and
> overriding wrapOnInheritance and return an instance of your class?
>
> Eelco
>
>
> On 6/17/07, Maurice Marrink <ma...@gmail.com> wrote:
> > Hi, I am in the process of extending CompoundPropertyModel and its
> > inner class AttachedCompoundPropertyModel. However since the last is a
> > private inner class i am forced to copy the class definition in to my
> > own creating some code duplication. In order to prevent this
> > duplication it would be helpful if this inner class was made protected
> > instead of private and provided a method to access the owning
> > component. These proposed changes are already applied to the attached
> > patch. So if everybody agrees the change can be made very quickly.
> >
> > Index: .
> > ===================================================================
> > --- .   (revision 548032)
> > +++ .   (working copy)
> > @@ -149,7 +149,7 @@
> >          *
> >          * @author ivaynberg
> >          */
> > -       private class AttachedCompoundPropertyModel extends AbstractPropertyModel
> > +       protected class AttachedCompoundPropertyModel extends AbstractPropertyModel
> >                         implements  IWrapModel
> >         {
> >                 private static final long serialVersionUID = 1L;
> > @@ -167,7 +167,14 @@
> >                         super(CompoundPropertyModel.this);
> >                         this.owner = owner;
> >                 }
> > -
> > +               /**
> > +                * The owning component of this model.
> > +                * @return the component owning this model.
> > +                */
> > +               protected final Component getOwner()
> > +               {
> > +                       return owner;
> > +               }
> >                 /**
> >                  * @see org.apache.wicket.model.AbstractPropertyModel#propertyExpression()
> >                  */
> >
> >
> > What do you think?
> >
> > Maurice
> >
>

Re: private inner class of compoundpropertymodel

Posted by Eelco Hillenius <ee...@gmail.com>.
Can't you just create your own version of
AttachedCompoundPropertyModel (you are after all thinking about
extending it, and there isn't so much going on in that class) and
overriding wrapOnInheritance and return an instance of your class?

Eelco


On 6/17/07, Maurice Marrink <ma...@gmail.com> wrote:
> Hi, I am in the process of extending CompoundPropertyModel and its
> inner class AttachedCompoundPropertyModel. However since the last is a
> private inner class i am forced to copy the class definition in to my
> own creating some code duplication. In order to prevent this
> duplication it would be helpful if this inner class was made protected
> instead of private and provided a method to access the owning
> component. These proposed changes are already applied to the attached
> patch. So if everybody agrees the change can be made very quickly.
>
> Index: .
> ===================================================================
> --- .   (revision 548032)
> +++ .   (working copy)
> @@ -149,7 +149,7 @@
>          *
>          * @author ivaynberg
>          */
> -       private class AttachedCompoundPropertyModel extends AbstractPropertyModel
> +       protected class AttachedCompoundPropertyModel extends AbstractPropertyModel
>                         implements  IWrapModel
>         {
>                 private static final long serialVersionUID = 1L;
> @@ -167,7 +167,14 @@
>                         super(CompoundPropertyModel.this);
>                         this.owner = owner;
>                 }
> -
> +               /**
> +                * The owning component of this model.
> +                * @return the component owning this model.
> +                */
> +               protected final Component getOwner()
> +               {
> +                       return owner;
> +               }
>                 /**
>                  * @see org.apache.wicket.model.AbstractPropertyModel#propertyExpression()
>                  */
>
>
> What do you think?
>
> Maurice
>