001// license-header java merge-point 002// 003// Attention: generated code (by MetafacadeLogic.vsl) - do not modify! 004// 005package org.andromda.metafacades.uml14; 006 007import java.util.Collection; 008import org.andromda.core.metafacade.MetafacadeBase; 009import org.andromda.core.metafacade.ModelValidationMessage; 010import org.andromda.metafacades.uml.DependencyFacade; 011import org.andromda.metafacades.uml.ModelElementFacade; 012import org.apache.log4j.Logger; 013import org.omg.uml.foundation.core.Dependency; 014 015/** 016 * A representation of the model object 'Directed Relationship'.Represents a relationship between a 017 * collection of source model elements and a collection of target model elements, a 018 * dependency/reference. 019 * MetafacadeLogic for DependencyFacade 020 * 021 * @see DependencyFacade 022 */ 023public abstract class DependencyFacadeLogic 024 extends ModelElementFacadeLogicImpl 025 implements DependencyFacade 026{ 027 /** 028 * The underlying UML object 029 * @see Dependency 030 */ 031 protected Dependency metaObject; 032 033 /** Create Metafacade implementation instance using the MetafacadeFactory from the context 034 * @param metaObjectIn 035 * @param context 036 */ 037 protected DependencyFacadeLogic(Dependency metaObjectIn, String context) 038 { 039 super(metaObjectIn, getContext(context)); 040 this.metaObject = metaObjectIn; 041 } 042 043 /** 044 * The logger instance. 045 */ 046 private static final Logger logger = Logger.getLogger(DependencyFacadeLogic.class); 047 048 /** 049 * Gets the context for this metafacade logic instance. 050 * @param context String. Set to DependencyFacade if null 051 * @return context String 052 */ 053 private static String getContext(String context) 054 { 055 if (context == null) 056 { 057 context = "org.andromda.metafacades.uml.DependencyFacade"; 058 } 059 return context; 060 } 061 062 /** Reset context only for non-root metafacades 063 * @param context 064 */ 065 @Override 066 public void resetMetafacadeContext(String context) 067 { 068 if (!this.contextRoot) // reset context only for non-root metafacades 069 { 070 context = getContext(context); // to have same value as in original constructor call 071 setMetafacadeContext (context); 072 } 073 } 074 075 /** 076 * @return boolean true always 077 * @see DependencyFacade 078 */ 079 public boolean isDependencyFacadeMetaType() 080 { 081 return true; 082 } 083 084 // --------------- attributes --------------------- 085 086 /** 087 * @see DependencyFacade#getGetterName() 088 * @return String 089 */ 090 protected abstract String handleGetGetterName(); 091 092 private String __getterName1a; 093 private boolean __getterName1aSet = false; 094 095 /** 096 * The "getter" name for this dependency. 097 * @return (String)handleGetGetterName() 098 */ 099 public final String getGetterName() 100 { 101 String getterName1a = this.__getterName1a; 102 if (!this.__getterName1aSet) 103 { 104 // getterName has no pre constraints 105 getterName1a = handleGetGetterName(); 106 // getterName has no post constraints 107 this.__getterName1a = getterName1a; 108 if (isMetafacadePropertyCachingEnabled()) 109 { 110 this.__getterName1aSet = true; 111 } 112 } 113 return getterName1a; 114 } 115 116 /** 117 * @see DependencyFacade#getSetterName() 118 * @return String 119 */ 120 protected abstract String handleGetSetterName(); 121 122 private String __setterName2a; 123 private boolean __setterName2aSet = false; 124 125 /** 126 * The "setter" name for this dependency. 127 * @return (String)handleGetSetterName() 128 */ 129 public final String getSetterName() 130 { 131 String setterName2a = this.__setterName2a; 132 if (!this.__setterName2aSet) 133 { 134 // setterName has no pre constraints 135 setterName2a = handleGetSetterName(); 136 // setterName has no post constraints 137 this.__setterName2a = setterName2a; 138 if (isMetafacadePropertyCachingEnabled()) 139 { 140 this.__setterName2aSet = true; 141 } 142 } 143 return setterName2a; 144 } 145 146 // ------------- associations ------------------ 147 148 /** 149 * Gets the dependencies for which this model element is the source. 150 * @return (ModelElementFacade)handleGetSourceElement() 151 */ 152 public final ModelElementFacade getSourceElement() 153 { 154 ModelElementFacade getSourceElement1r = null; 155 // sourceDependencies has no pre constraints 156 Object result = handleGetSourceElement(); 157 MetafacadeBase shieldedResult = this.shieldedElement(result); 158 try 159 { 160 getSourceElement1r = (ModelElementFacade)shieldedResult; 161 } 162 catch (ClassCastException ex) 163 { 164 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 165 DependencyFacadeLogic.logger.warn("incorrect metafacade cast for DependencyFacadeLogic.getSourceElement ModelElementFacade " + result + ": " + shieldedResult); 166 } 167 // sourceDependencies has no post constraints 168 return getSourceElement1r; 169 } 170 171 /** 172 * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type 173 * @return Object 174 */ 175 protected abstract Object handleGetSourceElement(); 176 177 /** 178 * Gets the dependencies for which this model element is the target. 179 * @return (ModelElementFacade)handleGetTargetElement() 180 */ 181 public final ModelElementFacade getTargetElement() 182 { 183 ModelElementFacade getTargetElement2r = null; 184 // targetDependencies has no pre constraints 185 Object result = handleGetTargetElement(); 186 MetafacadeBase shieldedResult = this.shieldedElement(result); 187 try 188 { 189 getTargetElement2r = (ModelElementFacade)shieldedResult; 190 } 191 catch (ClassCastException ex) 192 { 193 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 194 DependencyFacadeLogic.logger.warn("incorrect metafacade cast for DependencyFacadeLogic.getTargetElement ModelElementFacade " + result + ": " + shieldedResult); 195 } 196 // targetDependencies has no post constraints 197 return getTargetElement2r; 198 } 199 200 /** 201 * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type 202 * @return Object 203 */ 204 protected abstract Object handleGetTargetElement(); 205 206 /** 207 * @param validationMessages Collection<ModelValidationMessage> 208 * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages) 209 */ 210 @Override 211 public void validateInvariants(Collection<ModelValidationMessage> validationMessages) 212 { 213 super.validateInvariants(validationMessages); 214 } 215}