View Javadoc

1   package ch.busyboxes.agoo.service.impl.adapter;
2   
3   import java.util.LinkedList;
4   import java.util.List;
5   
6   import ch.busyboxes.agoo.controller.model.WebWatchedFile;
7   import ch.busyboxes.agoo.model.WatchedFile;
8   
9   /**
10   * Converter between WatchedFile and WebWatchedFile
11   * 
12   * @author julien@busyboxes.ch
13   */
14  public class WatchedFileAdapter {
15  
16  	/**
17  	 * Convert a WatchedFile into a WebWatchedFile
18  	 * 
19  	 * @param watchedFile the WatchedFile object
20  	 * @return the converted WebWatchedFile
21  	 */
22  	public static WebWatchedFile adaptWatchedFile(WatchedFile watchedFile) {
23  		WebWatchedFile webWatchedFile = new WebWatchedFile();
24  		webWatchedFile.setId(watchedFile.getId());
25  		webWatchedFile.setFilename(watchedFile.getFilename());
26  		webWatchedFile.setLastCheck(watchedFile.getLastCheck());
27  		webWatchedFile.setMd5Hash(watchedFile.getMd5Hash());
28  		webWatchedFile.setWatchedFileState(watchedFile.getWatchedFileState());
29  		return webWatchedFile;
30  	}
31  	
32  	/**
33  	 * Converts a list of watched files to a list of web watched files
34  	 * 
35  	 * @param watchedFiles the list of watched files
36  	 * @return the list of web watched files
37  	 */
38  	public static List<WebWatchedFile> adaptWatchedFiles(List<WatchedFile> watchedFiles) {
39  		List<WebWatchedFile> webWatchedFiles = new LinkedList<WebWatchedFile>();
40  		for (WatchedFile watchedFile : watchedFiles) {
41  			webWatchedFiles.add(adaptWatchedFile(watchedFile));
42  		}
43  		return webWatchedFiles;
44  	}
45  
46  	
47  }