Source: eclairjs/streaming/Duration.js

  1. /*
  2. * Copyright 2015 IBM Corp.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. (function () {
  17. var JavaWrapper = require(EclairJS_Globals.NAMESPACE + '/JavaWrapper');
  18. var Logger = require(EclairJS_Globals.NAMESPACE + '/Logger');
  19. var Utils = require(EclairJS_Globals.NAMESPACE + '/Utils');
  20. var JavaDuration = Java.type("org.apache.spark.streaming.Duration");
  21. var logger = Logger.getLogger("streaming.Duration_js");
  22. /**
  23. * @constructor
  24. * @memberof module:eclairjs/streaming
  25. * @classdesc Duration of time to wait.
  26. * @param {long} millis
  27. */
  28. var Duration = function (millis) {
  29. var jvmObj = new JavaDuration(millis);
  30. JavaWrapper.call(this, jvmObj);
  31. };
  32. Duration.prototype = Object.create(JavaWrapper.prototype);
  33. Duration.prototype.constructor = Duration;
  34. /**
  35. *
  36. * @param {module:eclairjs/streaming.Duration} that
  37. * @returns {double}
  38. */
  39. Duration.prototype.div = function (that) {
  40. return this.getJavaObject().div(Utils.unwrapObject(that));
  41. };
  42. /**
  43. *
  44. * @param {module:eclairjs/streaming.Duration} that
  45. * @returns {boolean}
  46. */
  47. Duration.prototype.greater = function (that) {
  48. return this.getJavaObject().greater(Utils.unwrapObject(that));
  49. };
  50. /**
  51. *
  52. * @param {module:eclairjs/streaming.Duration} that
  53. * @returns {boolean}
  54. */
  55. Duration.prototype.greaterEq = function (that) {
  56. return this.getJavaObject().greaterEq(Utils.unwrapObject(that));
  57. };
  58. /**
  59. *
  60. * @param {module:eclairjs/streaming.Duration} that
  61. * @returns {boolean}
  62. */
  63. Duration.prototype.isMultipleOf = function (that) {
  64. return this.getJavaObject().isMultipleOf(Utils.unwrapObject(that));
  65. };
  66. /**
  67. * @returns {boolean}
  68. */
  69. Duration.prototype.isZero = function () {
  70. return this.getJavaObject().isZero();
  71. };
  72. /**
  73. *
  74. * @param {module:eclairjs/streaming.Duration} that
  75. * @returns {boolean}
  76. */
  77. Duration.prototype.less = function (that) {
  78. return this.getJavaObject().less(Utils.unwrapObject(that));
  79. };
  80. /**
  81. *
  82. * @param {module:eclairjs/streaming.Duration} that
  83. * @returns {boolean}
  84. */
  85. Duration.prototype.lessEq = function (that) {
  86. return this.getJavaObject().lessEq(Utils.unwrapObject(that));
  87. };
  88. /**
  89. *
  90. * @param {module:eclairjs/streaming.Duration} that
  91. * @returns {module:eclairjs/streaming.Duration}
  92. */
  93. Duration.prototype.max = function (that) {
  94. var d = this.getJavaObject().max(Utils.unwrapObject(that));
  95. return new Duration(d);
  96. };
  97. /**
  98. *
  99. * @returns {long}
  100. */
  101. Duration.prototype.milliseconds = function () {
  102. return this.getJavaObject().milliseconds();
  103. };
  104. /**
  105. * @param {module:eclairjs/streaming.Duration} that
  106. * @returns {module:eclairjs/streaming.Duration}
  107. */
  108. Duration.prototype.min = function (that) {
  109. var d = this.getJavaObject().min(Utils.unwrapObject(that));
  110. return new Duration(d);
  111. };
  112. /**
  113. *
  114. * @param {module:eclairjs/streaming.Duration} that
  115. * @returns {module:eclairjs/streaming.Duration}
  116. */
  117. Duration.prototype.minus = function (that) {
  118. var d = this.getJavaObject().minus(Utils.unwrapObject(that));
  119. return new Duration(d);
  120. };
  121. /**
  122. *
  123. * @param {module:eclairjs/streaming.Duration} that
  124. * @returns {module:eclairjs/streaming.Duration}
  125. */
  126. Duration.prototype.plus = function (that) {
  127. var d = this.getJavaObject().plus(Utils.unwrapObject(that));
  128. return new Duration(d);
  129. };
  130. /**
  131. *
  132. * @param {integer} times
  133. * @returns {module:eclairjs/streaming.Duration}
  134. */
  135. Duration.prototype.times = function (times) {
  136. var d = this.getJavaObject().times();
  137. return new Duration(d);
  138. };
  139. module.exports = Duration;
  140. })();