1 package org.robolectric.res; 2 3 public class ResourcePath { 4 private final Class<?> rClass; 5 private final FsFile resourceBase; 6 private final FsFile assetsDir; 7 private final Class<?> internalRClass; 8 ResourcePath(Class<?> rClass, FsFile resourceBase, FsFile assetsDir)9 public ResourcePath(Class<?> rClass, FsFile resourceBase, FsFile assetsDir) { 10 this(rClass, resourceBase, assetsDir, null); 11 } 12 ResourcePath(Class<?> rClass, FsFile resourceBase, FsFile assetsDir, Class<?> internalRClass)13 public ResourcePath(Class<?> rClass, FsFile resourceBase, FsFile assetsDir, Class<?> internalRClass) { 14 this.rClass = rClass; 15 this.resourceBase = resourceBase; 16 this.assetsDir = assetsDir; 17 this.internalRClass = internalRClass; 18 } 19 getRClass()20 public Class<?> getRClass() { 21 return rClass; 22 } 23 getResourceBase()24 public FsFile getResourceBase() { 25 return resourceBase; 26 } 27 hasResources()28 public boolean hasResources() { 29 return getResourceBase() != null && getResourceBase().exists(); 30 } 31 getAssetsDir()32 public FsFile getAssetsDir() { 33 return assetsDir; 34 } 35 getInternalRClass()36 public Class<?> getInternalRClass() { 37 return internalRClass; 38 } 39 40 @Override toString()41 public String toString() { 42 return "ResourcePath { path=" + resourceBase + "}"; 43 } 44 45 @Override equals(Object o)46 public boolean equals(Object o) { 47 if (this == o) return true; 48 if (o == null || getClass() != o.getClass()) return false; 49 50 ResourcePath that = (ResourcePath) o; 51 52 if (rClass != null ? !rClass.equals(that.rClass) : that.rClass != null) return false; 53 if (resourceBase != null ? !resourceBase.equals(that.resourceBase) : that.resourceBase != null) return false; 54 if (assetsDir != null ? !assetsDir.equals(that.assetsDir) : that.assetsDir != null) return false; 55 return internalRClass != null ? internalRClass.equals(that.internalRClass) : that.internalRClass == null; 56 57 } 58 59 @Override hashCode()60 public int hashCode() { 61 int result = rClass != null ? rClass.hashCode() : 0; 62 result = 31 * result + (resourceBase != null ? resourceBase.hashCode() : 0); 63 result = 31 * result + (assetsDir != null ? assetsDir.hashCode() : 0); 64 result = 31 * result + (internalRClass != null ? internalRClass.hashCode() : 0); 65 return result; 66 } 67 } 68