Coverage Report - org.apache.tapestry.record.PropertyChangeImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
PropertyChangeImpl
0%
0/20
0%
0/18
2.286
 
 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  
 
 29  
     private String _componentPath;
 30  
 
 31  
     private String _propertyName;
 32  
 
 33  
     private Object _newValue;
 34  
 
 35  
     public PropertyChangeImpl(String componentPath, String propertyName,
 36  
             Object newValue)
 37  0
     {
 38  0
         Defense.notNull(propertyName, "propertyName");
 39  
 
 40  
         // TODO: This breaks some tests, but those tests are wrong.
 41  
         // Defense.notNull(newValue, "newValue");
 42  
 
 43  0
         _componentPath = componentPath;
 44  0
         _propertyName = propertyName;
 45  0
         _newValue = newValue;
 46  0
     }
 47  
 
 48  
     /**
 49  
      * The path to the component on the page, or null if the property is a
 50  
      * property of the page.
 51  
      */
 52  
 
 53  
     public String getComponentPath()
 54  
     {
 55  0
         return _componentPath;
 56  
     }
 57  
 
 58  
     /**
 59  
      * The new value for the property, which may be null.
 60  
      */
 61  
 
 62  
     public Object getNewValue()
 63  
     {
 64  0
         return _newValue;
 65  
     }
 66  
 
 67  
     /**
 68  
      * The name of the property that changed.
 69  
      */
 70  
 
 71  
     public String getPropertyName()
 72  
     {
 73  0
         return _propertyName;
 74  
     }
 75  
 
 76  
     public String toString()
 77  
     {
 78  0
         ToStringBuilder builder = new ToStringBuilder(this);
 79  
 
 80  0
         builder.append("componentPath", _componentPath);
 81  0
         builder.append("propertyName", _propertyName);
 82  0
         builder.append("newValue", _newValue);
 83  
 
 84  0
         return builder.toString();
 85  
     }
 86  
 
 87  
     public boolean equals(Object object)
 88  
     {
 89  0
         if (this == object) return true;
 90  
 
 91  0
         if (object == null || object.getClass() != this.getClass())
 92  0
             return false;
 93  
 
 94  0
         PropertyChangeImpl other = (PropertyChangeImpl) object;
 95  
 
 96  0
         return same(_componentPath, other._componentPath)
 97  
                 && same(_propertyName, other._propertyName)
 98  
                 && same(_newValue, other._newValue);
 99  
     }
 100  
 
 101  
     private boolean same(Object o1, Object o2)
 102  
     {
 103  0
         return o1 == o2 || (o1 != null && o1.equals(o2));
 104  
     }
 105  
 }