You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2008/11/17 10:12:53 UTC
svn commit: r718204 -
/ant/core/trunk/src/main/org/apache/tools/ant/types/Resource.java
Author: bodewig
Date: Mon Nov 17 01:12:53 2008
New Revision: 718204
URL: http://svn.apache.org/viewvc?rev=718204&view=rev
Log:
add an "as" method to Resource that allows extensions without actually implementing additional interfaces
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/types/Resource.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/Resource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/Resource.java?rev=718204&r1=718203&r2=718204&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/Resource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/Resource.java Mon Nov 17 01:12:53 2008
@@ -423,4 +423,20 @@
super.setRefid(r);
}
+ /**
+ * Returns a view of this resource that implements the interface
+ * given as the argument or null if there is no such view.
+ *
+ * <p>This allows extension interfaces to be added to resources
+ * without growing the number of permutations of interfaces
+ * decorators/adapters need to implement.</p>
+ *
+ * <p>This implementation of the method will return the current
+ * instance itself if it can be assigned to the given class.</p>
+ *
+ * @since ant 1.8.0
+ */
+ public Object as(Class clazz) {
+ return clazz.isAssignableFrom(getClass()) ? this : null;
+ }
}