001: package org.andromda.metafacades.emf.uml2;
002:
003: import org.andromda.metafacades.uml.NameMasker;
004: import org.andromda.metafacades.uml.UMLMetafacadeProperties;
005: import org.andromda.metafacades.uml.UMLMetafacadeUtils;
006: import org.andromda.metafacades.uml.UMLProfile;
007: import org.apache.commons.lang.StringUtils;
008: import org.eclipse.uml2.Activity;
009: import org.eclipse.uml2.Element;
010: import org.eclipse.uml2.Operation;
011: import org.eclipse.uml2.ParameterDirectionKind;
012:
013: /**
014: * MetafacadeLogic implementation for
015: * org.andromda.metafacades.uml.ParameterFacade.
016: *
017: * @see org.andromda.metafacades.uml.ParameterFacade
018: */
019: public class ParameterFacadeLogicImpl extends ParameterFacadeLogic {
020: public ParameterFacadeLogicImpl(
021: final org.eclipse.uml2.Parameter metaObject,
022: final String context) {
023: super (metaObject, context);
024: }
025:
026: /**
027: * @see org.andromda.metafacades.uml.ParameterFacade#getDefaultValue()
028: */
029: protected java.lang.String handleGetDefaultValue() {
030: return this .metaObject.getDefault();
031: }
032:
033: /**
034: * Overridden to provide name masking.
035: *
036: * @see org.andromda.metafacades.uml.ModelElementFacade#getName()
037: */
038: protected String handleGetName() {
039: final String nameMask = String
040: .valueOf(this
041: .getConfiguredProperty(UMLMetafacadeProperties.PARAMETER_NAME_MASK));
042: return NameMasker.mask(super .handleGetName(), nameMask);
043: }
044:
045: /**
046: * @see org.andromda.metafacades.uml.ParameterFacade#isReturn()
047: */
048: protected boolean handleIsReturn() {
049: return this .metaObject.getDirection().equals(
050: ParameterDirectionKind.RETURN_LITERAL);
051: }
052:
053: /**
054: * @see org.andromda.metafacades.uml.ParameterFacade#isRequired()
055: */
056: protected boolean handleIsRequired() {
057: return !this .hasStereotype(UMLProfile.STEREOTYPE_NULLABLE);
058: }
059:
060: /**
061: * @see org.andromda.metafacades.uml.ParameterFacade#getGetterName()
062: */
063: protected java.lang.String handleGetGetterName() {
064: return UMLMetafacadeUtils.getGetterPrefix(this .getType())
065: + StringUtils.capitalize(this .getName());
066: }
067:
068: /**
069: * @see org.andromda.metafacades.uml.ParameterFacade#getSetterName()
070: */
071: protected java.lang.String handleGetSetterName() {
072: return "set" + StringUtils.capitalize(this .getName());
073: }
074:
075: /**
076: * @see org.andromda.metafacades.uml.ParameterFacade#isReadable()
077: */
078: protected boolean handleIsReadable() {
079: return this .isInParameter() || this .isInoutParameter();
080: }
081:
082: /**
083: * @see org.andromda.metafacades.uml.ParameterFacade#isWritable()
084: */
085: protected boolean handleIsWritable() {
086: return this .isOutParameter() || this .isInoutParameter();
087: }
088:
089: /**
090: * @see org.andromda.metafacades.uml.ParameterFacade#isDefaultValuePresent()
091: */
092: protected boolean handleIsDefaultValuePresent() {
093: return StringUtils.isNotBlank(this .getDefaultValue());
094: }
095:
096: /**
097: * @see org.andromda.metafacades.uml.ParameterFacade#isInParameter()
098: */
099: protected boolean handleIsInParameter() {
100: return this .metaObject.getDirection().equals(
101: ParameterDirectionKind.IN_LITERAL);
102: }
103:
104: /**
105: * @see org.andromda.metafacades.uml.ParameterFacade#isOutParameter()
106: */
107: protected boolean handleIsOutParameter() {
108: return this .metaObject.getDirection().equals(
109: ParameterDirectionKind.OUT_LITERAL);
110: }
111:
112: /**
113: * @see org.andromda.metafacades.uml.ParameterFacade#isInoutParameter()
114: */
115: protected boolean handleIsInoutParameter() {
116: return this .metaObject.getDirection().equals(
117: ParameterDirectionKind.INOUT_LITERAL);
118: }
119:
120: /**
121: * @see org.andromda.metafacades.uml.ParameterFacade#getOperation()
122: */
123: protected java.lang.Object handleGetOperation() {
124: Object owner = this .metaObject.getOwner();
125: if (owner instanceof Operation) {
126: return owner;
127: }
128: return null;
129: }
130:
131: /**
132: * @see org.andromda.metafacades.uml.ParameterFacade#getEvent()
133: */
134: protected java.lang.Object handleGetEvent() {
135: Element owner = this .metaObject.getOwner();
136: if (owner instanceof Activity) {
137: return owner;
138: }
139: return null;
140: }
141:
142: /**
143: * @see org.andromda.metafacades.uml.ParameterFacade#getType()
144: */
145: protected java.lang.Object handleGetType() {
146: return this .metaObject.getType();
147: }
148:
149: /**
150: * @see org.andromda.core.metafacade.MetafacadeBase#getValidationOwner()
151: */
152: public Object getValidationOwner() {
153: Object owner = this .getOperation();
154: if (owner == null) {
155: owner = this .getEvent();
156: }
157: return owner;
158: }
159:
160: /**
161: * Get the UML upper multiplicity Not implemented for UML1.4
162: */
163: protected int handleGetUpper() {
164: return UmlUtilities.parseMultiplicity(this .metaObject
165: .getUpperValue());
166: }
167:
168: /**
169: * Get the UML lower multiplicity Not implemented for UML1.4
170: */
171: protected int handleGetLower() {
172: return UmlUtilities.parseMultiplicity(this.metaObject
173: .getLowerValue());
174: }
175: }
|