-
Notifications
You must be signed in to change notification settings - Fork 210
/
Unit.ts
42 lines (38 loc) · 1.3 KB
/
Unit.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Quantity
*/
import { UnitProps } from "./Interfaces";
/** This class provides basic implementation of UnitProps interface.
* @beta
*/
export class BasicUnit implements UnitProps {
public name = "";
public label = "";
public phenomenon = "";
public isValid = false;
public system: string = "unknown";
constructor(name: string, label: string, phenomenon: string, system?: string) {
if (name && name.length > 0 && label && label.length > 0 && phenomenon && phenomenon.length > 0) {
this.name = name;
this.label = label;
this.phenomenon = phenomenon;
this.isValid = true;
if (system)
this.system = system;
}
}
}
/** This class is a convenience class that can be returned when a valid Unit cannot be determined.
* @beta
*/
export class BadUnit implements UnitProps {
public name = "";
public label = "";
public phenomenon = "";
public isValid = false;
public system = "unknown";
}