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 java.util.List; 009import org.andromda.core.metafacade.ModelValidationMessage; 010import org.andromda.metafacades.uml.ValueObject; 011import org.apache.log4j.Logger; 012import org.omg.uml.foundation.core.Classifier; 013 014/** 015 * Represents a value object, a Classifier whose unique value is determined only by its attributes. 016 * MetafacadeLogic for ValueObject 017 * 018 * @see ValueObject 019 */ 020public abstract class ValueObjectLogic 021 extends ClassifierFacadeLogicImpl 022 implements ValueObject 023{ 024 /** 025 * The underlying UML object 026 * @see Object 027 */ 028 protected Object metaObject; 029 030 /** Create Metafacade implementation instance using the MetafacadeFactory from the context 031 * @param metaObjectIn 032 * @param context 033 */ 034 protected ValueObjectLogic(Object metaObjectIn, String context) 035 { 036 super((Classifier)metaObjectIn, getContext(context)); 037 this.metaObject = metaObjectIn; 038 } 039 040 /** 041 * The logger instance. 042 */ 043 private static final Logger logger = Logger.getLogger(ValueObjectLogic.class); 044 045 /** 046 * Gets the context for this metafacade logic instance. 047 * @param context String. Set to ValueObject if null 048 * @return context String 049 */ 050 private static String getContext(String context) 051 { 052 if (context == null) 053 { 054 context = "org.andromda.metafacades.uml.ValueObject"; 055 } 056 return context; 057 } 058 059 /** Reset context only for non-root metafacades 060 * @param context 061 */ 062 @Override 063 public void resetMetafacadeContext(String context) 064 { 065 if (!this.contextRoot) // reset context only for non-root metafacades 066 { 067 context = getContext(context); // to have same value as in original constructor call 068 setMetafacadeContext (context); 069 } 070 } 071 072 /** 073 * @return boolean true always 074 * @see ValueObject 075 */ 076 public boolean isValueObjectMetaType() 077 { 078 return true; 079 } 080 081 // ------------- associations ------------------ 082 083 private Collection<ValueObject> __getTypeSpecializations1r; 084 private boolean __getTypeSpecializations1rSet = false; 085 086 /** 087 * Represents a value object, a Classifier whose unique value is determined only by its 088 * attributes. 089 * @return (Collection<ValueObject>)handleGetTypeSpecializations() 090 */ 091 public final Collection<ValueObject> getTypeSpecializations() 092 { 093 Collection<ValueObject> getTypeSpecializations1r = this.__getTypeSpecializations1r; 094 if (!this.__getTypeSpecializations1rSet) 095 { 096 // valueObject has no pre constraints 097 Collection result = handleGetTypeSpecializations(); 098 List shieldedResult = this.shieldedElements(result); 099 try 100 { 101 getTypeSpecializations1r = (Collection<ValueObject>)shieldedResult; 102 } 103 catch (ClassCastException ex) 104 { 105 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 106 ValueObjectLogic.logger.warn("incorrect metafacade cast for ValueObjectLogic.getTypeSpecializations Collection<ValueObject> " + result + ": " + shieldedResult); 107 } 108 // valueObject has no post constraints 109 this.__getTypeSpecializations1r = getTypeSpecializations1r; 110 if (isMetafacadePropertyCachingEnabled()) 111 { 112 this.__getTypeSpecializations1rSet = true; 113 } 114 } 115 return getTypeSpecializations1r; 116 } 117 118 /** 119 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 120 * @return Collection 121 */ 122 protected abstract Collection handleGetTypeSpecializations(); 123 124 /** 125 * @param validationMessages Collection<ModelValidationMessage> 126 * @see ClassifierFacadeLogicImpl#validateInvariants(Collection validationMessages) 127 */ 128 @Override 129 public void validateInvariants(Collection<ModelValidationMessage> validationMessages) 130 { 131 super.validateInvariants(validationMessages); 132 } 133}