/**
  * Looking for dependencies in attributes
  *
  * @param allClasses
  */
 public void alterAttributeList(ArrayList<RealClass> allClasses) {
   if (this.classAttributes == null || this.classAttributes.size() == 0) {
     return;
   }
   ClassRelation relation = null;
   ClassAttribute classAttribute = null;
   ArrayList<Integer> removeMethodIndex = new ArrayList<Integer>();
   ArrayList<Integer> removeAttributeIndex = new ArrayList<Integer>();
   for (int i = 0; i < classAttributes.size(); i++) {
     classAttribute = classAttributes.get(i);
     String type = classAttribute.getAttributeType();
     // Do nothing when type is primitive type or String type
     // Add relation into classRelations and delete this attribute when type contains Collection<>
     Pattern pattern = Pattern.compile("Collection<.*>", Pattern.CASE_INSENSITIVE);
     Matcher m = pattern.matcher(type);
     if (m.matches()) {
       int beginIndex = type.indexOf('<'); // Get the type out of string
       int endIndex = type.indexOf('>');
       String tempType = type.substring(beginIndex + 1, endIndex);
       // under the requirement, no need for checking if type is in the class list
       relation = new ClassRelation(this.getClassName(), tempType, RelatinType.OneToMany);
       this.classRelations.add(relation);
       // Delete the attribute
       removeAttributeIndex.add(i);
       relation = null;
     }
     // Arrays: [] --> (*)
     else if (type.contains("[]")) {
       int openIndex = type.indexOf('[');
       type = type.substring(0, openIndex);
       type += "(*)";
       classAttribute.setAttributeType(type);
     }
     // Other situation(simple declaration)
     else if (classList.contains(type)) {
       relation = new ClassRelation(this.getClassName(), type, RelatinType.OneToOne);
       this.classRelations.add(relation);
       // Attributes can not be deleted during the loop
       removeAttributeIndex.add(i);
       relation = null;
     }
     // If Getter and Setter of a attribute are found
     // This attribute should become public
     // Getter and Setter should be deleted
     else if (classAttribute.getAccessModifier() == "-") {
       String getter = "get" + classAttribute.getAttributeName();
       String setter = "set" + classAttribute.getAttributeName();
       // Find the indexes of getter and setter in method list
       int getterIndex = -1;
       int setterIndex = -1;
       for (int index = 0; index < this.classMethods.size(); index++) {
         if (this.classMethods.get(index).getMethodName().toLowerCase().contentEquals(getter)) {
           getterIndex = index;
         } else if (this.classMethods
             .get(index)
             .getMethodName()
             .toLowerCase()
             .contentEquals(setter)) {
           setterIndex = index;
         }
       }
       // Can not delete method within this loop
       // Mark the indexes, delete them after loop is end
       if (getterIndex != -1 && setterIndex != -1) {
         removeMethodIndex.add(getterIndex);
         removeMethodIndex.add(setterIndex);
         classAttribute.setAccessModifier("+");
       }
     }
     // If it's protected, remove it
     else if (classAttribute.getAccessModifier() == "#") {
       removeAttributeIndex.add(i);
     }
   }
   // Delete those attributes
   for (int j = removeAttributeIndex.size() - 1; j >= 0; j--) {
     classAttributes.remove((int) removeAttributeIndex.get(j));
   }
   // Delete the getter and setter
   for (int j = removeMethodIndex.size() - 1; j >= 0; j--) {
     classMethods.remove((int) removeMethodIndex.get(j));
   }
 }