Skip to content
Snippets Groups Projects

Issue #80: Add enumHandler

Merged Rafael Dias requested to merge issue/80 into develop
3 files
+ 58
4
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 4
38
@@ -19,7 +19,7 @@
*/
import { RelationType, DataType } from "../common/types";
import { EnumType } from "./enumType";
import { EnumHandler } from "../util/enumHandler";
/** Parameters used to create a Dimension object. */
export interface DimensionOptions {
@@ -96,52 +96,18 @@ export class Dimension {
if (this.relation === RelationType.NONE) {
return {
name: this.name,
dataType: (this.dataType !== DataType.NONE) ? EnumType.stringfyDataType(this.dataType) : this.enumType ,
dataType: (this.dataType !== DataType.NONE) ? EnumHandler.stringfyDataType(this.dataType) : this.enumType ,
description: this.description
};
}
else {
return {
name: this.name,
dataType: (this.dataType !== DataType.NONE) ? EnumType.stringfyDataType(this.dataType) : this.enumType ,
dataType: (this.dataType !== DataType.NONE) ? EnumHandler.stringfyDataType(this.dataType) : this.enumType ,
parent: this.parent.name,
relation: Dimension.stringifyRelationType(this.relation),
relation: EnumHandler.stringifyRelationType(this.relation),
description: this.description
};
}
}
/**
* Parse a string to enum(Relation Type).
* @param r - Relation in string format.
*/
public static parseRelationType(r: string): RelationType {
switch (r) {
case "day":
return RelationType.DAY;
case "month":
return RelationType.MONTH;
case "year":
return RelationType.YEAR;
default:
return RelationType.NONE;
}
}
/**
* Parse an enum(Relation Type) to string.
* @param r - Relation to be stringified.
*/
public static stringifyRelationType(r: RelationType): string {
switch (r) {
case RelationType.DAY:
return "day";
case RelationType.MONTH:
return "month";
case RelationType.YEAR:
return "year";
default:
return "";
}
}
}
Loading