-
Notifications
You must be signed in to change notification settings - Fork 0
/
anchoring-applier.go
46 lines (40 loc) · 1.17 KB
/
anchoring-applier.go
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package anchoring
import (
"fmt"
"github.com/Azbesciak/RealDecisionMaker/lib/model"
)
//go:generate easytags $GOFILE json:camel
type AnchoringApplier interface {
FunctionBase
ApplyAnchoring(
dmp *model.DecisionMakingParams,
perReferencePointDiffs *[]ReferencePointsDifference,
boundingsWithScales BoundingsWithScales,
params FunctionParams,
listener *model.BiasListener,
) (*model.DecisionMakingParams, AnchoringApplierResult)
}
type AnchoringApplierResult = interface{}
type ApplierWithParams struct {
fun AnchoringApplier
params FunctionParams
}
func (a *Anchoring) getAnchoringApplier(params *FunctionDefinition) ApplierWithParams {
for _, fun := range a.anchoringAppliers {
if fun.Identifier() == params.Function {
return ApplierWithParams{
fun: fun,
params: parseFuncParams(fun, params),
}
}
}
existing := a.knownAnchoringAppliersNames()
panic(fmt.Errorf("anchoring applier function '%s' not found in %v", params.Function, existing))
}
func (a *Anchoring) knownAnchoringAppliersNames() []string {
existing := make([]string, len(a.anchoringAppliers))
for i, id := range a.anchoringAppliers {
existing[i] = id.Identifier()
}
return existing
}