forked from riehlegroup/adap-names
-
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.
Showing
18 changed files
with
261 additions
and
87 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
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 |
---|---|---|
@@ -1,21 +1,18 @@ | ||
import { Exception } from "./Exception"; | ||
import { InvalidStateException } from "./InvalidStateException"; | ||
|
||
/** | ||
* An IllegalArgumentException signals an invalid argument. | ||
* In other words, a method precondition failed. | ||
*/ | ||
export class IllegalArgumentException extends Exception { | ||
|
||
static assertIsNotNullOrUndefined(o: Object | null, exMsg: string = "null or undefined"): void { | ||
this.assertCondition(this.isNullOrUndefined(o), exMsg); | ||
public static assert(c: boolean, m: string = "illegal argument", t?: Exception): void { | ||
if (!c) throw new IllegalArgumentException(m, t); | ||
} | ||
|
||
static assertCondition(cond: boolean, exMsg: string): void { | ||
if (!cond) throw new IllegalArgumentException(exMsg); | ||
constructor(m: string, t?: Exception) { | ||
super(m, t); | ||
} | ||
|
||
constructor(m: string) { | ||
super(m); | ||
} | ||
|
||
|
||
} |
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 |
---|---|---|
@@ -1,14 +1,27 @@ | ||
export const DEFAULT_DELIMITER: string = '.'; | ||
export const ESCAPE_CHARACTER = '\\'; | ||
|
||
export interface Printable { | ||
|
||
/** | ||
* Returns human-readable representation of this object | ||
* Expects that delimiter is a single character | ||
/** | ||
* Returns a human-readable representation of the Name instance using user-set control characters | ||
* Control characters are not escaped (creating a human-readable string) | ||
* Users can vary the delimiter character to be used | ||
* The delimiter character must be a single character | ||
*/ | ||
asString(delChar?: string): string; | ||
asString(delimiter?: string): string; | ||
|
||
/** | ||
* Returns machine-readable representation of this object | ||
*/ | ||
asDataString(): string; | ||
/** | ||
* Returns a machine-readable representation of Name instance using default control characters | ||
* Machine-readable means that from a data string, a Name can be parsed back in | ||
* The control characters in the data string are the default characters | ||
* Different fields of the object are separated by the delimiter character | ||
*/ | ||
asDataString(): string; | ||
|
||
/** | ||
* Returns delimiter char; must be a single character | ||
*/ | ||
getDelimiterCharacter(): string; | ||
|
||
} |
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,17 @@ | ||
import { Exception } from "./Exception"; | ||
|
||
/** | ||
* A ServiceFailureException signals that a service failed to provide its service. | ||
* ServiceFailureExceptions must be checked for by the client after the service call. | ||
*/ | ||
export class ServiceFailureException extends Exception { | ||
|
||
public static assert(c: boolean, m: string = "service failed", t?: Exception): void { | ||
if (!c) throw new ServiceFailureException(m, t); | ||
} | ||
|
||
constructor(m: string, t?: Exception) { | ||
super(m, t); | ||
} | ||
|
||
} |
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
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,3 @@ | ||
export function calculateDuration1(distance: number, speed: number): number { | ||
return distance / speed; | ||
} |
Oops, something went wrong.