1 /* 2 * Copyright (C) 2005-2015 Schlichtherle IT Services. 3 * All rights reserved. Use is subject to license terms. 4 */ 5 package net.java.truevfs.kernel.spec; 6 7 import java.io.Serializable; 8 import java.util.Comparator; 9 10 /** 11 * Compares {@linkplain FsController file system controllers} in reverse order 12 * of the 13 * {@linkplain FsMountPoint#toHierarchicalUri() hierarchical URI} 14 * of the {@linkplain FsModel#getMountPoint() mount point} of their 15 * {@linkplain FsController#getModel() file system model}. 16 * When applied to a list of file system controllers for 17 * {@linkplain FsController#sync sync()}ing, this ordering ensures that any 18 * archive file system gets {@code sync()}ed before their parent file system so 19 * that all file systems reflect all changes once the list has been completely 20 * processed. 21 * 22 * @author Christian Schlichtherle 23 */ 24 public class FsControllerComparator 25 implements Comparator<FsController>, Serializable { 26 27 private static final long serialVersionUID = 0L; 28 29 @Override 30 public int compare(FsController o1, FsController o2) { 31 return o2.getModel().getMountPoint().toHierarchicalUri().compareTo( 32 o1.getModel().getMountPoint().toHierarchicalUri()); 33 } 34 }