1 17 package org.eclipse.emf.ecore.impl; 18 19 20 import java.util.HashMap ; 21 22 import org.eclipse.emf.ecore.EPackage; 23 import org.eclipse.emf.ecore.EValidator; 24 25 import org.eclipse.emf.ecore.util.EObjectValidator; 26 27 28 31 public class EValidatorRegistryImpl extends HashMap implements EValidator.Registry 32 { 33 protected EValidator.Registry delegateRegistry; 34 35 public EValidatorRegistryImpl() 36 { 37 } 38 39 public EValidatorRegistryImpl(EValidator.Registry delegateRegistry) 40 { 41 this.delegateRegistry = delegateRegistry; 42 } 43 44 public Object get(Object key) 45 { 46 Object eValidator = super.get(key); 47 if (eValidator instanceof EValidator.Descriptor) 48 { 49 EValidator.Descriptor eValidatorDescriptor = (EValidator.Descriptor)eValidator; 50 eValidator = eValidatorDescriptor.getEValidator(); 51 put(key, eValidator); 52 return eValidator; 53 } 54 else if (eValidator != null) 55 { 56 return eValidator; 57 } 58 else 59 { 60 return delegatedGet(key); 61 } 62 } 63 64 public EValidator getEValidator(EPackage ePackage) 65 { 66 return (EValidator)get(ePackage); 67 } 68 69 protected Object delegatedGet(Object key) 70 { 71 if (delegateRegistry != null) 72 { 73 return delegateRegistry.get(key); 74 } 75 76 return key == null ? EObjectValidator.INSTANCE : null; 77 } 78 79 public boolean containsKey(Object key) 80 { 81 return super.containsKey(key) || delegateRegistry != null && delegateRegistry.containsKey(key); 82 } 83 } 84 | Popular Tags |