"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyShadowBuilderImpl.java" between
apache-tapestry-5.6.2-sources.zip and apache-tapestry-5.6.3-sources.zip

About: Apache Tapestry is a framework for creating dynamic, robust, highly scalable web applications in Java. Source code.

PropertyShadowBuilderImpl.java  (apache-tapestry-5.6.2-sources):PropertyShadowBuilderImpl.java  (apache-tapestry-5.6.3-sources)
skipping to change at line 21 skipping to change at line 21
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package org.apache.tapestry5.ioc.internal.services; package org.apache.tapestry5.ioc.internal.services;
import org.apache.tapestry5.ioc.services.*; import org.apache.tapestry5.ioc.services.*;
import org.apache.tapestry5.plastic.*; import org.apache.tapestry5.plastic.*;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
public class PropertyShadowBuilderImpl implements PropertyShadowBuilder public class PropertyShadowBuilderImpl implements PropertyShadowBuilder
{ {
private final PropertyAccess propertyAccess; private final PropertyAccess propertyAccess;
private final PlasticProxyFactory proxyFactory; private final PlasticProxyFactory proxyFactory;
final private static MethodSignatureUniqueComparator METHOD_COMPARATOR = new
MethodSignatureUniqueComparator();
public PropertyShadowBuilderImpl(@Builtin public PropertyShadowBuilderImpl(@Builtin
PlasticProxyFactory proxyFactory, PlasticProxyFactory proxyFactory,
PropertyAccess propertyAccess) PropertyAccess propertyAccess)
{ {
this.proxyFactory = proxyFactory; this.proxyFactory = proxyFactory;
this.propertyAccess = propertyAccess; this.propertyAccess = propertyAccess;
} }
@Override @Override
skipping to change at line 99 skipping to change at line 108
String.format( String.format(
"Unable to delegate method invoc ation to property '%s' of %s, because the property is null.", "Unable to delegate method invoc ation to property '%s' of %s, because the property is null.",
propertyName, source)); propertyName, source));
} }
}); });
builder.returnResult(); builder.returnResult();
} }
}); });
for (Method m : propertyType.getMethods()) for (Method m : METHOD_COMPARATOR.getUniqueMethods(propertyType) )
{ {
plasticClass.introduceMethod(m).delegateTo(delegateMethod); final MethodDescription description = new MethodDescription(
m);
if (Modifier.isStatic(description.modifiers)) {
continue;
}
plasticClass.introduceMethod(description).delegateTo(delegat
eMethod);
} }
plasticClass.addToString(String.format("<Shadow: property %s of %s>", propertyName, source)); plasticClass.addToString(String.format("<Shadow: property %s of %s>", propertyName, source));
} }
}); });
return propertyType.cast(instantiator.newInstance()); return propertyType.cast(instantiator.newInstance());
} }
private final static class MethodSignatureUniqueComparator implements Compar
ator<Method> {
@Override
public int compare(Method o1, Method o2) {
int comparison = o1.getName().compareTo(o2.getName());
if (comparison == 0) {
comparison = o1.getParameterTypes().length - o2.getParameterType
s().length;
}
if (comparison == 0) {
final int count = o1.getParameterTypes().length;
for (int i = 0; i < count; i++) {
Class p1 = o1.getParameterTypes()[i];
Class p2 = o2.getParameterTypes()[i];
if (!p1.equals(p2)) {
comparison = p1.getName().compareTo(p2.getName());
break;
}
}
}
return comparison;
}
public List<Method> getUniqueMethods(Class interfaceType)
{
final List<Method> unique = new ArrayList<>(Arrays.asList(interfaceT
ype.getMethods()));
Collections.sort(unique, this);
Method last = null;
Iterator<Method> iterator = unique.iterator();
while (iterator.hasNext())
{
Method m = iterator.next();
if (last != null && compare(m, last) == 0)
{
iterator.remove();
}
last = m;
}
return unique;
}
}
} }
 End of changes. 5 change blocks. 
2 lines changed or deleted 67 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)