Files
alfresco-community-repo/source/java/org/alfresco/repo/content/caching/Key.java
Alan Davis 91eb2644ad Merged 5.2.N (5.2.1) to HEAD (5.2)
125781 rmunteanu: Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
      125603 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
         125484 slanglois: MNT-16155 Update source headers - remove old Copyrights from Java and JSP dource files


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@127808 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2016-06-03 16:40:56 +00:00

65 lines
1.7 KiB
Java

package org.alfresco.repo.content.caching;
import java.io.File;
import java.io.Serializable;
/**
* Multipurpose key so that data can be cached either by content URL or cache file path.
*
* @author Matt Ward
*/
public class Key implements Serializable
{
private static final long serialVersionUID = 1L;
private enum Type { CONTENT_URL, CACHE_FILE_PATH };
private final Type type;
private final String value;
private Key(Type type, String value)
{
this.type = type;
this.value = value;
}
public static Key forUrl(String url)
{
return new Key(Type.CONTENT_URL, url);
}
public static Key forCacheFile(String path)
{
return new Key(Type.CACHE_FILE_PATH, path);
}
public static Key forCacheFile(File file)
{
return forCacheFile(file.getAbsolutePath());
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((this.type == null) ? 0 : this.type.hashCode());
result = prime * result + ((this.value == null) ? 0 : this.value.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
Key other = (Key) obj;
if (this.type != other.type) return false;
if (this.value == null)
{
if (other.value != null) return false;
}
else if (!this.value.equals(other.value)) return false;
return true;
}
}