Polishing.
Simplify PersistenceProvider by removing PresenceDetector interface. Refine presence detection to make present field final. Add warning suppressions as we know that we duplicate code (similar code) and that ANTLR doesn't generate methods with nullable annotations. See #3170 Original pull request: #3176
This commit is contained in:
@@ -55,7 +55,7 @@ import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
* @author Greg Turnquist
|
||||
* @author Yuriy Tsarkov
|
||||
*/
|
||||
public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor, QueryComment, PresenceDetector {
|
||||
public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor, QueryComment {
|
||||
|
||||
/**
|
||||
* Hibernate persistence provider.
|
||||
@@ -204,7 +204,7 @@ public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor, Quer
|
||||
private final Iterable<String> entityManagerClassNames;
|
||||
private final Iterable<String> metamodelClassNames;
|
||||
|
||||
private boolean present;
|
||||
private final boolean present;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PersistenceProvider}.
|
||||
@@ -218,12 +218,16 @@ public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor, Quer
|
||||
this.entityManagerClassNames = entityManagerClassNames;
|
||||
this.metamodelClassNames = metamodelClassNames;
|
||||
|
||||
this.present = false;
|
||||
entityManagerClassNames.forEach(entityManagerClassName -> {
|
||||
boolean present = false;
|
||||
for (String entityManagerClassName : entityManagerClassNames) {
|
||||
|
||||
if (ClassUtils.isPresent(entityManagerClassName, PersistenceProvider.class.getClassLoader())) {
|
||||
this.present = true;
|
||||
present = true;
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.present = present;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,7 +344,6 @@ public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor, Quer
|
||||
: value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPresent() {
|
||||
return this.present;
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
|
||||
*/
|
||||
package org.springframework.data.jpa.provider;
|
||||
|
||||
/**
|
||||
* Define operations needed to detect the presence of a given JPA provider.
|
||||
*
|
||||
* @author Greg Turnquist
|
||||
* @since 3.2
|
||||
*/
|
||||
interface PresenceDetector {
|
||||
boolean isPresent();
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import java.util.List;
|
||||
* @author Greg Turnquist
|
||||
* @since 3.2
|
||||
*/
|
||||
@SuppressWarnings({ "ConstantConditions", "DuplicatedCode" })
|
||||
class EqlQueryRenderer extends EqlBaseVisitor<List<JpaQueryParsingToken>> {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.List;
|
||||
* @author Greg Turnquist
|
||||
* @since 3.1
|
||||
*/
|
||||
@SuppressWarnings({ "ConstantConditions", "DuplicatedCode" })
|
||||
class HqlQueryRenderer extends HqlBaseVisitor<List<JpaQueryParsingToken>> {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.List;
|
||||
* @author Greg Turnquist
|
||||
* @since 3.1
|
||||
*/
|
||||
@SuppressWarnings({ "ConstantConditions", "DuplicatedCode" })
|
||||
class JpqlQueryRenderer extends JpqlBaseVisitor<List<JpaQueryParsingToken>> {
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user