private static List<String> linesToWrite(String path,Global global,List<Attribute> attributes,Class<?> aClass) throws NoSuchFieldException, IOException {
  String[] classIdentifier=new String[]{"class","{",aClass.getSimpleName()};
  boolean classFound=false;
  verifyAttributes(aClass,attributes);
  HashMap<String,String> attributeTypes=getTypes(aClass,attributes);
  List<String> linesToWrite=new ArrayList<String>();
  List<String> lines=readFile(new File(path));
  if (!isEmpty(attributes)) {
    lines=addImport(lines,aClass,JMap.class);
    lines=addTargetClassesImport(lines,attributes,aClass);
  }
  if (!isNull(global))   lines=addImport(lines,aClass,JGlobalMap.class);
  if (containtsAccessors(global,attributes)) {
    lines=addImport(lines,aClass,JMapAccessor.class);
    lines=addImport(lines,aClass,JMapAccessors.class);
  }
  for (  String line : lines) {
    if (containsAll(line,classIdentifier)) {
      if (global != null)       linesToWrite.add(toAnnotation(global));
      classFound=true;
    }
    if (classFound && !isEmpty(attributes)) {
      Attribute remove=null;
      for (      Attribute attribute : attributes) {
        String name=attribute.getName();
        String type=attributeTypes.get(name);
        if (containsAll(line,name,type) && !line.contains("{")) {
          linesToWrite.add(toAnnotation(attribute));
          remove=attribute;
        }
      }
      if (remove != null)       attributes.remove(remove);
    }
    linesToWrite.add(line);
  }
  return linesToWrite;
}

private static List < String > linesToWrite ( String path , Global global , List < Attribute > attributes , Class < ? > aClass ) throws NoSuchFieldException , IOException { String [ ] classIdentifier = new String [ ] { "class" , "{" , aClass . getSimpleName ( ) } ; boolean classFound = false ; verifyAttributes ( aClass , attributes ) ; HashMap < String , String > attributeTypes = getTypes ( aClass , attributes ) ; List < String > linesToWrite = new ArrayList < String > ( ) ; List < String > lines = readFile ( new File ( path ) ) ; if ( ! isEmpty ( attributes ) ) { lines = addImport ( lines , aClass , JMap . class ) ; lines = addTargetClassesImport ( lines , attributes , aClass ) ; } if ( ! isNull ( global ) ) lines = addImport ( lines , aClass , JGlobalMap . class ) ; if ( containtsAccessors ( global , attributes ) ) { lines = addImport ( lines , aClass , JMapAccessor . class ) ; lines = addImport ( lines , aClass , JMapAccessors . class ) ; } for ( String line : lines ) { if ( containsAll ( line , classIdentifier ) ) { if ( global != null ) linesToWrite . add ( toAnnotation ( global ) ) ; classFound = true ; } if ( classFound && ! isEmpty ( attributes ) ) { Attribute remove = null ; for ( Attribute attribute : attributes ) { String name = attribute . getName ( ) ; String type = attributeTypes . get ( name ) ; if ( containsAll ( line , name , type ) && ! line . contains ( "{" ) ) { linesToWrite . add ( toAnnotation ( attribute ) ) ; remove = attribute ; } } if ( remove != null ) attributes . remove ( remove ) ; } linesToWrite . add ( line ) ; } return linesToWrite ; }
this method returns the lines of the file enriched with annotations .
