001package org.andromda.metafacades.uml14; 002 003import java.util.Collection; 004import org.apache.commons.lang.StringUtils; 005import org.omg.uml.foundation.core.Dependency; 006 007/** 008 * Metaclass facade implementation. 009 * @author Bob Fields 010 */ 011public class DependencyFacadeLogicImpl 012 extends DependencyFacadeLogic 013{ 014 private static final long serialVersionUID = 34L; 015 /** 016 * @param metaObject 017 * @param context 018 */ 019 public DependencyFacadeLogicImpl(Dependency metaObject, String context) 020 { 021 super(metaObject, context); 022 } 023 024 /** 025 * Gets the name in the following manner. <ol> <li>If the dependency has a name return it.</li> <li>If the 026 * dependency does <strong>NOT </strong> have a name, get the target element's and return its name 027 * uncapitalized.</li> </ol> 028 * 029 * @see org.andromda.metafacades.uml.ModelElementFacade#getName() 030 */ 031 @Override 032 public String handleGetName() 033 { 034 String name = super.handleGetName(); 035 if (StringUtils.isBlank(name) && this.getTargetElement() != null) 036 { 037 name = StringUtils.uncapitalize(this.getTargetElement().getName()); 038 } 039 return name; 040 } 041 042 /** 043 * @see org.andromda.metafacades.uml.DependencyFacade#getGetterName() 044 */ 045 @Override 046 public String handleGetGetterName() 047 { 048 return "get" + StringUtils.capitalize(this.getName()); 049 } 050 051 /** 052 * @see org.andromda.metafacades.uml.DependencyFacade#getSetterName() 053 */ 054 @Override 055 public String handleGetSetterName() 056 { 057 return "set" + StringUtils.capitalize(this.getName()); 058 } 059 060 /** 061 * @see org.andromda.metafacades.uml.DependencyFacade#getTargetElement() 062 */ 063 @Override 064 public Object handleGetTargetElement() 065 { 066 Object targetElement = null; 067 Collection suppliers = UML14MetafacadeUtils.getCorePackage().getASupplierSupplierDependency().getSupplier( 068 this.metaObject); 069 if (!suppliers.isEmpty()) 070 { 071 targetElement = suppliers.iterator().next(); 072 } 073 return targetElement; 074 } 075 076 /** 077 * @see org.andromda.metafacades.uml.DependencyFacade#getSourceElement() 078 */ 079 @Override 080 protected Object handleGetSourceElement() 081 { 082 Object sourceElement = null; 083 Collection clients = UML14MetafacadeUtils.getCorePackage().getAClientClientDependency().getClient( 084 this.metaObject); 085 if (!clients.isEmpty()) 086 { 087 sourceElement = clients.iterator().next(); 088 } 089 return sourceElement; 090 } 091 092}