Java Code Examples for joptsimple.internal.Strings#EMPTY

The following examples show how to use joptsimple.internal.Strings#EMPTY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutoReply.java    From ForgeHax with MIT License 7 votes vote down vote up
@SubscribeEvent
public void onClientChat(ClientChatReceivedEvent event) {
  String message = (event.getMessage().getUnformattedText());
  if (message.matches(search.get()) && !message.startsWith(MC.getSession().getUsername())) {
    String append;
    switch (mode.get().toUpperCase()) {
      case "REPLY":
        append = "/r ";
        break;
      case "CHAT":
      default:
        append = Strings.EMPTY;
        break;
    }
    getLocalPlayer().sendChatMessage(append + reply.get());
  }
}
 
Example 2
Source File: BaseNotificationContent.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
/**
 * The lift value for an SLA anomaly is delay from the configured sla. (Ex: 2 days & 3 hours)
 */
protected static String getFormattedSLALiftValue(MergedAnomalyResultDTO anomaly) {
  if (!anomaly.getType().equals(AnomalyType.DATA_SLA)
      || anomaly.getProperties() == null || anomaly.getProperties().isEmpty()
      || !anomaly.getProperties().containsKey("sla")
      || !anomaly.getProperties().containsKey("datasetLastRefreshTime")) {
    return Strings.EMPTY;
  }

  long delayInMillis = anomaly.getEndTime() - Long.parseLong(anomaly.getProperties().get("datasetLastRefreshTime"));
  long days = TimeUnit.MILLISECONDS.toDays(delayInMillis);
  long hours = TimeUnit.MILLISECONDS.toHours(delayInMillis) % TimeUnit.DAYS.toHours(1);
  long minutes = TimeUnit.MILLISECONDS.toMinutes(delayInMillis) % TimeUnit.HOURS.toMinutes(1);

  String liftValue;
  if (days > 0) {
    liftValue = String.format("%d days & %d hours", days, hours);
  } else if (hours > 0) {
    liftValue = String.format("%d hours & %d mins", hours, minutes);
  } else {
    liftValue = String.format("%d mins", minutes);
  }

  return liftValue;
}
 
Example 3
Source File: EventDeserializer.java    From ic with MIT License 5 votes vote down vote up
/**
 * 如果事件不包含类型信息,则返回空字符串
 */
private String parseType(String type, String event) {
    String result = Strings.EMPTY;
    if (type != null) {
        result = type;
    } else if (event != null) {
        result = event;
    }
    return result;
}
 
Example 4
Source File: FirstTimeRunningService.java    From ForgeHax with MIT License 5 votes vote down vote up
private static final String getOnceFileVersion() {
  if (Files.exists(STARTUP_ONCE)) {
    try {
      return new String(Files.readAllBytes(STARTUP_ONCE));
    } catch (Throwable t) {
    }
  }
  return Strings.EMPTY;
}
 
Example 5
Source File: BlockEntry.java    From ForgeHax with MIT License 5 votes vote down vote up
public BlockEntry(Block block, int meta, boolean check) throws BlockDoesNotExistException {
  meta = Math.max(meta, 0);
  if (check) {
    BlockOptionHelper.requiresValidBlock(block, meta);
  }
  this.block = block;
  this.meta = BlockOptionHelper.getAllBlocks(block).size() > 1 ? meta : -1;
  this.uniqueId = getResourceName() + (isMetadata() ? ("::" + getMetadata()) : Strings.EMPTY);
}
 
Example 6
Source File: BlockEntry.java    From ForgeHax with MIT License 5 votes vote down vote up
public String getPrettyName() {
  return block != null
      ? ((block.getRegistryName() != null
      ? block.getRegistryName().getResourcePath()
      : block.toString())
      + (isMetadata() ? ":" + meta : Strings.EMPTY))
      : Strings.EMPTY;
}
 
Example 7
Source File: SpamEntry.java    From ForgeHax with MIT License 5 votes vote down vote up
public String next() {
  if (!messages.isEmpty()) {
    switch (type) {
      case RANDOM:
        return messages.get(ThreadLocalRandom.current().nextInt(messages.size()));
      case SEQUENTIAL:
        return messages.get((nextIndex++ % messages.size()));
    }
  }
  return Strings.EMPTY;
}
 
Example 8
Source File: UnGzipConverterTest.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private static String readGzipStreamAsString(InputStream is) throws Exception {
  TarArchiveInputStream tarIn = new TarArchiveInputStream(is);
  try {
    TarArchiveEntry tarEntry;
    while ((tarEntry = tarIn.getNextTarEntry()) != null) {
      if (tarEntry.isFile() && tarEntry.getName().endsWith(".txt")) {
        return IOUtils.toString(tarIn, "UTF-8");
      }
    }
  } finally {
    tarIn.close();
  }

  return Strings.EMPTY;
}
 
Example 9
Source File: BaseNotificationContent.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
public AnomalyReportEntity(String anomalyId, String anomalyURL, String baselineVal, String currentVal, String lift,
    boolean positiveLift, Double swi, List<String> dimensions, String duration, String feedback, String function,
    String funcDescription, String metric, String startTime, String endTime, String timezone, String issueType,
    String anomalyType, String properties) {
  this.anomalyId = anomalyId;
  this.anomalyURL = anomalyURL;
  this.baselineVal = baselineVal;
  this.currentVal = currentVal;
  this.dimensions = dimensions;
  this.duration = duration;
  this.feedback = feedback;
  this.function = function;
  this.funcDescription = funcDescription;
  this.swi = "";
  if (swi != null) {
    this.swi = String.format(PERCENTAGE_FORMAT, swi * 100);
  }
  if (baselineVal.equals("-")) {
    this.lift = Strings.EMPTY;
  } else {
    this.lift = lift;
  }
  this.positiveLift = positiveLift;
  this.metric = metric;
  this.startDateTime = startTime;
  this.endTime = endTime;
  this.timezone = timezone;
  this.issueType = issueType;
  this.anomalyType = anomalyType;
  this.properties = properties;
}
 
Example 10
Source File: ItemCollectionBuilder.java    From staccato with Apache License 2.0 4 votes vote down vote up
protected void buildGetLink(SearchRequest searchRequest, ItemCollection itemCollection, int finalLimit,
                              String nextToken) {
    // rebuild the original request link
    double[] bbox = searchRequest.getBbox();
    String link = LinksConfigProps.LINK_BASE + "?limit=" + finalLimit;
    if (null != bbox && (bbox.length == 4 || bbox.length == 6)) {
        link += bbox == null ? Strings.EMPTY : "&bbox=" + bbox[0] + "," + bbox[1] + "," + bbox[2] + "," + bbox[3];
    }
    link += searchRequest.getDatetime() == null ? Strings.EMPTY : "&datetime=" + searchRequest.getDatetime();
    link += searchRequest.getQuery() == null ? Strings.EMPTY : "&query=" + searchRequest.getQuery();
    link += searchRequest.getIds() == null ? Strings.EMPTY :
            "&ids=" + String.join(",", searchRequest.getIds());
    link += searchRequest.getCollections() == null ? Strings.EMPTY :
            "&collections=" + String.join(",", searchRequest.getCollections());

    String fieldsValue = "";
    if (null != searchRequest.getFields()) {
        // add include fields
        fieldsValue += searchRequest.getFields().getInclude() == null ? Strings.EMPTY :
                String.join(",", searchRequest.getFields().getInclude());

        // add exclude fields
        Set<String> excludeFields = searchRequest.getFields().getExclude();
        if (null != excludeFields) {
            // need to add the "-" prefix for the get parameter
            List<String> prefixedExcludeFields = new ArrayList<>();
            excludeFields.forEach(field -> prefixedExcludeFields.add("-" + field));
            String excludeFieldsString = String.join(",", prefixedExcludeFields);
            fieldsValue += fieldsValue.isBlank() ? excludeFieldsString : "," + excludeFieldsString;
        }
    }

    if (fieldsValue != null && !fieldsValue.isBlank()) {
        link += "&fields=" + fieldsValue;
    }

    if (nextToken != null) {
        itemCollection.addLink(new Link()
                .href(link + "&next=" + nextToken)
                .type(StaccatoMediaType.APPLICATION_GEO_JSON_VALUE)
                .rel("next"));
    }

    String selfLink = searchRequest.getNext() == null ? link : link + "&next=" + searchRequest.getNext();
    itemCollection.addLink(new Link()
            .href(selfLink)
            .method(HttpMethod.GET.toString())
            .type(StaccatoMediaType.APPLICATION_GEO_JSON_VALUE)
            .rel("self"));

}
 
Example 11
Source File: BlockEntry.java    From ForgeHax with MIT License 4 votes vote down vote up
public String getResourceName() {
  return block != null
      ? (block.getRegistryName() != null ? block.getRegistryName().toString() : block.toString())
      : Strings.EMPTY;
}
 
Example 12
Source File: CommandGlobal.java    From ForgeHax with MIT License 4 votes vote down vote up
@Override
public String getName() {
  return Strings.EMPTY;
}
 
Example 13
Source File: CommandGlobal.java    From ForgeHax with MIT License 4 votes vote down vote up
@Override
public String getAbsoluteName() {
  return Strings.EMPTY;
}
 
Example 14
Source File: BaseMod.java    From ForgeHax with MIT License 4 votes vote down vote up
public BaseMod(Category category, String name) {
  this(category, name, Strings.EMPTY);
}
 
Example 15
Source File: CommandMod.java    From ForgeHax with MIT License 4 votes vote down vote up
public CommandMod(String name) {
  super(name, Strings.EMPTY);
}