commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Carman" <ja...@carmanconsulting.com>
Subject Re: [DISCUSS] New Expressions Sandbox Project...
Date Thu, 10 Apr 2008 18:08:29 GMT
On Thu, Apr 10, 2008 at 1:59 PM, James Carman
<james@carmanconsulting.com> wrote:
> On Thu, Apr 10, 2008 at 1:46 PM, James Carman
>  <james@carmanconsulting.com> wrote:
>  >  If people feel that [expression] isn't the right name for what I've
>  >  come up with, I don't really care (as I said, what's in a name).  But,
>  >  the idea of an expression just fit in my mind.  I'll try to come up
>  >  with something else if you're really that opposed to me using the name
>  >  "expression".  The term "macro" came to mind when I was thinking about
>  >  a name for this thing, since the builders are essentially recording
>  >  something from the user (on a proxy) that will later be played back
>  >  (on some other object).
>  >
>
>  Other words that convey a similar idea:
>
>  variable - the "expression" is really a variable (a value that can be
>  modified or retrieved).
>  value - the "expression" represents a settable/gettable "value"
>  shortcut - the "expression" is a shortcut for calling a (potentially)
>  chained series of method calls
>  flatten - the "expression" flattens the chained series of method calls
>

To spell out the "macro" API, it would be:

public interface Macro<R,V>
{
    public V getValue(R root);
    public void setValue(R root, V value);
}

public interface Recorder<R>
{
    public R template();
    public <V> Macro<R,V> record(V value);
}

A usage would look like:

Recorder<Person> recorder = ...;
Macro<Person,String> addressCityMacro =
recorder.record(recorder.template().getAddress().getCity());
Person p = ...;
String city = addressCityMacro.getValue(p);

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message