1
1
/*
2
- * Copyright 2002-2015 the original author or authors.
2
+ * Copyright 2002-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
18
18
19
19
import java .io .FileNotFoundException ;
20
20
import java .io .IOException ;
21
+ import java .util .ArrayDeque ;
21
22
import java .util .ArrayList ;
22
23
import java .util .Collection ;
23
24
import java .util .Collections ;
24
25
import java .util .Comparator ;
26
+ import java .util .Deque ;
25
27
import java .util .HashMap ;
26
28
import java .util .Iterator ;
27
29
import java .util .LinkedHashMap ;
30
32
import java .util .List ;
31
33
import java .util .Map ;
32
34
import java .util .Set ;
33
- import java .util .Stack ;
34
35
35
36
import org .apache .commons .logging .Log ;
36
37
import org .apache .commons .logging .LogFactory ;
@@ -625,7 +626,7 @@ public SourceClass asSourceClass(String className) throws IOException {
625
626
626
627
627
628
@ SuppressWarnings ("serial" )
628
- private static class ImportStack extends Stack <ConfigurationClass > implements ImportRegistry {
629
+ private static class ImportStack extends ArrayDeque <ConfigurationClass > implements ImportRegistry {
629
630
630
631
private final MultiValueMap <String , AnnotationMetadata > imports = new LinkedMultiValueMap <String , AnnotationMetadata >();
631
632
@@ -650,23 +651,6 @@ public AnnotationMetadata getImportingClassFor(String importedClass) {
650
651
return (!CollectionUtils .isEmpty (list ) ? list .get (list .size () - 1 ) : null );
651
652
}
652
653
653
- /**
654
- * Simplified contains() implementation that tests to see if any {@link ConfigurationClass}
655
- * exists within this stack that has the same name as <var>elem</var>. Elem must be of
656
- * type ConfigurationClass.
657
- */
658
- @ Override
659
- public boolean contains (Object elem ) {
660
- ConfigurationClass configClass = (ConfigurationClass ) elem ;
661
- Comparator <ConfigurationClass > comparator = new Comparator <ConfigurationClass >() {
662
- @ Override
663
- public int compare (ConfigurationClass first , ConfigurationClass second ) {
664
- return (first .getMetadata ().getClassName ().equals (second .getMetadata ().getClassName ()) ? 0 : 1 );
665
- }
666
- };
667
- return (Collections .binarySearch (this , configClass , comparator ) != -1 );
668
- }
669
-
670
654
/**
671
655
* Given a stack containing (in order)
672
656
* <ul>
@@ -886,7 +870,7 @@ public String toString() {
886
870
*/
887
871
private static class CircularImportProblem extends Problem {
888
872
889
- public CircularImportProblem (ConfigurationClass attemptedImport , Stack <ConfigurationClass > importStack ) {
873
+ public CircularImportProblem (ConfigurationClass attemptedImport , Deque <ConfigurationClass > importStack ) {
890
874
super (String .format ("A circular @Import has been detected: " +
891
875
"Illegal attempt by @Configuration class '%s' to import class '%s' as '%s' is " +
892
876
"already present in the current import stack %s" , importStack .peek ().getSimpleName (),
0 commit comments