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 ;
@@ -622,7 +623,7 @@ public SourceClass asSourceClass(String className) throws IOException {
622
623
623
624
624
625
@ SuppressWarnings ("serial" )
625
- private static class ImportStack extends Stack <ConfigurationClass > implements ImportRegistry {
626
+ private static class ImportStack extends ArrayDeque <ConfigurationClass > implements ImportRegistry {
626
627
627
628
private final MultiValueMap <String , AnnotationMetadata > imports = new LinkedMultiValueMap <String , AnnotationMetadata >();
628
629
@@ -647,23 +648,6 @@ public AnnotationMetadata getImportingClassFor(String importedClass) {
647
648
return (!CollectionUtils .isEmpty (list ) ? list .get (list .size () - 1 ) : null );
648
649
}
649
650
650
- /**
651
- * Simplified contains() implementation that tests to see if any {@link ConfigurationClass}
652
- * exists within this stack that has the same name as <var>elem</var>. Elem must be of
653
- * type ConfigurationClass.
654
- */
655
- @ Override
656
- public boolean contains (Object elem ) {
657
- ConfigurationClass configClass = (ConfigurationClass ) elem ;
658
- Comparator <ConfigurationClass > comparator = new Comparator <ConfigurationClass >() {
659
- @ Override
660
- public int compare (ConfigurationClass first , ConfigurationClass second ) {
661
- return (first .getMetadata ().getClassName ().equals (second .getMetadata ().getClassName ()) ? 0 : 1 );
662
- }
663
- };
664
- return (Collections .binarySearch (this , configClass , comparator ) != -1 );
665
- }
666
-
667
651
/**
668
652
* Given a stack containing (in order)
669
653
* <ul>
@@ -883,7 +867,7 @@ public String toString() {
883
867
*/
884
868
private static class CircularImportProblem extends Problem {
885
869
886
- public CircularImportProblem (ConfigurationClass attemptedImport , Stack <ConfigurationClass > importStack ) {
870
+ public CircularImportProblem (ConfigurationClass attemptedImport , Deque <ConfigurationClass > importStack ) {
887
871
super (String .format ("A circular @Import has been detected: " +
888
872
"Illegal attempt by @Configuration class '%s' to import class '%s' as '%s' is " +
889
873
"already present in the current import stack %s" , importStack .peek ().getSimpleName (),
0 commit comments