forked from equinor/webviz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3af6571
commit 739a2da
Showing
5 changed files
with
60 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
export class ParameterIdent { | ||
readonly name: string; | ||
readonly groupName: string | null; | ||
|
||
constructor(name: string, groupName: string | null) { | ||
this.name = name; | ||
this.groupName = groupName; | ||
} | ||
|
||
static fromNameAndGroup(name: string, groupName: string | null): ParameterIdent { | ||
return new ParameterIdent(name, groupName); | ||
} | ||
|
||
static fromString(paramIdentString: string): ParameterIdent { | ||
const parts = paramIdentString.split("~@@~"); | ||
if (parts.length === 1) { | ||
return new ParameterIdent(parts[0], null); | ||
} | ||
if (parts.length === 2) { | ||
return new ParameterIdent(parts[0], parts[1]); | ||
} | ||
|
||
throw new Error(`Invalid parameter ident string: ${paramIdentString}`); | ||
} | ||
|
||
toString(): string { | ||
if (this.groupName) { | ||
return `${this.name}~@@~${this.groupName}`; | ||
} else { | ||
return this.name; | ||
} | ||
} | ||
|
||
equals(otherIdent: ParameterIdent | null): boolean { | ||
if (!otherIdent) { | ||
return false; | ||
} | ||
if (otherIdent === this) { | ||
return true; | ||
} | ||
|
||
return this.name === otherIdent.name && this.groupName === otherIdent.groupName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters