Skip to content

Commit b4118f2

Browse files
committed
Original naming
1 parent 7866b74 commit b4118f2

File tree

6 files changed

+41
-41
lines changed

6 files changed

+41
-41
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ import { TermWrapper, ValueMapping, TermMapping } from "https://unpkg.com/rdfjs-
5050

5151
class Person extends TermWrapper {
5252
get name() {
53-
return this.getSingularNullable("https://example.org/name", ValueMapping.literalToString)
53+
return this.singularNullable("https://example.org/name", ValueMapping.literalToString)
5454
}
5555

5656
set name(value) {
57-
this.setSingularNullable("https://example.org/name", value, TermMapping.literalToString)
57+
this.overwriteNullable("https://example.org/name", value, TermMapping.literalToString)
5858
}
5959
}
6060
```
@@ -129,19 +129,19 @@ import { TermWrapper, ValueMapping, TermMapping, ObjectMapping } from "https://u
129129

130130
class Person extends TermWrapper {
131131
get name() {
132-
return this.getSingularNullable("https://example.org/name", ValueMapping.literalToString)
132+
return this.singularNullable("https://example.org/name", ValueMapping.literalToString)
133133
}
134134

135135
set name(value) {
136-
this.getSingularNullable("https://example.org/name", value, TermMapping.literalToString)
136+
this.singularNullable("https://example.org/name", value, TermMapping.literalToString)
137137
}
138138

139139
get mum() {
140-
return this.getSingularNullable("https://example.org/mum", ObjectMapping.as(Person))
140+
return this.singularNullable("https://example.org/mum", ObjectMapping.as(Person))
141141
}
142142

143143
set mum(value) {
144-
this.setSingularNullable("https://example.org/mum", value, ObjectMapping.as(Person))
144+
this.overwriteNullable("https://example.org/mum", value, ObjectMapping.as(Person))
145145
}
146146
}
147147
```

src/TermWrapper.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class TermWrapper {
2121
this.factory = factory;
2222
}
2323

24-
protected getSingular<T>(p: string, valueMapping: IValueMapping<T>): T {
24+
protected singular<T>(p: string, valueMapping: IValueMapping<T>): T {
2525
const predicate = this.factory.namedNode(p)
2626
const matches = this.dataset.match(this.term, predicate)
2727

@@ -37,7 +37,7 @@ export class TermWrapper {
3737
throw new Error(`No value found for predicate ${p} on term ${this.term.value}`)
3838
}
3939

40-
protected getSingularNullable<T>(p: string, valueMapping: IValueMapping<T>): T | undefined {
40+
protected singularNullable<T>(p: string, valueMapping: IValueMapping<T>): T | undefined {
4141
const predicate = this.factory.namedNode(p)
4242

4343
for (const q of this.dataset.match(this.term, predicate)) {
@@ -47,15 +47,15 @@ export class TermWrapper {
4747
return
4848
}
4949

50-
protected setSingular<T>(p: string, value: T, nodeMapping: ITermMapping<T>): void {
50+
protected overwrite<T>(p: string, value: T, nodeMapping: ITermMapping<T>): void {
5151
if (value === undefined) {
5252
throw new Error("value cannot be undefined")
5353
}
5454

55-
this.setSingularNullable(p, value, nodeMapping)
55+
this.overwriteNullable(p, value, nodeMapping)
5656
}
5757

58-
protected setSingularNullable<T>(p: string, value: T | undefined, termMapping: ITermMapping<T>): void {
58+
protected overwriteNullable<T>(p: string, value: T | undefined, termMapping: ITermMapping<T>): void {
5959
const predicate = this.factory.namedNode(p)
6060

6161
for (const q of this.dataset.match(this.term, predicate)) {
@@ -88,7 +88,7 @@ export class TermWrapper {
8888
this.dataset.add(q)
8989
}
9090

91-
protected getSet<T>(p: string, valueMapping: IValueMapping<T>, termMapping: ITermMapping<T>): Set<T> {
91+
protected objects<T>(p: string, valueMapping: IValueMapping<T>, termMapping: ITermMapping<T>): Set<T> {
9292
return new WrappingSet(this, p, valueMapping, termMapping)
9393
}
9494

src/decorators/getter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ export function getter(predicate: string, getterArity: GetterArity, valueMapping
1111
return function (this: TermWrapper): any {
1212
switch (getterArity) {
1313
case GetterArity.Singular:
14-
return this.getSingular(predicate, valueMapping)
14+
return this.singular(predicate, valueMapping)
1515
case GetterArity.SingularNullable:
16-
return this.getSingularNullable(predicate, valueMapping)
16+
return this.singularNullable(predicate, valueMapping)
1717
case GetterArity.Set:
18-
return this.getSet(predicate, valueMapping, termMapping)
18+
return this.objects(predicate, valueMapping, termMapping)
1919
}
2020
}
2121
}

src/decorators/setter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ export function setter(predicate: string, setterArity: SetterArity, termMapping:
99
return function (this: TermWrapper, value: any): void {
1010
switch (setterArity) {
1111
case SetterArity.Singular:
12-
this.setSingular(predicate, value, termMapping)
12+
this.overwrite(predicate, value, termMapping)
1313
break
1414
case SetterArity.SingularNullable:
15-
this.setSingularNullable(predicate, value, termMapping)
15+
this.overwriteNullable(predicate, value, termMapping)
1616
break
1717
}
1818
}

test/unit/model/Child.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { Example } from "../vocabulary/Example.js"
33

44
export class Child extends TermWrapper {
55
public get hasString(): string | undefined {
6-
return this.getSingularNullable(Example.hasString, ValueMapping.literalToString)
6+
return this.singularNullable(Example.hasString, ValueMapping.literalToString)
77
}
88

99
public set hasString(value: string | undefined) {
10-
this.setSingularNullable(Example.hasString, value, TermMapping.stringToLiteral)
10+
this.overwriteNullable(Example.hasString, value, TermMapping.stringToLiteral)
1111
}
1212
}

test/unit/model/Parent.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,100 +7,100 @@ import { Example } from "../vocabulary/Example.js"
77
export class Parent extends TermWrapper {
88
/* Value Mapping */
99
public get hasBlankNode(): string {
10-
return this.getSingular(Example.hasBlankNode, ValueMapping.blankNodeToString)
10+
return this.singular(Example.hasBlankNode, ValueMapping.blankNodeToString)
1111
}
1212

1313
public get hasDate(): Date {
14-
return this.getSingular(Example.hasDate, ValueMapping.literalToDate)
14+
return this.singular(Example.hasDate, ValueMapping.literalToDate)
1515
}
1616

1717
public get hasLangString(): ILangString {
18-
return this.getSingular(Example.hasLangString, ValueMapping.literalToLangString)
18+
return this.singular(Example.hasLangString, ValueMapping.literalToLangString)
1919
}
2020

2121
public get hasNumber(): number {
22-
return this.getSingular(Example.hasNumber, ValueMapping.literalToNumber)
22+
return this.singular(Example.hasNumber, ValueMapping.literalToNumber)
2323
}
2424

2525
public get hasString(): string {
26-
return this.getSingular(Example.hasString, ValueMapping.literalToString)
26+
return this.singular(Example.hasString, ValueMapping.literalToString)
2727
}
2828

2929
public get hasIri(): string {
30-
return this.getSingular(Example.hasIri, ValueMapping.iriToString)
30+
return this.singular(Example.hasIri, ValueMapping.iriToString)
3131
}
3232

3333

3434
/* Term Mapping */
3535
public set hasBlankNode(value: string) {
36-
this.setSingular(Example.hasBlankNode, value, TermMapping.stringToBlankNode)
36+
this.overwrite(Example.hasBlankNode, value, TermMapping.stringToBlankNode)
3737
}
3838

3939
public set hasDate(value: Date ) {
40-
this.setSingular(Example.hasDate, value, TermMapping.dateToLiteral)
40+
this.overwrite(Example.hasDate, value, TermMapping.dateToLiteral)
4141
}
4242

4343
public set hasLangString(value: ILangString ) {
44-
this.setSingular(Example.hasLangString, value, TermMapping.langStringToLiteral)
44+
this.overwrite(Example.hasLangString, value, TermMapping.langStringToLiteral)
4545
}
4646

4747
public set hasNumber(value: number ) {
48-
this.setSingular(Example.hasNumber, value, TermMapping.numberToLiteral)
48+
this.overwrite(Example.hasNumber, value, TermMapping.numberToLiteral)
4949
}
5050

5151
public set hasString(value: string ) {
52-
this.setSingular(Example.hasString, value, TermMapping.stringToLiteral)
52+
this.overwrite(Example.hasString, value, TermMapping.stringToLiteral)
5353
}
5454

5555
public set hasIri(value: string ) {
56-
this.setSingular(Example.hasIri, value, TermMapping.stringToIri)
56+
this.overwrite(Example.hasIri, value, TermMapping.stringToIri)
5757
}
5858

5959

6060
/* Object Mapping */
6161
public get hasChild(): Child {
62-
return this.getSingular(Example.hasChild, ObjectMapping.as(Child))
62+
return this.singular(Example.hasChild, ObjectMapping.as(Child))
6363
}
6464

6565
public set hasChild(value: Child) {
66-
this.setSingularNullable(Example.hasChild, value, ObjectMapping.as(Child))
66+
this.overwriteNullable(Example.hasChild, value, ObjectMapping.as(Child))
6767
}
6868

6969

7070
/* Arity Mapping */
7171
public get hasNoSingularString(): string {
72-
return this.getSingular(Example.hasNoSingularString, ValueMapping.literalToString)
72+
return this.singular(Example.hasNoSingularString, ValueMapping.literalToString)
7373
}
7474

7575
public get hasTooManySingularString(): string {
76-
return this.getSingular(Example.hasTooManySingularString, ValueMapping.literalToString)
76+
return this.singular(Example.hasTooManySingularString, ValueMapping.literalToString)
7777
}
7878

7979
public get hasNullableString(): string | undefined {
80-
return this.getSingularNullable(Example.hasNullableString, ValueMapping.literalToString)
80+
return this.singularNullable(Example.hasNullableString, ValueMapping.literalToString)
8181
}
8282

8383
public set hasNullableString(value: string | undefined ) {
84-
this.setSingularNullable(Example.hasNullableString, value, TermMapping.stringToLiteral)
84+
this.overwriteNullable(Example.hasNullableString, value, TermMapping.stringToLiteral)
8585
}
8686

8787

8888
/* Set Mapping */
8989
public get hasChildSet(): Set<Child> {
90-
return this.getSet(Example.hasChildSet, ObjectMapping.as(Child), ObjectMapping.as(Child))
90+
return this.objects(Example.hasChildSet, ObjectMapping.as(Child), ObjectMapping.as(Child))
9191
}
9292

9393
public get hasLangStringSet(): Set<ILangString> {
94-
return this.getSet(Example.hasLangStringSet, ValueMapping.literalToLangString, TermMapping.langStringToLiteral)
94+
return this.objects(Example.hasLangStringSet, ValueMapping.literalToLangString, TermMapping.langStringToLiteral)
9595
}
9696

9797

9898
/* Recursion Mapping */
9999
public get hasRecursive(): Parent {
100-
return this.getSingular(Example.hasRecursive, ObjectMapping.as(Parent))
100+
return this.singular(Example.hasRecursive, ObjectMapping.as(Parent))
101101
}
102102

103103
public set hasRecursive(value: string | undefined) {
104-
this.setSingularNullable(Example.hasRecursive, value, TermMapping.stringToIri)
104+
this.overwriteNullable(Example.hasRecursive, value, TermMapping.stringToIri)
105105
}
106106
}

0 commit comments

Comments
 (0)