Package com.belladati.sdk.intervals

Examples of com.belladati.sdk.intervals.TimeUnit


   */
  private static Interval<TimeUnit> parseTimeInterval(JsonNode node) {
    try {
      if (node.hasNonNull("timeInterval") && node.get("timeInterval").hasNonNull("aggregationType")) {
        JsonNode timeInterval = node.get("timeInterval");
        TimeUnit unit = TimeUnit.valueOf(timeInterval.get("aggregationType").asText().toUpperCase(Locale.ENGLISH));
        JsonNode interval = timeInterval.get("interval");
        String type = interval.get("type").asText().toLowerCase(Locale.ENGLISH);
        if ("relative".equals(type)) {
          // the server may send numbers inside strings
          // or numbers as decimals, e.g. 3.0
          // regardless, we treat them all as int
          String from = interval.get("from").asText();
          String to = interval.get("to").asText();
          return new RelativeInterval<TimeUnit>(unit, (int) Float.parseFloat(from), (int) Float.parseFloat(to));
        } else if ("absolute".equals(type)) {
          // an absolute interval
          return new AbsoluteInterval<TimeUnit>(unit, unit.parseAbsolute(interval.get("from")),
            unit.parseAbsolute(interval.get("to")));
        } else if ("custom".equals(type)) {
          // a custom interval
          return new CustomInterval<TimeUnit>(unit, interval.get("from").asText(), interval.get("to").asText());
        }
      }
View Full Code Here


   */
  private static Interval<TimeUnit> parseTimeInterval(JsonNode node) {
    try {
      if (node.hasNonNull("timeInterval") && node.get("timeInterval").hasNonNull("aggregationType")) {
        JsonNode timeInterval = node.get("timeInterval");
        TimeUnit unit = TimeUnit.valueOf(timeInterval.get("aggregationType").asText().toUpperCase());
        JsonNode interval = timeInterval.get("interval");
        String type = interval.get("type").asText().toLowerCase();
        if ("relative".equals(type)) {
          // the server may send numbers inside strings
          // or numbers as decimals, e.g. 3.0
          // regardless, we treat them all as int
          String from = interval.get("from").asText();
          String to = interval.get("to").asText();
          return new RelativeInterval<TimeUnit>(unit, (int) Float.parseFloat(from), (int) Float.parseFloat(to));
        } else if ("absolute".equals(type)) {
          // an absolute interval
          return new AbsoluteInterval<TimeUnit>(unit, unit.parseAbsolute(interval.get("from")),
            unit.parseAbsolute(interval.get("to")));
        }
      }
    } catch (InvalidIntervalException e) {
      // ignore the interval
    } catch (NumberFormatException e) {
View Full Code Here

   */
  private static Interval<TimeUnit> parseTimeInterval(JsonNode node) {
    try {
      if (node.hasNonNull("timeInterval") && node.get("timeInterval").hasNonNull("aggregationType")) {
        JsonNode timeInterval = node.get("timeInterval");
        TimeUnit unit = TimeUnit.valueOf(timeInterval.get("aggregationType").asText().toUpperCase(Locale.ENGLISH));
        JsonNode interval = timeInterval.get("interval");
        String type = interval.get("type").asText().toLowerCase(Locale.ENGLISH);
        if ("relative".equals(type)) {
          // the server may send numbers inside strings
          // or numbers as decimals, e.g. 3.0
          // regardless, we treat them all as int
          String from = interval.get("from").asText();
          String to = interval.get("to").asText();
          return new RelativeInterval<TimeUnit>(unit, (int) Float.parseFloat(from), (int) Float.parseFloat(to));
        } else if ("absolute".equals(type)) {
          // an absolute interval
          return new AbsoluteInterval<TimeUnit>(unit, unit.parseAbsolute(interval.get("from")),
            unit.parseAbsolute(interval.get("to")));
        }
      }
    } catch (InvalidIntervalException e) {
      // ignore the interval
    } catch (NumberFormatException e) {
View Full Code Here

   */
  private static Interval<TimeUnit> parseTimeInterval(JsonNode node) {
    try {
      if (node.hasNonNull("timeInterval") && node.get("timeInterval").hasNonNull("aggregationType")) {
        JsonNode timeInterval = node.get("timeInterval");
        TimeUnit unit = TimeUnit.valueOf(timeInterval.get("aggregationType").asText().toUpperCase(Locale.ENGLISH));
        JsonNode interval = timeInterval.get("interval");
        String type = interval.get("type").asText().toLowerCase(Locale.ENGLISH);
        if ("relative".equals(type)) {
          // the server may send numbers inside strings
          // or numbers as decimals, e.g. 3.0
          // regardless, we treat them all as int
          String from = interval.get("from").asText();
          String to = interval.get("to").asText();
          return new RelativeInterval<TimeUnit>(unit, (int) Float.parseFloat(from), (int) Float.parseFloat(to));
        } else if ("absolute".equals(type)) {
          // an absolute interval
          return new AbsoluteInterval<TimeUnit>(unit, unit.parseAbsolute(interval.get("from")),
            unit.parseAbsolute(interval.get("to")));
        }
      }
    } catch (InvalidIntervalException e) {
      // ignore the interval
    } catch (NumberFormatException e) {
View Full Code Here

TOP

Related Classes of com.belladati.sdk.intervals.TimeUnit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.