Clover coverage report - Code Coverage for tapestry release 4.0.1
Coverage timestamp: Fri Mar 31 2006 09:12:14 EST
file stats: LOC: 102   Methods: 7
NCLOC: 49   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PropertyChangeImpl.java 100% 100% 100% 100%
coverage
 1    // Copyright 2004, 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.tapestry.record;
 16   
 17    import org.apache.hivemind.util.Defense;
 18    import org.apache.hivemind.util.ToStringBuilder;
 19   
 20    /**
 21    * Represents a change to a component on a page.
 22    *
 23    * @author Howard Lewis Ship
 24    */
 25   
 26    public class PropertyChangeImpl implements PropertyChange
 27    {
 28    private String _componentPath;
 29   
 30    private String _propertyName;
 31   
 32    private Object _newValue;
 33   
 34  154 public PropertyChangeImpl(String componentPath, String propertyName, Object newValue)
 35    {
 36  154 Defense.notNull(propertyName, "propertyName");
 37   
 38    // TODO: This breaks some tests, but those tests are wrong.
 39    // Defense.notNull(newValue, "newValue");
 40   
 41  154 _componentPath = componentPath;
 42  154 _propertyName = propertyName;
 43  154 _newValue = newValue;
 44    }
 45   
 46    /**
 47    * The path to the component on the page, or null if the property is a property of the page.
 48    */
 49   
 50  84 public String getComponentPath()
 51    {
 52  84 return _componentPath;
 53    }
 54   
 55    /**
 56    * The new value for the property, which may be null.
 57    */
 58   
 59  84 public Object getNewValue()
 60    {
 61  84 return _newValue;
 62    }
 63   
 64    /**
 65    * The name of the property that changed.
 66    */
 67   
 68  84 public String getPropertyName()
 69    {
 70  84 return _propertyName;
 71    }
 72   
 73  2 public String toString()
 74    {
 75  2 ToStringBuilder builder = new ToStringBuilder(this);
 76   
 77  2 builder.append("componentPath", _componentPath);
 78  2 builder.append("propertyName", _propertyName);
 79  2 builder.append("newValue", _newValue);
 80   
 81  2 return builder.toString();
 82    }
 83   
 84  62 public boolean equals(Object object)
 85    {
 86  62 if (this == object)
 87  2 return true;
 88   
 89  60 if (object == null || object.getClass() != this.getClass())
 90  2 return false;
 91   
 92  58 PropertyChangeImpl other = (PropertyChangeImpl) object;
 93   
 94  58 return same(_componentPath, other._componentPath)
 95    && same(_propertyName, other._propertyName) && same(_newValue, other._newValue);
 96    }
 97   
 98  170 private boolean same(Object o1, Object o2)
 99    {
 100  170 return o1 == o2 || (o1 != null && o1.equals(o2));
 101    }
 102    }