1 17 package org.alfresco.repo.policy; 18 19 import java.util.ArrayList ; 20 import java.util.Collection ; 21 import java.util.HashMap ; 22 import java.util.List ; 23 import java.util.Map ; 24 25 26 33 class BehaviourMap<B extends BehaviourBinding> 34 { 35 38 private Map <B, BehaviourDefinition<B>> index = new HashMap <B, BehaviourDefinition<B>>(); 39 40 43 private List <BehaviourChangeObserver<B>> observers = new ArrayList <BehaviourChangeObserver<B>>(); 44 45 46 51 public void put(BehaviourDefinition<B> behaviourDefinition) 52 { 53 B binding = behaviourDefinition.getBinding(); 54 index.put(binding, behaviourDefinition); 55 for (BehaviourChangeObserver<B> listener : observers) 56 { 57 listener.addition(binding, behaviourDefinition.getBehaviour()); 58 } 59 } 60 61 62 68 public BehaviourDefinition<B> get(B binding) 69 { 70 return index.get(binding); 71 } 72 73 74 79 public Collection <BehaviourDefinition<B>> getAll() 80 { 81 return index.values(); 82 } 83 84 85 90 public int size() 91 { 92 return index.size(); 93 } 94 95 96 101 public void addChangeObserver(BehaviourChangeObserver<B> observer) 102 { 103 observers.add(observer); 104 } 105 106 } 107 | Popular Tags |