From 84c72ec3202ed9c2dff66ba3f5136a38af4ce95c Mon Sep 17 00:00:00 2001 From: rnveach Date: Tue, 10 Nov 2015 12:42:30 -0500 Subject: [PATCH] Issue #2451: removed excess hierarchy from ImportOrderCheck --- config/suppressions.xml | 2 +- .../checks/imports/ImportOrderCheck.java | 33 ++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/config/suppressions.xml b/config/suppressions.xml index 668a78347..3e57c3205 100644 --- a/config/suppressions.xml +++ b/config/suppressions.xml @@ -109,7 +109,7 @@ - + Aleksey Nesterenko */ public class ImportOrderCheck - extends AbstractOptionCheck { + extends Check { /** * A key is pointing to the warning message text in "messages.properties" @@ -217,11 +220,31 @@ public class ImportOrderCheck /** Whether static imports should be sorted alphabetically or not. */ private boolean sortStaticImportsAlphabetically; + /** The policy to enforce. */ + private ImportOrderOption option = ImportOrderOption.UNDER; + /** - * Groups static imports under each group. + * Set the option to enforce. + * @param optionStr string to decode option from + * @throws ConversionException if unable to decode */ - public ImportOrderCheck() { - super(ImportOrderOption.UNDER, ImportOrderOption.class); + public void setOption(String optionStr) { + try { + option = ImportOrderOption.valueOf(optionStr.trim().toUpperCase(Locale.ENGLISH)); + } + catch (IllegalArgumentException iae) { + throw new ConversionException("unable to parse " + optionStr, iae); + } + } + + /** + * Gets option set. + * @return the {@code option} set + */ + public ImportOrderOption getAbstractOption() { + // WARNING!! Do not rename this method to getOption(). It breaks + // BeanUtils, which will silently not call setOption. Very annoying! + return option; } /**