org.entityfs.util.dirdiff
Class EntitySizeAndFileModificationTimeMatchStrategy

java.lang.Object
  extended by org.entityfs.util.dirdiff.EntitySizeAndModificationTimeMatchStrategy
      extended by org.entityfs.util.dirdiff.EntitySizeAndFileModificationTimeMatchStrategy
All Implemented Interfaces:
EntityMatchStrategy

public class EntitySizeAndFileModificationTimeMatchStrategy
extends EntitySizeAndModificationTimeMatchStrategy

This EntityMatchStrategy matches entities with the same names and types. If the entities are files, their sizes must be equal and the modification time of the target file must be equal to or later than the modification time of the master entity.

Files with dissimilar contents that happen to have the same size are matched by this filter.

Since objects of this class contains no mutable internal state, the singleton instance INSTANCE may be used instead of instantiating this class.

Since:
1.0
Author:
Karl Gustafsson

Field Summary
static EntitySizeAndFileModificationTimeMatchStrategy INSTANCE
           
 
Constructor Summary
EntitySizeAndFileModificationTimeMatchStrategy()
           
 
Method Summary
 String getMatchingEntityName(EntityView ev, Map<String,? extends EntityView> m)
          Check if there is a matching entity in the supplied entity map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final EntitySizeAndFileModificationTimeMatchStrategy INSTANCE
Constructor Detail

EntitySizeAndFileModificationTimeMatchStrategy

public EntitySizeAndFileModificationTimeMatchStrategy()
Method Detail

getMatchingEntityName

public String getMatchingEntityName(EntityView ev,
                                    Map<String,? extends EntityView> m)
Description copied from interface: EntityMatchStrategy
Check if there is a matching entity in the supplied entity map. If there is one, return its name.

When this method is called, the master directory (ev's parent) is locked for reading, and the target directory (the parent of all entities in the map) is locked for writing.

Specified by:
getMatchingEntityName in interface EntityMatchStrategy
Overrides:
getMatchingEntityName in class EntitySizeAndModificationTimeMatchStrategy
Parameters:
ev - The entity to search for a matching entity to.
m - A map containing all remaining entities in the target directory, keyed under their names. Remaining entities are all of the entities in the target directory that has not been matched by a previous invocation of this method.
Returns:
The name of the matching entity, or null if no entity in the target directory matched ev. The returned name, if non-null, must be the same as one of the keys in the map.