/** * Returns the enum by its name as it appears in the XML or the R class. * @param name name of the resource * @return the matching {@link ResourceType} or <code>null</code> if no match was found. */ public static ResourceType getEnum(String name) { for (ResourceType rType : values()) { if (rType.mName.equals(name)) { return rType; } else if (rType.mAlternateXmlNames != null) { // if there are alternate Xml Names, we test those too for (String alternate : rType.mAlternateXmlNames) { if (alternate.equals(name)) { return rType; } } } } return null; }
/** * Returns an array with all the names defined by this enum. */ public static String[] getNames() { ResourceType[] values = values(); String[] names = new String[values.length]; for (int i = values.length - 1; i >= 0; --i) { names[i] = values[i].getName(); } return names; }
/** * Returns an array with all the names defined by this enum. */ public static String[] getNames() { ResourceType[] values = values(); String[] names = new String[values.length]; for (int i = values.length - 1; i >= 0; --i) { names[i] = values[i].getName(); } return names; }
/** * Makes the maps safe by replacing the current list values with unmodifiable lists. */ private static void makeSafe() { for (ResourceType type : ResourceType.values()) { List<ResourceFolderType> list = mTypeToFolderMap.get(type); if (list != null) { // replace with a unmodifiable list wrapper around the current list. mTypeToFolderMap.put(type, Collections.unmodifiableList(list)); } } for (ResourceFolderType folder : ResourceFolderType.values()) { List<ResourceType> list = mFolderToTypeMap.get(folder); if (list != null) { // replace with a unmodifiable list wrapper around the current list. mFolderToTypeMap.put(folder, Collections.unmodifiableList(list)); } } } }
/** * Makes the maps safe by replacing the current list values with unmodifiable lists. */ private static void makeSafe() { for (ResourceType type : ResourceType.values()) { List<ResourceFolderType> list = mTypeToFolderMap.get(type); if (list != null) { // replace with a unmodifiable list wrapper around the current list. mTypeToFolderMap.put(type, Collections.unmodifiableList(list)); } } for (ResourceFolderType folder : ResourceFolderType.values()) { List<ResourceType> list = mFolderToTypeMap.get(folder); if (list != null) { // replace with a unmodifiable list wrapper around the current list. mFolderToTypeMap.put(folder, Collections.unmodifiableList(list)); } } } }
return Collections.singletonList(type); } else if (typeString.equals("any")) { // @AnyRes ResourceType[] types = ResourceType.values(); List<ResourceType> result = Lists.newArrayListWithExpectedSize( types.length);