abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1196844 - /abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java
Date Wed, 02 Nov 2011 22:32:50 GMT
Author: jmsnell
Date: Wed Nov  2 22:32:49 2011
New Revision: 1196844

URL: http://svn.apache.org/viewvc?rev=1196844&view=rev
Log:
Support fluent interfaces in the extend proxy...

e.g. if the attached interface uses setters whose return value is the same class, assume that
it's a fluent method so calls can be chained...

public interface Foo {
  Foo setBar(String bar);
  Foo setBaz(String baz);
}

PersonObject p = new PersonObject();
p.extend(Foo.class)
  .setBar("abc")
  .setBaz("xyz");
p.writeTo(System.out);

Modified:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java?rev=1196844&r1=1196843&r2=1196844&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java
Wed Nov  2 22:32:49 2011
@@ -686,7 +686,8 @@ public class Extra {
           if (args.length != 1)
             throw new UnsupportedOperationException();
           base.setProperty(name,args[0]);
-          return null; 
+          return method.getReturnType().isAssignableFrom(type) ?
+            obj : null; 
         } else if (method.getParameterTypes().length == 0) {
           return method.getReturnType().cast(base.getProperty(name));
         } else {



Mime
View raw message