...
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 package gojsonschema
27
28 import (
29 "fmt"
30 )
31
32 type schemaReferencePool struct {
33 documents map[string]*subSchema
34 }
35
36 func newSchemaReferencePool() *schemaReferencePool {
37
38 p := &schemaReferencePool{}
39 p.documents = make(map[string]*subSchema)
40
41 return p
42 }
43
44 func (p *schemaReferencePool) Get(ref string) (r *subSchema, o bool) {
45
46 if internalLogEnabled {
47 internalLog(fmt.Sprintf("Schema Reference ( %s )", ref))
48 }
49
50 if sch, ok := p.documents[ref]; ok {
51 if internalLogEnabled {
52 internalLog(fmt.Sprintf(" From pool"))
53 }
54 return sch, true
55 }
56
57 return nil, false
58 }
59
60 func (p *schemaReferencePool) Add(ref string, sch *subSchema) {
61
62 if internalLogEnabled {
63 internalLog(fmt.Sprintf("Add Schema Reference %s to pool", ref))
64 }
65 if _, ok := p.documents[ref]; !ok {
66 p.documents[ref] = sch
67 }
68 }
69
View as plain text