001package org.andromda.metafacades.uml14; 002 003import java.util.Collection; 004import java.util.Iterator; 005import java.util.TreeSet; 006import org.andromda.metafacades.uml.GeneralizableElementFacade; 007import org.andromda.metafacades.uml.StereotypeFacade; 008 009/** 010 * MetafacadeLogic implementation for org.andromda.metafacades.uml.ValueObject. 011 * 012 * @see org.andromda.metafacades.uml.ValueObject 013 * @author Bob Fields 014 */ 015public class ValueObjectLogicImpl 016 extends ValueObjectLogic 017{ 018 private static final long serialVersionUID = 6729122952696837826L; 019 // ---------------- constructor ------------------------------- 020 021 /** 022 * @param metaObject 023 * @param context 024 */ 025 public ValueObjectLogicImpl(Object metaObject, String context) 026 { 027 super(metaObject, context); 028 } 029 030 /** 031 * @return specializations 032 * @see org.andromda.metafacades.uml.ValueObject#getTypeSpecializations() 033 */ 034 @Override 035 protected Collection<ValueObjectLogic> handleGetTypeSpecializations() 036 { 037 StringBuilder stereotypes = new StringBuilder(); 038 for (final Iterator<StereotypeFacade> iterator = this.getStereotypes().iterator(); iterator.hasNext();) 039 { 040 stereotypes.append(iterator.next().getName()).append(','); 041 } 042 return this.handleGetTypeSpecializations(stereotypes.toString()); 043 } 044 045 /** 046 * @param stereotypes 047 * @return specializations 048 */ 049 protected Collection<ValueObjectLogic> handleGetTypeSpecializations(String stereotypes) 050 { 051 Collection<ValueObjectLogic> specializations = new TreeSet<ValueObjectLogic>(); 052 String[] stereotypeList = stereotypes.split(",", -1); 053 for (final Iterator<GeneralizableElementFacade> iterator = this.getAllSpecializations().iterator(); iterator.hasNext();) 054 { 055 final GeneralizableElementFacade classifier = iterator.next(); 056 if (classifier instanceof ValueObjectLogic) 057 { 058 for (int i=0; i<stereotypeList.length; i++) 059 { 060 if (classifier.hasStereotype(stereotypeList[i]) && !specializations.contains(classifier)) 061 { 062 specializations.add((ValueObjectLogic) classifier); 063 } 064 } 065 } 066 } 067 return specializations; 068 } 069}