我的大部分课程都有这个警告,不知道为什么会这样。这发生在公共普通类和具有私有构造函数的最终类上,有些根本没有构造函数。我尝试将我的私有类方法更改为受保护,但没有帮助。
有关如何关闭它的任何建议吗?
这是一个类示例
public final class PlanBenefitManagerAssembler {
private static final Logger LOGGER = Logger.getLogger(PlanBenefitManagerAssembler.class);
/**
* No Instance of the this class is allowed.
*/
private PlanBenefitManagerAssembler() {
}
public static List<BenefitDecisionDetailsBean> assembleBenefitDecisionDetailsBean(
List<BenefitDetails> benefitDecisionDetailsList, int relationalSequenceNumber) {
LOGGER.debug("Enter assembleBenefitDecisionDetailsBean");
List<BenefitDecisionDetailsBean> benefitDecisionDetailsBeanList = new ArrayList<BenefitDecisionDetailsBean>();
for (BenefitDetails benefitDecisionDetails : benefitDecisionDetailsList) {
BenefitDecisionDetailsBean benefitDecisionDetailsBean = new BenefitDecisionDetailsBean();
benefitDecisionDetailsBean.setBenefitTypeCode(benefitDecisionDetails.getBenefitTypeCode());
benefitDecisionDetailsBean.setRelationSequenceNumber(relationalSequenceNumber);
benefitDecisionDetailsBean.setBenefitStatusDescription(
benefitDecisionDetails.getBenefitStatusDescription());
benefitDecisionDetailsBean.setBenefitStatusCode(benefitDecisionDetails.getBenefitStatusCode());
benefitDecisionDetailsBean.setBenefitUnderwritingStatusCode(
benefitDecisionDetails.getBenefitUnderwritingStatusCode());
benefitDecisionDetailsBean.setBenefitUnderwritingStatusDescription(
benefitDecisionDetails.getBenefitUnderwritingStatusDescription());
benefitDecisionDetailsBean.setBenefitChangeReasonCode(
String.valueOf(benefitDecisionDetails.getBenefitChangeReasonCode()));
benefitDecisionDetailsBean.setBenefitChangeReasonDescription(
benefitDecisionDetails.getBenefitChangeReasonDescription());
benefitDecisionDetailsBean.setComponentNumber(benefitDecisionDetails.getBenefitNumber());
benefitDecisionDetailsBean.setBenefitVisible(benefitDecisionDetails.isExplicitBenefitDecisionRequired());
benefitDecisionDetailsBean.setModelChanged(false);
// * Set BenefitLoading and BenefitExclusion
List<ExclusionDetailsBean> exclusionDetailsBeanList =
PlanBenefitManagerAssembler.assembleExclusionDetailsList(benefitDecisionDetails
.getBenefitExclusionsDetailsList().getBenefitExclusionsDetailsList());
List<LoadingDetailsBean> loadingDetailsBeanList =
PlanBenefitManagerAssembler.assembleLoadingDetailsList(benefitDecisionDetails
.getBenefitLoadingsDetailsList().getBenefitLoadingsDetailsList());
benefitDecisionDetailsBean.setExclusionDetailsBeanList(exclusionDetailsBeanList);
benefitDecisionDetailsBean.setLoadingDetailsBeanList(loadingDetailsBeanList);
benefitDecisionDetailsBeanList.add(benefitDecisionDetailsBean);
}
LOGGER.debug("Exit assembleBenefitDecisionDetailsBean");
return benefitDecisionDetailsBeanList;
}
}
答案 0 :(得分:3)
您可以随时关闭警告,但它们通常出于某种原因:)
我很确定这会解决你的问题。
答案 1 :(得分:3)
当Checkstyle发出警告时,警告文本应包含一个短规则名称,以便您查找正在触发的确切规则。例如,“DesignForExtension”。
根据规则名称,您可以在Checkstyle文档中查找更多详细信息:http://checkstyle.sourceforge.net/availablechecks.html
发布触发规则的完整详情,有人可能会提供帮助。
答案 2 :(得分:1)
在sourceforge上,它表示AbstractClassName规则使用以下正则表达式:
^Abstract.*$|^.*Factory$
这会导致标记名称以“Abstract”开头或以“Factory”结尾的类。我得到了'Abstract ..'的一部分,但为什么所有'..Factory'类都应该是抽象的?有时我创建使用依赖项来完成工作的工厂,所以我需要一个实例来注入。
然而,这并不能解释您的情况。我尝试了你的示例类,没有得到任何Checkstyle警告(我正在使用Eclipse Checkstyle插件版本5.3.0.201012121300)。
您确定要获取此类的AbstractClassName警告吗?您使用的是哪个版本的Checkstyle?