Skip to content

Commit af74f15

Browse files
committed
Simplify name and alias annotation processing
1 parent e3ced8b commit af74f15

36 files changed

+93
-615
lines changed

log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/Named.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@
1616
*/
1717
package org.apache.logging.log4j.core.test.junit;
1818

19-
import static java.util.Optional.ofNullable;
20-
import static org.apache.logging.log4j.util.Strings.trimToNull;
21-
2219
import java.lang.annotation.Documented;
2320
import java.lang.annotation.ElementType;
2421
import java.lang.annotation.Retention;
2522
import java.lang.annotation.RetentionPolicy;
2623
import java.lang.annotation.Target;
27-
import java.util.Optional;
28-
import org.apache.logging.log4j.plugins.name.AnnotatedElementNameProvider;
29-
import org.apache.logging.log4j.plugins.name.NameProvider;
24+
import org.apache.logging.log4j.plugins.NameProvider;
3025

3126
/**
3227
* Specifies the name of an {@link org.apache.logging.log4j.core.Appender} to inject into JUnit 5 tests from the specified
@@ -38,17 +33,10 @@
3833
@Retention(RetentionPolicy.RUNTIME)
3934
@Target(ElementType.PARAMETER)
4035
@Documented
41-
@NameProvider(Named.Provider.class)
36+
@NameProvider
4237
public @interface Named {
4338
/**
4439
* Specifies the name of the configuration item to inject. If blank, uses the name of the annotated parameter.
4540
*/
4641
String value() default "";
47-
48-
class Provider implements AnnotatedElementNameProvider<Named> {
49-
@Override
50-
public Optional<String> getSpecifiedName(final Named annotation) {
51-
return ofNullable(trimToNull(annotation.value()));
52-
}
53-
}
5442
}

log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginAliases.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
import java.lang.annotation.Retention;
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
24-
import org.apache.logging.log4j.core.config.plugins.util.PluginAliasesProvider;
25-
import org.apache.logging.log4j.plugins.name.AliasesProvider;
24+
import org.apache.logging.log4j.plugins.AliasesProvider;
2625

2726
/**
2827
* Identifies a list of aliases for a Plugin, PluginAttribute, or PluginBuilderAttribute.
@@ -31,7 +30,7 @@
3130
@Documented
3231
@Retention(RetentionPolicy.RUNTIME)
3332
@Target({ElementType.PARAMETER, ElementType.TYPE, ElementType.FIELD})
34-
@AliasesProvider(PluginAliasesProvider.class)
33+
@AliasesProvider
3534
@Deprecated(since = "3.0", forRemoval = true)
3635
@SuppressWarnings("removal")
3736
public @interface PluginAliases {

log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginAttribute.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
import java.lang.annotation.Retention;
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
24-
import org.apache.logging.log4j.core.config.plugins.util.PluginAttributeNameProvider;
24+
import org.apache.logging.log4j.plugins.NameProvider;
2525
import org.apache.logging.log4j.plugins.QualifierType;
26-
import org.apache.logging.log4j.plugins.name.NameProvider;
2726
import org.apache.logging.log4j.util.Strings;
2827

2928
/**
@@ -37,7 +36,7 @@
3736
@Documented
3837
@Retention(RetentionPolicy.RUNTIME)
3938
@Target({ElementType.PARAMETER, ElementType.FIELD})
40-
@NameProvider(PluginAttributeNameProvider.class)
39+
@NameProvider
4140
@QualifierType
4241
@Deprecated(since = "3.0", forRemoval = true)
4342
@SuppressWarnings("removal")

log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginBuilderAttribute.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
import java.lang.annotation.Retention;
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
24-
import org.apache.logging.log4j.core.config.plugins.util.PluginBuilderAttributeNameProvider;
24+
import org.apache.logging.log4j.plugins.NameProvider;
2525
import org.apache.logging.log4j.plugins.QualifierType;
26-
import org.apache.logging.log4j.plugins.name.NameProvider;
2726
import org.apache.logging.log4j.util.Strings;
2827

2928
/**
@@ -33,7 +32,7 @@
3332
@Documented
3433
@Retention(RetentionPolicy.RUNTIME)
3534
@Target({ElementType.PARAMETER, ElementType.FIELD})
36-
@NameProvider(PluginBuilderAttributeNameProvider.class)
35+
@NameProvider
3736
@QualifierType
3837
@Deprecated(since = "3.0", forRemoval = true)
3938
@SuppressWarnings("removal")

log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginElement.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
import java.lang.annotation.Retention;
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
24-
import org.apache.logging.log4j.core.config.plugins.util.PluginElementNameProvider;
24+
import org.apache.logging.log4j.plugins.NameProvider;
2525
import org.apache.logging.log4j.plugins.QualifierType;
26-
import org.apache.logging.log4j.plugins.name.NameProvider;
2726

2827
/**
2928
* Identifies a parameter as a Plugin and corresponds with an XML element (or equivalent) in configuration files.
@@ -32,7 +31,7 @@
3231
@Documented
3332
@Retention(RetentionPolicy.RUNTIME)
3433
@Target({ElementType.PARAMETER, ElementType.FIELD})
35-
@NameProvider(PluginElementNameProvider.class)
34+
@NameProvider
3635
@QualifierType
3736
@Deprecated(since = "3.0", forRemoval = true)
3837
@SuppressWarnings("removal")

log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginValue.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
import java.lang.annotation.Retention;
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
24-
import org.apache.logging.log4j.core.config.plugins.util.PluginValueNameProvider;
24+
import org.apache.logging.log4j.plugins.NameProvider;
2525
import org.apache.logging.log4j.plugins.QualifierType;
26-
import org.apache.logging.log4j.plugins.name.NameProvider;
2726

2827
/**
2928
* Identifies a parameter as a value. These correspond with property values generally, but are meant as values to be
@@ -35,7 +34,7 @@
3534
@Documented
3635
@Retention(RetentionPolicy.RUNTIME)
3736
@Target({ElementType.PARAMETER, ElementType.FIELD})
38-
@NameProvider(PluginValueNameProvider.class)
37+
@NameProvider
3938
@QualifierType
4039
@Deprecated(since = "3.0", forRemoval = true)
4140
@SuppressWarnings("removal")

log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginAliasesProvider.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginAttributeNameProvider.java

Lines changed: 0 additions & 33 deletions
This file was deleted.

log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginBuilderAttributeNameProvider.java

Lines changed: 0 additions & 33 deletions
This file was deleted.

log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginElementNameProvider.java

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)