]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ComposedTGValueModifier.java
Fail safe import fixes made by Antti
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / util / ComposedTGValueModifier.java
1 package org.simantics.db.layer0.util;
2
3 import org.simantics.databoard.binding.Binding;
4 import org.simantics.databoard.type.Datatype;
5 import org.simantics.db.exception.DatabaseException;
6
7 public class ComposedTGValueModifier implements TGValueModifier {
8
9         final TGValueModifier[] modifiers;
10         
11         public ComposedTGValueModifier(TGValueModifier[] modifiers) {
12                 this.modifiers = modifiers;
13         }
14         
15         @Override
16         public boolean mayNeedModification(Datatype type) throws DatabaseException {
17                 for(TGValueModifier mod : modifiers)
18                         if(mod.mayNeedModification(type))
19                                 return true;
20                 return false;
21         }
22
23         @Override
24         public Object modify(final DomainProcessorState state, Binding binding, Object value) throws DatabaseException {
25
26                 Datatype type = binding.type();
27                 
28                 for(TGValueModifier mod : modifiers)
29                         if(mod.mayNeedModification(type))
30                                 value = mod.modify(state, binding, value);
31                 
32                 return value;
33                 
34         }
35
36 }