|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AmbiguousComponentResolutionException.java | 100% | 100% | 100% | 100% |
|
1 |
/*****************************************************************************
|
|
2 |
* Copyright (c) PicoContainer Organization. All rights reserved. *
|
|
3 |
* ------------------------------------------------------------------------- *
|
|
4 |
* The software in this package is published under the terms of the BSD *
|
|
5 |
* style license a copy of which has been included with this distribution in *
|
|
6 |
* the LICENSE.txt file. *
|
|
7 |
* *
|
|
8 |
* Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant *
|
|
9 |
*****************************************************************************/
|
|
10 |
package org.picocontainer.defaults;
|
|
11 |
|
|
12 |
import org.picocontainer.PicoIntrospectionException;
|
|
13 |
|
|
14 |
import java.util.Arrays;
|
|
15 |
|
|
16 |
/**
|
|
17 |
* Exception that is thrown as part of the introspection. Raised if a PicoContainer cannot resolve a
|
|
18 |
* type dependency because the registered {@link org.picocontainer.ComponentAdapter}s are not
|
|
19 |
* distinct.
|
|
20 |
*
|
|
21 |
* @author Paul Hammant
|
|
22 |
* @author Aslak Hellesøy
|
|
23 |
* @author Jon Tirsén
|
|
24 |
* @since 1.0
|
|
25 |
*/
|
|
26 |
public class AmbiguousComponentResolutionException extends PicoIntrospectionException { |
|
27 |
private Class ambiguousClass;
|
|
28 |
private final Object[] ambiguousComponentKeys;
|
|
29 |
|
|
30 |
/**
|
|
31 |
* Construct a new exception with the ambigous class type and the ambiguous component keys.
|
|
32 |
*
|
|
33 |
* @param ambiguousClass the unresolved dependency type
|
|
34 |
* @param componentKeys the ambiguous keys.
|
|
35 |
*/
|
|
36 | 2 |
public AmbiguousComponentResolutionException(Class ambiguousClass, Object[] componentKeys) {
|
37 | 2 |
this.ambiguousClass = ambiguousClass;
|
38 | 2 |
this.ambiguousComponentKeys = new Class[componentKeys.length]; |
39 | 2 |
for (int i = 0; i < componentKeys.length; i++) { |
40 | 4 |
ambiguousComponentKeys[i] = componentKeys[i]; |
41 |
} |
|
42 |
} |
|
43 |
|
|
44 |
/**
|
|
45 |
* @return Returns a string containing the unresolved class type and the ambiguous keys.
|
|
46 |
*/
|
|
47 | 1 |
public String getMessage() {
|
48 | 1 |
StringBuffer msg = new StringBuffer();
|
49 | 1 |
msg.append("Ambiguous ");
|
50 | 1 |
msg.append(ambiguousClass); |
51 | 1 |
msg.append(", ");
|
52 | 1 |
msg.append("resolves to multiple keys ");
|
53 | 1 |
msg.append(Arrays.asList(getAmbiguousComponentKeys())); |
54 | 1 |
return msg.toString();
|
55 |
} |
|
56 |
|
|
57 |
/**
|
|
58 |
* @return Returns the ambiguous component keys as array.
|
|
59 |
*/
|
|
60 | 2 |
public Object[] getAmbiguousComponentKeys() {
|
61 | 2 |
return ambiguousComponentKeys;
|
62 |
} |
|
63 |
} |
|
64 |
|
|