Need a new method in ArgumentsFactory to check argument

9 views
Skip to first unread message

veaven

unread,
Aug 23, 2011, 6:32:17 AM8/23/11
to lambdaj
Hi,

Can we have a new public method in ArgumentsFactory to check if an
object is an Argument? e.g. ArgumentsFactory.isArgument()

Currently, ArgumentsFactory only provides three public API:
actualArgument(), createArgument(), and
createClosureArgumentPlaceholder(). However, my project need to know
if the an object is an Argument or not, if it is, then it will do
something else.

Can we add a new API ArgumentsFactory.isArgument() into lambdaj? Any
feedback is much appreciated.

David

Mario Fusco

unread,
Aug 23, 2011, 6:55:22 AM8/23/11
to lam...@googlegroups.com
Hi David,

to be honest the ArgumentsFactory is not intended to be used by the client code. It has been designed only for lambdaj's internal use and then it has not to be formally considered as part of lambdaj's API. It also means that I feel free to change its API regardless of its backward compatibility, and that is something I actually did quite frequently in the past.

Said that, could you please send an example of how you are using the ArgumentsFactory? I am curious to see what you are doing with it, so maybe I could help you to find a better and safer way to obtain the same result without directly accessing the ArgumentsFactory or I could be convinced that it is actually necessary to consider it as part of lambadj's API and then to take care of its backward compatibility and to extend its features as you are requesting.

Thanks,
Mario

veaven

unread,
Aug 27, 2011, 8:01:37 AM8/27/11
to lambdaj
Hi Mario,

Thanks a lot for your reply.
Currently, I am using lambdaj's Argument component to build an
expression, and then I will use reflection to call those methods one
by one.

E.g.
1st, I will use lambdaj's Argument to record what method I have been
called.
Student s = on(Student.class);
Expression exp = eq(s.getGrade(), 3);

public static Expression eq(X x1, X x2)
{
if(isArgument(x1)){
method1= getMethodFromArgument(x1);
}
...
return new Expression(method1, method2);
}

2nd, I will apply these method call to my framework to calculate any
input data
e.g.
result= expression.evalute(data);

That is the reason why I want ArgumentsFactory class is not a Final
class, so that I can extend it, and then, I am about to extend
ArgumentsFactory to create my own customized Arguments which can give
me access ability to get InvocationSequence, etc.

Would you mind to make ArgumentsFactory to be extensible? thanks
again.

David

Mario Fusco

unread,
Aug 27, 2011, 11:11:16 AM8/27/11
to lam...@googlegroups.com
Hi David,

I am still not sure that I am getting what you are asking. How the Expression of your example is made? What its evaluate method does?

Moreover consider that the ArgumentsFactory class is all made of static methods, so I don't understand what you could achieve by extending it even if it wasn't final.

If I have understood the intention of your example, I guess lambdaj's closures could offer something very similar to what you're looking for especially in this feature:

http://code.google.com/p/lambdaj/wiki/Closures#Using_the_object_on_which_the_closure_is_invoked_as_unbound_vari

Let me know if that makes sense.
Cheers,
Mario
Reply all
Reply to author
Forward
0 new messages