Skip to content

Commit

Permalink
Refactor ShadowDataSourceMappingsFinderFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Nov 3, 2024
1 parent 3977d2f commit d447eb5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public final class HintShadowAlgorithmDeterminer {
* @return is shadow or not
*/
public static boolean isShadow(final HintShadowAlgorithm<Comparable<?>> shadowAlgorithm, final ShadowDetermineCondition shadowCondition, final ShadowRule shadowRule, final boolean useShadow) {
PreciseHintShadowValue<Comparable<?>> shadowValue = createNoteShadowValues(shadowCondition, useShadow);
PreciseHintShadowValue<Comparable<?>> shadowValue = createHintShadowValues(shadowCondition, useShadow);
return shadowAlgorithm.isShadow(shadowRule.getAllShadowTableNames(), shadowValue);
}

private static PreciseHintShadowValue<Comparable<?>> createNoteShadowValues(final ShadowDetermineCondition shadowDetermineCondition, final boolean useShadow) {
private static PreciseHintShadowValue<Comparable<?>> createHintShadowValues(final ShadowDetermineCondition shadowDetermineCondition, final boolean useShadow) {
ShadowOperationType shadowOperationType = shadowDetermineCondition.getShadowOperationType();
String tableName = shadowDetermineCondition.getTableName();
return new PreciseHintShadowValue<>(tableName, shadowOperationType, useShadow);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public Map<String, String> find(final ShadowRule rule) {
if (!hintValueContext.isShadow()) {
return Collections.emptyMap();
}
if (isMatchAnyNoteShadowAlgorithms(rule, new ShadowDetermineCondition("", ShadowOperationType.HINT_MATCH))) {
if (isMatchAnyHintShadowAlgorithms(rule, new ShadowDetermineCondition("", ShadowOperationType.HINT_MATCH))) {
return rule.getAllShadowDataSourceMappings();
}
return Collections.emptyMap();
}

private boolean isMatchAnyNoteShadowAlgorithms(final ShadowRule rule, final ShadowDetermineCondition shadowCondition) {
private boolean isMatchAnyHintShadowAlgorithms(final ShadowRule rule, final ShadowDetermineCondition shadowCondition) {
return rule.getAllHintShadowAlgorithms().stream().anyMatch(each -> HintShadowAlgorithmDeterminer.isShadow(each, shadowCondition, rule, hintValueContext.isShadow()));
}
}

0 comments on commit d447eb5

Please sign in to comment.