refactor: Optimsed codes.
Move private and protected methods or fields to the last of java files.
This commit is contained in:
+13
-13
@@ -65,19 +65,6 @@ import org.springframework.context.annotation.Bean;
|
||||
@AutoConfigureAfter(value = GuidAutoConfiguration.class)
|
||||
public class AuthzeroTokenResolverAutoConfiguration {
|
||||
|
||||
/**
|
||||
* The GuidCreator instance to be used for generating JWT IDs (JTI).
|
||||
*/
|
||||
private final GuidCreator<?> jtiCreator;
|
||||
|
||||
/**
|
||||
* The {@code SimpleJwtProperties} instance containing the configuration
|
||||
* properties for Simple JWT.
|
||||
*/
|
||||
private final SimpleJwtProperties simpleJwtProperties;
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code SimpleJwtAutoConfiguration} instance with the
|
||||
* provided SimpleJwtProperties.
|
||||
@@ -112,4 +99,17 @@ public class AuthzeroTokenResolverAutoConfiguration {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The GuidCreator instance to be used for generating JWT IDs (JTI).
|
||||
*/
|
||||
private final GuidCreator<?> jtiCreator;
|
||||
|
||||
/**
|
||||
* The {@code SimpleJwtProperties} instance containing the configuration
|
||||
* properties for Simple JWT.
|
||||
*/
|
||||
private final SimpleJwtProperties simpleJwtProperties;
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
}
|
||||
|
||||
+5
@@ -39,6 +39,11 @@ import java.util.UUID;
|
||||
@AutoConfiguration
|
||||
public class GuidAutoConfiguration {
|
||||
|
||||
/**
|
||||
* Create a default {@code jtiCreator} with UUID.
|
||||
*
|
||||
* @return UUID creator
|
||||
*/
|
||||
@Bean(name = "jtiCreator")
|
||||
@Conditional(GuidCreatorCondition.class)
|
||||
public GuidCreator<?> jtiCreator() {
|
||||
|
||||
+11
-11
@@ -65,17 +65,6 @@ import org.springframework.context.annotation.Bean;
|
||||
@AutoConfigureAfter(value = GuidAutoConfiguration.class)
|
||||
public class JjwtTokenResolverAutoConfiguration {
|
||||
|
||||
/**
|
||||
* The GuidCreator instance to be used for generating JWT IDs (JTI).
|
||||
*/
|
||||
private final GuidCreator<?> jtiCreator;
|
||||
|
||||
/**
|
||||
* The {@code SimpleJwtProperties} instance containing the configuration
|
||||
* properties for Simple JWT.
|
||||
*/
|
||||
private final SimpleJwtProperties simpleJwtProperties;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code SimpleJwtAutoConfiguration} instance with the
|
||||
* provided SimpleJwtProperties.
|
||||
@@ -107,4 +96,15 @@ public class JjwtTokenResolverAutoConfiguration {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The GuidCreator instance to be used for generating JWT IDs (JTI).
|
||||
*/
|
||||
private final GuidCreator<?> jtiCreator;
|
||||
|
||||
/**
|
||||
* The {@code SimpleJwtProperties} instance containing the configuration
|
||||
* properties for Simple JWT.
|
||||
*/
|
||||
private final SimpleJwtProperties simpleJwtProperties;
|
||||
|
||||
}
|
||||
|
||||
+12
@@ -17,6 +17,18 @@ import java.util.Objects;
|
||||
*/
|
||||
@Slf4j
|
||||
public class GuidCreatorCondition implements Condition {
|
||||
|
||||
/**
|
||||
* The condition to create bean {@code jtiCreator}.
|
||||
* <p>
|
||||
* If Spring does not have a bean of type
|
||||
* {@link cn.org.codecrafters.guid.GuidCreator} named {@code jtiCreator}
|
||||
* in the application context, then create {@code jtiCreator}.
|
||||
*
|
||||
* @param context the spring application context
|
||||
* @param metadata the metadata of the {@link org.springframework.core.type.AnnotationMetadata class}
|
||||
* or {@link org.springframework.core.type.MethodMetadata method} being checked
|
||||
*/
|
||||
@Override
|
||||
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
||||
final var beanFactory = Objects.requireNonNull(context.getBeanFactory());
|
||||
|
||||
Reference in New Issue
Block a user