org.mozilla.zest.core.v1.ZestLoopTokenSet类的使用及代码示例

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

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

ZestLoopTokenSet介绍

[英]this class represents a Set of loop tokens.
[中]此类表示一组循环标记。

代码示例

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

/**
 * main construptor.
 *
 * @param initializationTokenSet the set of token and the fisrt value to consider inside the
 *     loop
 */
protected ZestLoopState(ZestLoopTokenSet<T> initializationTokenSet) {
  if (initializationTokenSet == null) {
    throw new IllegalArgumentException("a null token set is not allowed");
  }
  if (initializationTokenSet.size() > 0) {
    this.currentToken = initializationTokenSet.getToken(0);
    this.currentIndex = 0;
  }
}

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

/**
 * Inits the Loop.
 *
 * @param set the initialization token set
 * @param statements the list of statements inside the loop
 */
protected void init(ZestLoopTokenSet<T> set, List<ZestStatement> statements) {
  this.statements = statements;
  this.currentState = set.getFirstState();
}
/**

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

@Override
public boolean increase(ZestLoopTokenSet<Integer> set) {
  ZestLoopTokenIntegerSet integerSet = (ZestLoopTokenIntegerSet) set;
  this.setIndex(getCurrentIndex() + integerSet.getStep());
  if (!isLastState(set)) {
    super.setCurrentToken(this.getCurrentToken() + integerSet.getStep());
    return getCurrentIndex() < set.size();
  } else {
    super.setCurrentToken(set.getLastToken());
    return false;
  }
}

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

@Test
  public void testDeepCopy() {
    ZestLoopTokenStringSet set = new ZestLoopTokenStringSet(arrayValueS);
    ZestLoopTokenSet<String> copy = set.deepCopy();
    for (int i = 0; i < set.size(); i++) {
      String expected = set.getToken(i);
      String obtained = copy.getToken(i);
      String msg = i + " obtained " + obtained + " instead of " + expected;
      assertTrue(msg, expected.equals(obtained));
    }
  }
}

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

/**
 * Checks if is last state.
 *
 * @param set the set
 * @return true, if is last state
 */
public boolean isLastState(ZestLoopTokenSet<T> set) {
  return (this.getCurrentIndex() >= set.size());
}

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

/**
 * this sets the state to the last state: i.e. the loop has finished
 *
 * @param set the set
 */
public void toLastState(ZestLoopTokenSet<T> set) {
  if (set == null) {
    return;
  } else {
    this.setIndex(set.size());
    this.setCurrentToken(null);
  }
}

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

@Override
public boolean increase(ZestLoopTokenSet<String> set) {
  this.increaseIndex();
  if (this.getCurrentIndex() >= set.size()) {
    this.setCurrentToken(null);
  } else {
    this.setCurrentToken(set.getToken(getCurrentIndex()));
  }
  return true;
}

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

/**
 * inits the loop refreshing the current state to the first considered state
 *
 * @param runtime the Zest runtime.
 */
public void init(ZestRuntime runtime) {
  this.runtime = runtime;
  this.currentState = this.getSet().getFirstState();
}
/**

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

/**
 * sets the current state to the new one (for subclasses).
 *
 * @param newSet the new sets the
 */
protected void setSet(ZestLoopTokenSet<T> newSet) {
  this.setCurrentState(newSet.getFirstState());
}

相关文章