org.spongepowered.api.text.Text.isEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(76)

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

Text.isEmpty介绍

[英]Returns whether this Text is empty.
[中]返回此文本是否为空。

代码示例

代码示例来源:origin: EngineHub/WorldEdit

@Override
public boolean isTagged() {
  return !entity.get(Keys.DISPLAY_NAME).orElse(Text.EMPTY).isEmpty();
}

代码示例来源:origin: SpongePowered/SpongeAPI

/**
 * Removes all empty texts from the beginning and end of this
 * builder.
 *
 * @return This builder
 */
public Builder trim() {
  Iterator<Text> front = this.children.iterator();
  while (front.hasNext()) {
    if (front.next().isEmpty()) {
      front.remove();
    } else {
      break;
    }
  }
  ListIterator<Text> back = this.children.listIterator(this.children.size());
  while (back.hasPrevious()) {
    if (back.previous().isEmpty()) {
      back.remove();
    } else {
      break;
    }
  }
  return this;
}

代码示例来源:origin: SpongePowered/SpongeAPI

@Override
  public Text getUsage(CommandSource src) {
    Text usage = this.dispatcher.getUsage(src);
    if (this.fallbackElements == null) {
      return usage;
    }

    Text elementUsage = this.fallbackElements.getUsage(src);
    if (elementUsage.isEmpty()) {
      return usage;
    }

    return Text.of(usage, CommandMessageFormatting.PIPE_TEXT, elementUsage);
  }
}

代码示例来源:origin: org.spongepowered/spongeapi

/**
 * Removes all empty texts from the beginning and end of this
 * builder.
 *
 * @return This builder
 */
public Builder trim() {
  Iterator<Text> front = this.children.iterator();
  while (front.hasNext()) {
    if (front.next().isEmpty()) {
      front.remove();
    } else {
      break;
    }
  }
  ListIterator<Text> back = this.children.listIterator(this.children.size());
  while (back.hasPrevious()) {
    if (back.previous().isEmpty()) {
      back.remove();
    } else {
      break;
    }
  }
  return this;
}

相关文章