1. 问题描述
今天在写Java switch case语句的时候,有一句代码引起Eclipse黄色警告:The label NO_TRADE is never explicitly referenced。
原代码如下:
switch (tradeStatus) { case CREATE: NO_TRADE: result.setCommonStatus(CommonStatus.UNPAY); result.setActionButtons(Lists.newArrayList(getTradeButton("付款"))); break; case SHIP: result.setCommonStatus(CommonStatus.ACCEPTED); result.setActionButtons(Lists.newArrayList(getTradeButton("确认服务"))); break; case SUCCESS: result.setCommonStatus(CommonStatus.FINISH); result.setActionButtons(Lists.newArrayList(getTradeButton("评价"))); break; default: break; }
告警的是“NO_TRADE:”这行,告警的意思是次标签将永远不会被明确引用。
2. 原因分析
后来自己又看了下代码及Java switch case的语法,原因是自己错误使用了语法,这种写法在Java语法中只会匹配CREATE这一种情况,后面的NO_TRADE是永远不会考虑的。
3. 解决方法
只需要对NO_TRADE这个Label新增一个case标记即可,修改后的代码如下所示:
TradeStatus tradeStatus = TradeStatus.getByValue(searchDO.getTbMainOrderPayStatus().get(0).intValue()); switch (tradeStatus) { case CREATE: case NO_TRADE: result.setCommonStatus(CommonStatus.UNPAY); result.setActionButtons(Lists.newArrayList(getTradeButton("付款"))); break; case SHIP: result.setCommonStatus(CommonStatus.ACCEPTED); result.setActionButtons(Lists.newArrayList(getTradeButton("确认服务"))); break; case SUCCESS: result.setCommonStatus(CommonStatus.FINISH); result.setActionButtons(Lists.newArrayList(getTradeButton("评价"))); break; default: break; }
相关推荐
vue新建项目出现问题 替换这个文件
This toolbox contains programs for the multi-label classifier which explicitly exploits label dependency with Bayesian network structure.
In these simulations the SISO option is not explicitly given. This is because the SISO result for a particular type of modulation is shown in every plot for purposes of comparison. This software ...
Note that this change will have no effect if the hot_exit setting is left at its default value of true Build 3073 Release Date: 28 February 2015 See also the Forum Thread Fixed a Goto Definition ...
Another useful rule of thumb: it's typically not cost effective to inline functions with loops or switch statements (unless, in the common case, the loop or switch statement is never executed)....
If the table is a heap (in other words, it has no clustered index), the bookmark is a RID, which is an actual row locator in the form File#:Page#:Slot#. Finding Rows with a NC Index on a Heap ...
A profile is dependent upon another profile if it re-uses parts of that profile by implicitly or explicitly referencing it. Dependency is illustrated in the figure: a profile has dependencies on the ...
In particular, this is achieved by leveraging a feature-centric voting scheme to implement novel convolutional layers which explicitly exploit the sparsity encountered in the input. To this end, we ...
To avoid this warning and prepare your code for PHP 8, you should explicitly pass the `$_FILES` array to `move_uploaded_file()`, `is_uploaded_file()` and other functions dealing with uploaded files. ...
In its basic form, given a new instance, the algorithm finds the \( k \) closest instances (neighbors) in the training set and assigns a label based on the majority vote or a weighted average of the ...
The Gen 0 size is tuned by the Garbage Collector and can change during the execution of the application. At the end of a Gen 0 collection the size of the Gen 0 heap is infact 0 bytes; this counter ...
The Zen of Python, by Tim Peters Beautiful is better than ugly. ...If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!
The Zen of Python Python之禅 by Tim Peters Beautiful is better than ...If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!
a) there is a conflict when one uses the implicit palette to set wavelengths, and also defines palette states explicitly using the VsDefinePalette() function. When the explicitly set palette state ...
The purpose of this tutorial is to simulate a realistic industrial pulverized-coal furnace and compare the results with the measured data. Prerequisites This tutorial assumes that you are familiar ...
give no width suffix fasmarm will select the narrow form if it is available and encodable, and the wide form otherwise. To see how this impacts code using IT blocks examine the following example: ...
Instead, explicitly set the output handler using ob_start(). ; Using this ini directive may cause problems unless you know what script ; is doing. ; Note: You cannot use both "mb_output_handler" with...
for example - for this guideline is that you have to change the margin of some UI elements in you app to get a pixel perfect design but you heard that there is the golden rule "No custom CSS is ...
your .unity3d file is a compressed archive of all your used assets, your Unity scene files, your scripts' resulting managed DLLs, any managed DLLs from the Mono standard library your build needs, plus...
This paper describes the obstacle detection and ...explicitly abstracts each of the levels of processing. The subsystem can easily be extended by adding new sensors and validation algorithms.