Skip to content

Commit

Permalink
#343 Parameterize logger call
Browse files Browse the repository at this point in the history
and clean up surrounding method
  • Loading branch information
ascheman committed Sep 19, 2024
1 parent 2a8f2cb commit ac5d4fa
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,35 @@ private static boolean isCase(Class<? extends Checker> caseValue, Class<? extend
return false;
}

public static Checker createSingleChecker(final Class<? extends Checker> checkerClass, final Configuration pConfig) {
Checker checker;
public static Checker createSingleChecker(final Class<? extends Checker> checkerClass,
final Configuration configuration) {
if (null == checkerClass) {
throw new UnknownCheckerException("Checker Class must not be 'null'");
}

Checker checker;
// switch over all possible Checker classes
// in case of new Checkers, this has to be adapted,
// as Checker constructors will differ in minor details!

// clearly violates the open-close principle

if (isCase(BrokenCrossReferencesChecker.class, checkerClass)) {
checker = new BrokenCrossReferencesChecker(pConfig);
checker = new BrokenCrossReferencesChecker(configuration);
} else if (isCase(BrokenHttpLinksChecker.class, checkerClass)) {
checker = new BrokenHttpLinksChecker(pConfig);
checker = new BrokenHttpLinksChecker(configuration);
} else if (isCase(DuplicateIdChecker.class, checkerClass)) {
checker = new DuplicateIdChecker(pConfig);
checker = new DuplicateIdChecker(configuration);
} else if (isCase(ImageMapChecker.class, checkerClass)) {
checker = new ImageMapChecker(pConfig);
checker = new ImageMapChecker(configuration);
} else if (isCase(MissingAltInImageTagsChecker.class, checkerClass)) {
checker = new MissingAltInImageTagsChecker(pConfig);
checker = new MissingAltInImageTagsChecker(configuration);
} else if (isCase(MissingImageFilesChecker.class, checkerClass)) {
checker = new MissingImageFilesChecker(pConfig);
checker = new MissingImageFilesChecker(configuration);
} else if (isCase(MissingLocalResourcesChecker.class, checkerClass)) {
checker = new MissingLocalResourcesChecker(pConfig);
checker = new MissingLocalResourcesChecker(configuration);
} else {
logger.warn("unknown Checker " + checkerClass.toString());
logger.error("unknown Checker {}", checkerClass);
throw new UnknownCheckerException(checkerClass.toString());
}

Expand Down

0 comments on commit ac5d4fa

Please sign in to comment.