1 17 package org.alfresco.repo.policy; 18 19 import org.alfresco.service.cmr.dictionary.ClassDefinition; 20 import org.alfresco.service.cmr.dictionary.DictionaryService; 21 import org.alfresco.service.cmr.repository.NodeRef; 22 import org.alfresco.service.namespace.QName; 23 24 25 31 class ClassFeatureBehaviourBinding extends ClassBehaviourBinding 32 { 33 private QName featureQName; 35 private QName activeFeatureQName; 36 37 private static final QName ALL_FEATURES = QName.createQName("", "*"); 39 40 41 49 ClassFeatureBehaviourBinding(DictionaryService dictionary, NodeRef nodeRef, QName classQName, QName featureQName) 50 { 51 this(dictionary, nodeRef, classQName, featureQName, featureQName); 52 } 53 54 55 62 ClassFeatureBehaviourBinding(DictionaryService dictionary, QName classQName, QName featureQName) 63 { 64 this(dictionary, null, classQName, featureQName, featureQName); 65 } 66 67 68 75 ClassFeatureBehaviourBinding(DictionaryService dictionary, NodeRef nodeRef, QName classQName) 76 { 77 this(dictionary, nodeRef, classQName, ALL_FEATURES); 78 } 79 80 81 87 ClassFeatureBehaviourBinding(DictionaryService dictionary, QName classQName) 88 { 89 this(dictionary, null, classQName, ALL_FEATURES); 90 } 91 92 93 102 private ClassFeatureBehaviourBinding(DictionaryService dictionary, NodeRef nodeRef, QName classQName, QName featureQName, QName activeFeatureQName) 103 { 104 super(dictionary, nodeRef, classQName); 105 this.featureQName = featureQName; 106 this.activeFeatureQName = activeFeatureQName; 107 } 108 109 110 113 public BehaviourBinding generaliseBinding() 114 { 115 BehaviourBinding generalisedBinding = null; 116 ClassDefinition classDefinition = getDictionary().getClass(getClassQName()); 117 118 if (activeFeatureQName.equals(ALL_FEATURES)) 119 { 120 QName parentClassName = classDefinition.getParentName(); 121 if (parentClassName != null) 122 { 123 generalisedBinding = new ClassFeatureBehaviourBinding(getDictionary(), getNodeRef(), parentClassName, featureQName, featureQName); 124 } 125 } 126 else 127 { 128 generalisedBinding = new ClassFeatureBehaviourBinding(getDictionary(), getNodeRef(), getClassQName(), featureQName, ALL_FEATURES); 129 } 130 131 return generalisedBinding; 132 } 133 134 @Override 135 public boolean equals(Object obj) 136 { 137 if (obj == null || !(obj instanceof ClassFeatureBehaviourBinding)) 138 { 139 return false; 140 } 141 return getClassQName().equals(((ClassFeatureBehaviourBinding)obj).getClassQName()) && 142 activeFeatureQName.equals(((ClassFeatureBehaviourBinding)obj).activeFeatureQName); 143 } 144 145 @Override 146 public int hashCode() 147 { 148 return 37 * getClassQName().hashCode() + activeFeatureQName.hashCode(); 149 } 150 151 @Override 152 public String toString() 153 { 154 return "ClassFeatureBinding[class=" + getClassQName() + ";feature=" + activeFeatureQName + "]"; 155 } 156 157 } 158 | Popular Tags |