1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Eclipse Public License, Version 1.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.eclipse.org/org/documents/epl-v10.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ide.eclipse.adt.internal.refactoring.changes; 18 19 /** 20 * This class describes the text changes of android layout files 21 * 22 */ 23 public class AndroidLayoutChangeDescription { 24 25 private String mClassName; 26 27 private String mNewName; 28 29 private int mType; 30 31 /** 32 * the view layout 33 */ 34 public static final int VIEW_TYPE = 0; 35 36 /** 37 * the standalone layout 38 */ 39 public static final int STANDALONE_TYPE = 1; 40 41 /** 42 * Creates a new <code>AndroidDocumentChange</code> 43 * 44 * @param className the old layout class name 45 * @param newName the new layout class name 46 * @param type the layout type; valid value are VIEW_TYPE and STANDALONE_TYPE 47 */ 48 public AndroidLayoutChangeDescription(String className, String newName, int type) { 49 this.mClassName = className; 50 this.mNewName = newName; 51 this.mType = type; 52 } 53 54 /** 55 * @return the old class name 56 */ 57 public String getClassName() { 58 return mClassName; 59 } 60 61 /** 62 * @return the new class name 63 */ 64 public String getNewName() { 65 return mNewName; 66 } 67 68 /** 69 * @return the layout type 70 */ 71 public int getType() { 72 return mType; 73 } 74 75 /** 76 * @return true if the layout is standalone 77 */ 78 public boolean isStandalone() { 79 return mType == STANDALONE_TYPE; 80 } 81 82 @Override 83 public int hashCode() { 84 final int prime = 31; 85 int result = 1; 86 result = prime * result + ((mClassName == null) ? 0 : mClassName.hashCode()); 87 result = prime * result + ((mNewName == null) ? 0 : mNewName.hashCode()); 88 result = prime * result + mType; 89 return result; 90 } 91 92 @Override 93 public boolean equals(Object obj) { 94 if (this == obj) 95 return true; 96 if (obj == null) 97 return false; 98 if (getClass() != obj.getClass()) 99 return false; 100 AndroidLayoutChangeDescription other = (AndroidLayoutChangeDescription) obj; 101 if (mClassName == null) { 102 if (other.mClassName != null) 103 return false; 104 } else if (!mClassName.equals(other.mClassName)) 105 return false; 106 if (mNewName == null) { 107 if (other.mNewName != null) 108 return false; 109 } else if (!mNewName.equals(other.mNewName)) 110 return false; 111 if (mType != other.mType) 112 return false; 113 return true; 114 } 115 116 @Override 117 public String toString() { 118 return "AndroidLayoutChangeDescription [className=" + mClassName + ", newName=" + mNewName 119 + ", type=" + mType + "]"; 120 } 121 122 } 123