28
28
import com .techsenger .ansi4j .css .api .attribute .AttributeRegistry ;
29
29
import com .techsenger .ansi4j .css .api .GroupStyleGenerator ;
30
30
import com .techsenger .ansi4j .css .api .ProcessorResult ;
31
- import com .techsenger .ansi4j .css .api .TargetControl ;
32
31
33
32
/**
34
33
*
@@ -38,8 +37,7 @@ public final class StyleProcessorImpl implements StyleProcessor {
38
37
39
38
private final Map <Function , FunctionEvaluator > evaluatorsByFunction = new HashMap <>();
40
39
41
- private final Map <TargetControl , Map <AttributeGroup .Key <?>, GroupStyleGenerator <?>>>
42
- generatorsByControlAndGroupKey = new HashMap <>();
40
+ private final Map <AttributeGroup .Key <?>, GroupStyleGenerator <?>> generatorsByGroupKey = new HashMap <>();
43
41
44
42
private final AttributeRegistryImpl attributeRegistry ;
45
43
@@ -52,24 +50,13 @@ public StyleProcessorImpl(StyleProcessorConfig config) {
52
50
config .getGenerators ().forEach (g -> {
53
51
var group = this .attributeRegistry .getGroup (g .getGroupKey ());
54
52
((GroupStyleGenerator ) g ).initialize (group );
55
-
56
- var generatorsByGroupAndKey = this .generatorsByControlAndGroupKey .get (g .getTargetControl ());
57
- if (generatorsByGroupAndKey == null ) {
58
- generatorsByGroupAndKey = new HashMap <>();
59
- this .generatorsByControlAndGroupKey .put (g .getTargetControl (), generatorsByGroupAndKey );
60
- }
61
- generatorsByGroupAndKey .put (g .getGroupKey (), g );
53
+ generatorsByGroupKey .put (g .getGroupKey (), g );
62
54
});
63
55
}
64
56
65
57
@ Override
66
- public <T extends AttributeGroup <T >> GroupStyleGenerator <T > getGenerator (TargetControl targetControl ,
67
- AttributeGroup .Key <T > key ) {
68
- var generatorsByGroup = this .generatorsByControlAndGroupKey .get (targetControl );
69
- if (generatorsByGroup == null ) {
70
- return null ;
71
- }
72
- return (GroupStyleGenerator <T >) generatorsByGroup .get (key );
58
+ public <T extends AttributeGroup <T >> GroupStyleGenerator <T > getGenerator (AttributeGroup .Key <T > key ) {
59
+ return (GroupStyleGenerator <T >) generatorsByGroupKey .get (key );
73
60
}
74
61
75
62
@ Override
@@ -78,19 +65,16 @@ public AttributeRegistry getAttributeRegistry() {
78
65
}
79
66
80
67
@ Override
81
- public ProcessorResult process (FunctionFragment functionFragment , TargetControl targetControl ) {
68
+ public ProcessorResult process (FunctionFragment functionFragment ) {
82
69
var result = new ProcessorResultImpl ();
83
70
var function = functionFragment .getFunction ();
84
71
var evaluator = this .evaluatorsByFunction .get (function );
85
72
if (evaluator != null ) {
86
73
evaluator .evaluate (functionFragment , result );
87
74
this .attributeRegistry .applyChanges (result .getAttributeChanges ());
88
- var generatorsByGroup = this .generatorsByControlAndGroupKey .get (targetControl );
89
- if (generatorsByGroup != null ) {
90
- for (var generator : generatorsByGroup .values ()) {
91
- var declarations = generator .generate ();
92
- result .getStyleDeclarations ().addAll (declarations );
93
- }
75
+ for (var generator : generatorsByGroupKey .values ()) {
76
+ var declarations = generator .generate ();
77
+ result .getStyleDeclarations ().addAll (declarations );
94
78
}
95
79
}
96
80
result .makeListsUnmodifiable ();
0 commit comments