|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2023 the original author or authors. |
| 2 | + * Copyright 2012-2024 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.
|
|
50 | 50 | *
|
51 | 51 | * @author Stephane Nicoll
|
52 | 52 | * @author Scott Frederick
|
| 53 | + * @author Moritz Halbritter |
53 | 54 | */
|
54 | 55 | class MetadataGenerationEnvironment {
|
55 | 56 |
|
56 | 57 | private static final String NULLABLE_ANNOTATION = "org.springframework.lang.Nullable";
|
57 | 58 |
|
58 |
| - private static final Set<String> TYPE_EXCLUDES; |
59 |
| - static { |
60 |
| - Set<String> excludes = new HashSet<>(); |
61 |
| - excludes.add("com.zaxxer.hikari.IConnectionCustomizer"); |
62 |
| - excludes.add("groovy.lang.MetaClass"); |
63 |
| - excludes.add("groovy.text.markup.MarkupTemplateEngine"); |
64 |
| - excludes.add("java.io.Writer"); |
65 |
| - excludes.add("java.io.PrintWriter"); |
66 |
| - excludes.add("java.lang.ClassLoader"); |
67 |
| - excludes.add("java.util.concurrent.ThreadFactory"); |
68 |
| - excludes.add("jakarta.jms.XAConnectionFactory"); |
69 |
| - excludes.add("javax.sql.DataSource"); |
70 |
| - excludes.add("javax.sql.XADataSource"); |
71 |
| - excludes.add("org.apache.tomcat.jdbc.pool.PoolConfiguration"); |
72 |
| - excludes.add("org.apache.tomcat.jdbc.pool.Validator"); |
73 |
| - excludes.add("org.flywaydb.core.api.callback.FlywayCallback"); |
74 |
| - excludes.add("org.flywaydb.core.api.resolver.MigrationResolver"); |
75 |
| - TYPE_EXCLUDES = Collections.unmodifiableSet(excludes); |
76 |
| - } |
| 59 | + private static final Set<String> TYPE_EXCLUDES = Set.of("com.zaxxer.hikari.IConnectionCustomizer", |
| 60 | + "groovy.lang.MetaClass", "groovy.text.markup.MarkupTemplateEngine", "java.io.Writer", "java.io.PrintWriter", |
| 61 | + "java.lang.ClassLoader", "java.util.concurrent.ThreadFactory", "jakarta.jms.XAConnectionFactory", |
| 62 | + "javax.sql.DataSource", "javax.sql.XADataSource", "org.apache.tomcat.jdbc.pool.PoolConfiguration", |
| 63 | + "org.apache.tomcat.jdbc.pool.Validator", "org.flywaydb.core.api.callback.FlywayCallback", |
| 64 | + "org.flywaydb.core.api.resolver.MigrationResolver"); |
| 65 | + |
| 66 | + private static final Set<String> DEPRECATION_EXCLUDES = Set.of( |
| 67 | + "org.apache.commons.dbcp2.BasicDataSource#getPassword", |
| 68 | + "org.apache.commons.dbcp2.BasicDataSource#getUsername"); |
77 | 69 |
|
78 | 70 | private final TypeUtils typeUtils;
|
79 | 71 |
|
@@ -162,6 +154,13 @@ boolean isExcluded(TypeMirror type) {
|
162 | 154 | }
|
163 | 155 |
|
164 | 156 | boolean isDeprecated(Element element) {
|
| 157 | + if (element == null) { |
| 158 | + return false; |
| 159 | + } |
| 160 | + String elementName = element.getEnclosingElement() + "#" + element.getSimpleName(); |
| 161 | + if (DEPRECATION_EXCLUDES.contains(elementName)) { |
| 162 | + return false; |
| 163 | + } |
165 | 164 | if (isElementDeprecated(element)) {
|
166 | 165 | return true;
|
167 | 166 | }
|
|
0 commit comments