## org.springframework.test.context
Class ContextConfigurationAttributes

    java.lang.Object
      org.springframework.test.context.ContextConfigurationAttributes

    public class ContextConfigurationAttributes

extends Object

`ContextConfigurationAttributes` encapsulates the context configuration attributes declared on a test class via `@ContextConfiguration`.

Since:
  3.1
Author:
  Sam Brannen
See Also:
  `ContextConfiguration`, `SmartContextLoader.processContextConfiguration(ContextConfigurationAttributes)`, `MergedContextConfiguration`

Constructor Summary
`ContextConfigurationAttributes(Class<?> declaringClass, ContextConfiguration contextConfiguration)` Construct a new `ContextConfigurationAttributes` instance for the supplied `@ContextConfiguration` annotation and the `test class` that declared it.
`ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes, boolean inheritLocations, Class<? extends ContextLoader> contextLoaderClass)` Construct a new `ContextConfigurationAttributes` instance for the `test class` that declared the `@ContextConfiguration` annotation and its corresponding attributes.

Method Summary
`Class<?>[]` `getClasses()` Get the configuration classes that were declared via `@ContextConfiguration`.
`Class<? extends ContextLoader>` `getContextLoaderClass()` Get the `ContextLoader` class that was declared via `@ContextConfiguration`.
`Class<?>` `getDeclaringClass()` Get the `class` that declared the `@ContextConfiguration` annotation.
`String[]` `getLocations()` Get the resource locations that were declared via `@ContextConfiguration`.
`boolean` `hasClasses()` Determine if this `ContextConfigurationAttributes` instance has class-based resources.
`boolean` `hasLocations()` Determine if this `ContextConfigurationAttributes` instance has path-based resource locations.
`boolean` `hasResources()` Determine if this `ContextConfigurationAttributes` instance has either path-based resource locations or class-based resources.
`boolean` `isInheritLocations()` Get the `inheritLocations` flag that was declared via `@ContextConfiguration`.
`void` `setClasses(Class<?>[] classes)` Set the processed configuration classes, effectively overriding the original value declared via `@ContextConfiguration`.
`void` `setLocations(String[] locations)` Set the processed resource locations, effectively overriding the original value declared via `@ContextConfiguration`.
`String` `toString()` Provide a String representation of the context configuration attributes and declaring class.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### ContextConfigurationAttributes

    public ContextConfigurationAttributes(Class<?> declaringClass,
                                          ContextConfiguration contextConfiguration)

  Construct a new `ContextConfigurationAttributes` instance for the supplied `@ContextConfiguration` annotation and the `test class` that declared it.

  Parameters:
    `declaringClass` - the test class that declared `@ContextConfiguration`
    `contextConfiguration` - the annotation from which to retrieve the attributes

### ContextConfigurationAttributes

    public ContextConfigurationAttributes(Class<?> declaringClass,
                                          String[] locations,
                                          Class<?>[] classes,
                                          boolean inheritLocations,
                                          Class<? extends ContextLoader> contextLoaderClass)

  Construct a new `ContextConfigurationAttributes` instance for the `test class` that declared the `@ContextConfiguration` annotation and its corresponding attributes.

  Parameters:
    `declaringClass` - the test class that declared `@ContextConfiguration`
    `locations` - the resource locations declared via `@ContextConfiguration`
    `classes` - the configuration classes declared via `@ContextConfiguration`
    `inheritLocations` - the `inheritLocations` flag declared via `@ContextConfiguration`
    `contextLoaderClass` - the `ContextLoader` class declared via `@ContextConfiguration`
  Throws:
    `IllegalArgumentException` - if the `declaringClass` or `contextLoaderClass` is `null`, or if the `locations` and `classes` are both non-empty

Method Detail

### getDeclaringClass

    public Class<?> getDeclaringClass()

  Get the `class` that declared the `@ContextConfiguration` annotation.

  Returns:
    the declaring class; never `null`

### getLocations

    public String[] getLocations()

  Get the resource locations that were declared via `@ContextConfiguration`.

  Note: this is a mutable property. The returned value may therefore represent a processed value that does not match the original value declared via `@ContextConfiguration`.

  Returns:
    the resource locations; potentially `null` or empty
  See Also:
    `ContextConfiguration.value()`, `ContextConfiguration.locations()`, `#setLocations()`

### setLocations

    public void setLocations(String[] locations)

  Set the processed resource locations, effectively overriding the original value declared via `@ContextConfiguration`.

  See Also:
    `getLocations()`

### getClasses

    public Class<?>[] getClasses()

  Get the configuration classes that were declared via `@ContextConfiguration`.

  Note: this is a mutable property. The returned value may therefore represent a processed value that does not match the original value declared via `@ContextConfiguration`.

  Returns:
    the configuration classes; potentially `null` or empty
  See Also:
    `ContextConfiguration.classes()`, `#setClasses()`

### setClasses

    public void setClasses(Class<?>[] classes)

  Set the processed configuration classes, effectively overriding the original value declared via `@ContextConfiguration`.

  See Also:
    `getClasses()`

### hasLocations

    public boolean hasLocations()

  Determine if this `ContextConfigurationAttributes` instance has path-based resource locations.

  Returns:
    `true` if the `locations` array is not empty
  See Also:
    `hasResources()`, `hasClasses()`

### hasClasses

    public boolean hasClasses()

  Determine if this `ContextConfigurationAttributes` instance has class-based resources.

  Returns:
    `true` if the `classes` array is not empty
  See Also:
    `hasResources()`, `hasLocations()`

### hasResources

    public boolean hasResources()

  Determine if this `ContextConfigurationAttributes` instance has either path-based resource locations or class-based resources.

  Returns:
    `true` if either the `locations` or the `classes` array is not empty
  See Also:
    `hasLocations()`, `hasClasses()`

### isInheritLocations

    public boolean isInheritLocations()

  Get the `inheritLocations` flag that was declared via `@ContextConfiguration`.

  Returns:
    the `inheritLocations` flag
  See Also:
    `ContextConfiguration.inheritLocations()`

### getContextLoaderClass

    public Class<? extends ContextLoader> getContextLoaderClass()

  Get the `ContextLoader` class that was declared via `@ContextConfiguration`.

  Returns:
    the `ContextLoader` class
  See Also:
    `ContextConfiguration.loader()`

### toString

    public String toString()

  Provide a String representation of the context configuration attributes and declaring class.

  Overrides:
    `toString` in class `Object`