typescript-util
Version:
JS/TS 的简单工具
44 lines • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyValue = void 0;
const BaseObject_1 = require("./BaseObject");
/**
* KeyValue
* @author LL
* @date 2022-01-23 上午 1:52
**/
class KeyValue extends BaseObject_1.BaseObject {
key;
value;
constructor(key, value) {
super();
this.key = key;
this.value = value;
}
equals(o) {
if (super.equals(o)) {
return true;
}
if (!(o instanceof KeyValue)) {
return false;
}
return o.key === this.key && o.value === this.value;
}
hashCode() {
return super.hashCode();
}
toString() {
return `${this.key}=${this.value}`;
}
/**
* toString 的 "重载"
* 可以自定义分隔符 connect 默认 =
* @param {string} connect
* @return {string}
*/
toStr(connect = '=') {
return `${this.key}${connect}${this.value}`;
}
}
exports.KeyValue = KeyValue;
//# sourceMappingURL=KeyValue.js.map