com.android.ide.common.repository
Class ResourceVisibilityLookup

java.lang.Object
  extended by com.android.ide.common.repository.ResourceVisibilityLookup

public abstract class ResourceVisibilityLookup
extends java.lang.Object

Class which provides information about whether Android resources for a given library are public or private.


Nested Class Summary
static class ResourceVisibilityLookup.Provider
          Provider which keeps a set of ResourceVisibilityLookup instances around for repeated queries, including from different libraries that may share dependencies
 
Field Summary
static ResourceVisibilityLookup NONE
           
 
Constructor Summary
ResourceVisibilityLookup()
           
 
Method Summary
static ResourceVisibilityLookup create(com.android.builder.model.AndroidLibrary library)
          Creates a ResourceVisibilityLookup for a given library.
static ResourceVisibilityLookup create(java.util.List<com.android.builder.model.AndroidLibrary> libraries, ResourceVisibilityLookup.Provider provider)
          Creates a ResourceVisibilityLookup for the set of libraries.
abstract  com.android.builder.model.AndroidLibrary getPrivateIn(com.android.resources.ResourceType type, java.lang.String name)
          For a private resource, return the AndroidLibrary that the resource was defined as private in
abstract  boolean isEmpty()
          Returns true if this repository does not declare any resources to be private
abstract  boolean isPrivate(com.android.resources.ResourceType type, java.lang.String name)
          Returns true if the given resource is private
 boolean isPrivate(ResourceUrl url)
          Returns true if the given resource is private
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final ResourceVisibilityLookup NONE
Constructor Detail

ResourceVisibilityLookup

public ResourceVisibilityLookup()
Method Detail

isPrivate

public abstract boolean isPrivate(@NonNull
                                  com.android.resources.ResourceType type,
                                  @NonNull
                                  java.lang.String name)
Returns true if the given resource is private

Parameters:
type - the type of the resource
name - the resource field name of the resource (in other words, for style Theme:Variant.Cls the name would be Theme_Variant_Cls
Returns:
true if the given resource is private

isPrivate

public boolean isPrivate(@NonNull
                         ResourceUrl url)
Returns true if the given resource is private

Parameters:
url - the resource URL
Returns:
true if the given resource is private

getPrivateIn

@Nullable
public abstract com.android.builder.model.AndroidLibrary getPrivateIn(@NonNull
                                                                               com.android.resources.ResourceType type,
                                                                               @NonNull
                                                                               java.lang.String name)
For a private resource, return the AndroidLibrary that the resource was defined as private in

Parameters:
type - the type of the resource
name - the name of the resource
Returns:
the library which defines the resource as private

isEmpty

public abstract boolean isEmpty()
Returns true if this repository does not declare any resources to be private


create

@NonNull
public static ResourceVisibilityLookup create(@NonNull
                                                      com.android.builder.model.AndroidLibrary library)
Creates a ResourceVisibilityLookup for a given library.

NOTE: The ResourceVisibilityLookup.Provider class can be used to share/cache ResourceVisibilityLookup instances, e.g. when you have library1 and library2 each referencing libraryBase, the ResourceVisibilityLookup.Provider will ensure that a the libraryBase data is shared.

Parameters:
library - the library
Returns:
a corresponding ResourceVisibilityLookup

create

@NonNull
public static ResourceVisibilityLookup create(@NonNull
                                                      java.util.List<com.android.builder.model.AndroidLibrary> libraries,
                                                      @Nullable
                                                      ResourceVisibilityLookup.Provider provider)
Creates a ResourceVisibilityLookup for the set of libraries.

NOTE: The ResourceVisibilityLookup.Provider class can be used to share/cache ResourceVisibilityLookup instances, e.g. when you have library1 and library2 each referencing libraryBase, the ResourceVisibilityLookup.Provider will ensure that a the libraryBase data is shared.

Parameters:
libraries - the list of libraries
provider - an optional manager instance for caching of individual libraries, if any
Returns:
a corresponding ResourceVisibilityLookup