小编Ste*_*ike的帖子

如果条件布尔表达式,则简化

if-condition我的代码中有这个:

if (a||a&&!b){
// do some stuff
}
Run Code Online (Sandbox Code Playgroud)

从我的那些初始值junit test:

boolean a=true, b = true;
Run Code Online (Sandbox Code Playgroud)

我后来认识到这个陈述可以简化为:

if (a&&b)
Run Code Online (Sandbox Code Playgroud)

变绿了: Assert.assertTrue(a||a&&!b == a&&b);

我现在的问题.有没有方法,工具,功能,图书馆等来检查boolean expression是否有简化?

谢谢你的帮助?

java boolean-logic if-statement boolean-expression

2
推荐指数
1
解决办法
3018
查看次数

getDeclaredConstructors0(boolean) - 在调试模式下tomcat启动期间行不可用

我的spring托管tomcat应用程序遇到了一些麻烦.有一个UserDao负责一些用户数据库操作.如果我启动tomcat,我收到此消息:

Thread [pool-2-thread-1] (Class load: UserDao)  
Class<T>.getDeclaredConstructors0(boolean) line: not available [native method]  
    Class<T>.privateGetDeclaredConstructors(boolean) line: not available    
    Class<T>.getDeclaredConstructors() line: not available  
    AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(Class<?>, String) line: 229 
    DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).determineConstructorsFromBeanPostProcessors(Class, String) line: 962 
    DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBeanInstance(String, RootBeanDefinition, Object[]) line: 935   
    DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).doCreateBean(String, RootBeanDefinition, Object[]) line: 485 
    DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBean(String, RootBeanDefinition, Object[]) line: 456   
    AbstractBeanFactory$1.getObject() line: 294 
    DefaultListableBeanFactory(DefaultSingletonBeanRegistry).getSingleton(String, ObjectFactory) line: 225  
    DefaultListableBeanFactory(AbstractBeanFactory).doGetBean(String, Class<T>, Object[], boolean) line: 291    
    DefaultListableBeanFactory(AbstractBeanFactory).getBean(String) line: 193   
    DefaultListableBeanFactory.preInstantiateSingletons() line: 605 
    XmlWebApplicationContext(AbstractApplicationContext).finishBeanFactoryInitialization(ConfigurableListableBeanFactory) line: 925 
    XmlWebApplicationContext(AbstractApplicationContext).refresh() line: 472    
    ContextLoaderListener(ContextLoader).configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext, ServletContext) line: 383  
    ContextLoaderListener(ContextLoader).initWebApplicationContext(ServletContext) line: 283    
    ContextLoaderListener.contextInitialized(ServletContextEvent) line: 111 
    StandardContext.listenerStart() line: …
Run Code Online (Sandbox Code Playgroud)

java spring tomcat dao debug-mode

2
推荐指数
1
解决办法
3459
查看次数

按下“返回”键时如何使编辑文本失去焦点?

当我按 'Return' 键时EditText,它会通过变大来创建新行。EditText按下“返回”键时如何失去焦点?换句话说,如何在按下“返回”时让键盘消失?

android return lost-focus android-edittext

1
推荐指数
1
解决办法
6096
查看次数

通用接口方法和实现类

我有这个接口方法Animal interface:

<T extends Animal> boolean isEqual(T pAnimal);
Run Code Online (Sandbox Code Playgroud)

现在我遇到了实施问题.我有两个类DogCat.两个班extends来自Animal.我想覆盖该方法,但具体实现:

@Override
public boolean isEqual(Dog pDog) {
  // do some stuff.
  return true;
}
Run Code Online (Sandbox Code Playgroud)

这导致编译错误

must override or implement a supertype method
Run Code Online (Sandbox Code Playgroud)

我如何定义接口,以便不必typecast在我的具体实现类中创建?

提前致谢

斯特凡

java generics

1
推荐指数
1
解决办法
48
查看次数

重构方法头参数顺序

我在Eclipse IDE中遇到了重构问题.

我有这个接口方法:

List<String> evaluateAllPoi(boolean pIsVerified, List<String> pAllNames, List<String> pAllComment);
Run Code Online (Sandbox Code Playgroud)

该方法对Junit具有较高的测试覆盖率(至少90次测试).

我想boolean通过重构将第一个参数移动到方法签名的末尾,所以我得到:

List<String> evaluateAllPoi(List<String> pAllNames, List<String> pAllComment,boolean pIsVerified);
Run Code Online (Sandbox Code Playgroud)

我很确定Eclipse提供了一种轻松实现这一目标的可能性,而无需手动更改每个调用,但目前我没有找到/看到它.

你能给我一个暗示吗?

java eclipse refactoring method-signature

1
推荐指数
1
解决办法
215
查看次数

IllegalArgumentException:期望块内的条件语句无效

Expectations在测试用例中编写的块有问题:

new Expectations() {
      {
        mFindHandlerMock.findAll((Model) any, (Set<Id>) any, false);
        if (!pWithRealData) {
          result = Collections.emptySet();
        } else {
          result = pAllData;
        }
        times = 1;

        Deencapsulation.invoke(mDb, "readSqlQuery", withAny(String.class));
        result = "select * from realdata";
        times = 1;
      }
    };
Run Code Online (Sandbox Code Playgroud)

测试用例崩溃:

java.lang.IllegalArgumentException: Invalid conditional statement inside expectation block
Run Code Online (Sandbox Code Playgroud)

正好在这里:

if (!pWithRealData) {
Run Code Online (Sandbox Code Playgroud)

它只是一个简单的boolean就是false在这种情况下.

我绝对不知道为什么exception会发生这种情况.我已经用谷歌搜索过但没有找到任何帮助.

你可以帮帮我吗?

java junit jmockit expectations illegalargumentexception

1
推荐指数
1
解决办法
1199
查看次数

Spring Autowiring无法正常工作

希望你能帮助我...我有两个项目common-lib和common-dao.每个项目都有自己的spring配置文件.

如果我运行以下测试类,则自动装配工作正常,所有属性都由spring生成.

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/cmn-dao-spring.xml"})
public class ScoreDaoTest extends TestCase {

@Autowired
private ScoreDao mScoreDao;

@Autowired
private ScoreCreator mScoreCreator;

@Autowired
private QuestionCreator mQuestionCreator;

@Override
protected void setUp() throws Exception {
    super.setUp();
}

@Test
public void testLoadAllScore() throws Exception {
    List<Score> lAllScore = mScoreDao.loadAllScore(0, 0);
    Assert.assertTrue(lAllScore.isEmpty());
}

@Test
public void testSaveScore() throws Exception {
    Question question = mQuestionCreator.createQuestion(49954854L, new Date(), "Wer bist Du?", "Jörg", "Anja", "Stefan", "Willi", 3, true, false, 1, "DE", "DE_QZ");
    Assert.assertNotNull(question);
    mScoreDao.saveScore(mScoreCreator.createScore(-1L, null, "Stefan", 1033, 27, "Wuhuuuu", question));
    List<Score> …
Run Code Online (Sandbox Code Playgroud)

java spring autowired

0
推荐指数
1
解决办法
2689
查看次数

使用作为clob一部分的substr进行分组

我需要你的帮助以下sql:

SELECT 
  substr(nd.nne_def,4,3) as bzn
FROM 
    core_def.nne_def nd
group by substr(nd.nne_def,4,4);
Run Code Online (Sandbox Code Playgroud)

我收到了错误:

ORA-00932: 00932. 00000 -  "inconsistent datatypes: expected - got CLOB"
Run Code Online (Sandbox Code Playgroud)

我需要sql只是为了分析而不是生产代码.

如何通过属于CLOB的子字符串进行分组?

谢谢你的帮助.

斯特凡

sql oracle group-by clob

0
推荐指数
1
解决办法
557
查看次数