add a 'reverse' property (default to false) to RequiresDialectFeature annotation
This commit is contained in:
parent
fc2051af71
commit
bbac6ed571
|
@ -63,7 +63,7 @@ public class DialectFilterExtension implements ExecutionCondition {
|
||||||
if ( !effectiveRequiresDialects.isEmpty() ) {
|
if ( !effectiveRequiresDialects.isEmpty() ) {
|
||||||
StringBuilder requiredDialects = new StringBuilder( );
|
StringBuilder requiredDialects = new StringBuilder( );
|
||||||
for ( RequiresDialect requiresDialect : effectiveRequiresDialects ) {
|
for ( RequiresDialect requiresDialect : effectiveRequiresDialects ) {
|
||||||
requiredDialects.append(requiresDialect.value() );
|
requiredDialects.append( requiresDialect.value() );
|
||||||
requiredDialects.append( " " );
|
requiredDialects.append( " " );
|
||||||
if ( requiresDialect.matchSubTypes() ) {
|
if ( requiresDialect.matchSubTypes() ) {
|
||||||
if ( requiresDialect.value().isInstance( dialect ) ) {
|
if ( requiresDialect.value().isInstance( dialect ) ) {
|
||||||
|
@ -116,12 +116,15 @@ public class DialectFilterExtension implements ExecutionCondition {
|
||||||
try {
|
try {
|
||||||
final DialectFeatureCheck dialectFeatureCheck = effectiveRequiresDialectFeature.feature()
|
final DialectFeatureCheck dialectFeatureCheck = effectiveRequiresDialectFeature.feature()
|
||||||
.newInstance();
|
.newInstance();
|
||||||
if ( !dialectFeatureCheck.apply( getDialect( context ) ) ) {
|
final boolean applicable = dialectFeatureCheck.apply( getDialect( context ) );
|
||||||
|
final boolean reverse = effectiveRequiresDialectFeature.reverse();
|
||||||
|
if ( applicable ^ reverse ) {
|
||||||
return ConditionEvaluationResult.disabled(
|
return ConditionEvaluationResult.disabled(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
Locale.ROOT,
|
||||||
"Failed @RequiresDialectFeature [%s]",
|
"Failed @RequiresDialectFeature [feature: %s, reverse: %s]",
|
||||||
effectiveRequiresDialectFeature.feature()
|
effectiveRequiresDialectFeature.feature(),
|
||||||
|
effectiveRequiresDialectFeature.reverse()
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,7 +133,7 @@ public class DialectFilterExtension implements ExecutionCondition {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ConditionEvaluationResult.enabled( "Passed all @SkipForDialects" );
|
return ConditionEvaluationResult.enabled( "Passed all @RequiresDialect(s), @SkipForDialect(s) and @RequiresDialectFeature(group)" );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dialect getDialect(ExtensionContext context) {
|
private Dialect getDialect(ExtensionContext context) {
|
||||||
|
|
|
@ -142,12 +142,6 @@ abstract public class DialectFeatureChecks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DoesRepeatableReadNotCauseReadersToBlockWritersCheck implements DialectFeatureCheck {
|
|
||||||
public boolean apply(Dialect dialect) {
|
|
||||||
return ! dialect.doesRepeatableReadCauseReadersToBlockWriters();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class SupportsExistsInSelectCheck implements DialectFeatureCheck {
|
public static class SupportsExistsInSelectCheck implements DialectFeatureCheck {
|
||||||
public boolean apply(Dialect dialect) {
|
public boolean apply(Dialect dialect) {
|
||||||
return dialect.supportsExistsInSelect();
|
return dialect.supportsExistsInSelect();
|
||||||
|
@ -185,12 +179,6 @@ abstract public class DialectFeatureChecks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DoesNotSupportRowValueConstructorSyntax implements DialectFeatureCheck {
|
|
||||||
public boolean apply(Dialect dialect) {
|
|
||||||
return dialect.supportsRowValueConstructorSyntax() == false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DoesNotSupportFollowOnLocking implements DialectFeatureCheck {
|
public static class DoesNotSupportFollowOnLocking implements DialectFeatureCheck {
|
||||||
public boolean apply(Dialect dialect) {
|
public boolean apply(Dialect dialect) {
|
||||||
return !dialect.useFollowOnLocking( null, null );
|
return !dialect.useFollowOnLocking( null, null );
|
||||||
|
|
|
@ -33,6 +33,11 @@ public @interface RequiresDialectFeature {
|
||||||
*/
|
*/
|
||||||
Class<? extends DialectFeatureCheck> feature();
|
Class<? extends DialectFeatureCheck> feature();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether the decision of {@link #feature()} is reversed
|
||||||
|
*/
|
||||||
|
boolean reverse() default false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comment describing the reason why the feature is required.
|
* Comment describing the reason why the feature is required.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue