org.mozilla.zest.core.v1.ZestConditional.addElse()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(88)

本文整理了Java中org.mozilla.zest.core.v1.ZestConditional.addElse()方法的一些代码示例,展示了ZestConditional.addElse()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZestConditional.addElse()方法的具体详情如下:
包路径:org.mozilla.zest.core.v1.ZestConditional
类名称:ZestConditional
方法名:addElse

ZestConditional.addElse介绍

[英]Adds an else.
[中]添加了一个else。

代码示例

代码示例来源:origin: mozilla/zest

/**
 * Adds an else.
 *
 * @param req the statement to add as else
 */
public void addElse(ZestStatement req) {
  this.addElse(this.elseStatements.size(), req);
}

代码示例来源:origin: mozilla/zest

/**
 * Moves an else.
 *
 * @param index the destination of the else statement
 * @param req the else statement to move
 */
public void moveElse(int index, ZestStatement req) {
  this.removeElse(req);
  this.addElse(index, req);
}

代码示例来源:origin: mozilla/zest

@Override
public void move(int index, ZestStatement stmt) {
  if (this.ifStatements.contains(stmt)) {
    this.removeIf(stmt);
    this.addIf(index, stmt);
  } else if (this.elseStatements.contains(stmt)) {
    this.removeElse(stmt);
    this.addElse(index, stmt);
  } else {
    throw new IllegalArgumentException("Not a direct child: " + stmt);
  }
}

代码示例来源:origin: mozilla/zest

/**
 * Method testMoveLastElse.
 *
 * @throws Exception
 */
@Test
public void testMoveLastElse() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  ZestRequest req3 = new ZestRequest();
  zc.addElse(req1);
  zc.addElse(req2);
  zc.addElse(req3);
  zc.moveElse(0, req3);
  checkOrder(new ZestStatement[] {zc, req3, req1, req2, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testRemoveMiddleElse.
 *
 * @throws Exception
 */
@Test
public void testRemoveMiddleElse() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  ZestRequest req3 = new ZestRequest();
  zc.addElse(req1);
  zc.addElse(req2);
  zc.addElse(req3);
  zc.removeElse(req2);
  checkOrder(new ZestStatement[] {zc, req1, req3, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testMoveSecondElse.
 *
 * @throws Exception
 */
@Test
public void testMoveSecondElse() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  ZestRequest req3 = new ZestRequest();
  zc.addElse(req1);
  zc.addElse(req2);
  zc.addElse(req3);
  zc.moveElse(2, req2);
  checkOrder(new ZestStatement[] {zc, req1, req3, req2, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testRemoveFirstElse.
 *
 * @throws Exception
 */
@Test
public void testRemoveFirstElse() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  ZestRequest req3 = new ZestRequest();
  zc.addElse(req1);
  zc.addElse(req2);
  zc.addElse(req3);
  zc.removeElse(req1);
  checkOrder(new ZestStatement[] {zc, req2, req3, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testMoveSecondElse.
 *
 * @throws Exception
 */
@Test
public void testMoveSecondElse() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  ZestRequest req3 = new ZestRequest();
  zc.addElse(req1);
  zc.addElse(req2);
  zc.addElse(req3);
  zc.moveElse(2, req2);
  checkOrder(new ZestStatement[] {zc, req1, req3, req2, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testMoveFirstElse.
 *
 * @throws Exception
 */
@Test
public void testMoveFirstElse() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  ZestRequest req3 = new ZestRequest();
  zc.addElse(req1);
  zc.addElse(req2);
  zc.addElse(req3);
  zc.moveElse(1, req1);
  checkOrder(new ZestStatement[] {zc, req2, req1, req3, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testMoveLastElse.
 *
 * @throws Exception
 */
@Test
public void testMoveLastElse() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  ZestRequest req3 = new ZestRequest();
  zc.addElse(req1);
  zc.addElse(req2);
  zc.addElse(req3);
  zc.moveElse(0, req3);
  checkOrder(new ZestStatement[] {zc, req3, req1, req2, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testRemoveMiddleElse.
 *
 * @throws Exception
 */
@Test
public void testRemoveMiddleElse() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  ZestRequest req3 = new ZestRequest();
  zc.addElse(req1);
  zc.addElse(req2);
  zc.addElse(req3);
  zc.removeElse(req2);
  checkOrder(new ZestStatement[] {zc, req1, req3, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testRemoveLastElse.
 *
 * @throws Exception
 */
@Test
public void testRemoveLastElse() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  ZestRequest req3 = new ZestRequest();
  zc.addElse(req1);
  zc.addElse(req2);
  zc.addElse(req3);
  zc.removeElse(req3);
  checkOrder(new ZestStatement[] {zc, req1, req2, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testMoveFirstElse.
 *
 * @throws Exception
 */
@Test
public void testMoveFirstElse() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  ZestRequest req3 = new ZestRequest();
  zc.addElse(req1);
  zc.addElse(req2);
  zc.addElse(req3);
  zc.moveElse(1, req1);
  checkOrder(new ZestStatement[] {zc, req2, req1, req3, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testRemoveFirstElse.
 *
 * @throws Exception
 */
@Test
public void testRemoveFirstElse() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  ZestRequest req3 = new ZestRequest();
  zc.addElse(req1);
  zc.addElse(req2);
  zc.addElse(req3);
  zc.removeElse(req1);
  checkOrder(new ZestStatement[] {zc, req2, req3, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testRemoveLastElse.
 *
 * @throws Exception
 */
@Test
public void testRemoveLastElse() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  ZestRequest req3 = new ZestRequest();
  zc.addElse(req1);
  zc.addElse(req2);
  zc.addElse(req3);
  zc.removeElse(req3);
  checkOrder(new ZestStatement[] {zc, req1, req2, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testMovingElseStatements.
 *
 * @throws Exception
 */
@Test
public void testMovingElseStatements() throws Exception {
  ZestConditional zc1 = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  zc1.addElse(req1);
  zc1.addElse(req2);
  zc1.moveElse(0, req2);
  checkOrder(new ZestStatement[] {zc1, req2, req1, null});
}
/*

代码示例来源:origin: mozilla/zest

/**
 * Method testAddingElses.
 *
 * @throws Exception
 */
@Test
public void testAddingElses() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req = new ZestRequest();
  zc.addElse(req);
  assertEquals(1, req.getIndex());
  checkOrder(new ZestStatement[] {zc, req, null});
  ZestRequest req2 = new ZestRequest();
  zc.addElse(req2);
  // 0: zc
  // 1:   req
  // 2:   req2
  checkOrder(new ZestStatement[] {zc, req, req2, null});
  ZestRequest req3 = new ZestRequest();
  zc.addElse(1, req3);
  // 0: zc
  // 1:   req
  // 2:   req3
  // 3:   req2
  checkOrder(new ZestStatement[] {zc, req, req3, req2, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testAddingElses.
 *
 * @throws Exception
 */
@Test
public void testAddingElses() throws Exception {
  ZestConditional zc = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req = new ZestRequest();
  zc.addElse(req);
  assertEquals(1, req.getIndex());
  checkOrder(new ZestStatement[] {zc, req, null});
  ZestRequest req2 = new ZestRequest();
  zc.addElse(req2);
  // 0: zc
  // 1:   req
  // 2:   req2
  checkOrder(new ZestStatement[] {zc, req, req2, null});
  ZestRequest req3 = new ZestRequest();
  zc.addElse(1, req3);
  // 0: zc
  // 1:   req
  // 2:   req3
  // 3:   req2
  checkOrder(new ZestStatement[] {zc, req, req3, req2, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testDeepConditionals1.
 *
 * @throws Exception
 */
@Test
public void testDeepConditionals1() throws Exception {
  ZestConditional zc1 = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestConditional zc2 = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  zc1.addIf(zc2);
  zc2.addIf(req1);
  zc1.addElse(req2);
  checkOrder(new ZestStatement[] {zc1, zc2, req1, req2, null});
}

代码示例来源:origin: mozilla/zest

/**
 * Method testDeepConditionals1.
 *
 * @throws Exception
 */
@Test
public void testDeepConditionals1() throws Exception {
  ZestConditional zc1 = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestConditional zc2 = new ZestConditional(new ZestExpressionRegex("BODY", ""));
  ZestRequest req1 = new ZestRequest();
  ZestRequest req2 = new ZestRequest();
  zc1.addIf(zc2);
  zc2.addIf(req1);
  zc1.addElse(req2);
  checkOrder(new ZestStatement[] {zc1, zc2, req1, req2, null});
}

相关文章