01: package org.andromda.cartridges.hibernate.metafacades;
02:
03: import org.andromda.metafacades.uml.ClassifierFacade;
04:
05: /**
06: * MetafacadeLogic implementation for
07: * org.andromda.cartridges.hibernate.metafacades.HibernateFinderMethodArgument.
08: *
09: * @see org.andromda.cartridges.hibernate.metafacades.HibernateFinderMethodArgument
10: */
11: public class HibernateFinderMethodArgumentLogicImpl extends
12: HibernateFinderMethodArgumentLogic {
13: // ---------------- constructor -------------------------------
14: public HibernateFinderMethodArgumentLogicImpl(Object metaObject,
15: String context) {
16: super (metaObject, context);
17: }
18:
19: /**
20: * Defines if specific setters methods will be created for primitive types
21: * and dates
22: */
23: private static final String USE_SPECIALIZED_SETTERS = "hibernateQueryUseSpecializedSetters";
24:
25: /**
26: * @see org.andromda.cartridges.hibernate.metafacades.HibernateFinderMethodArgument#getQueryArgumentNameSetter()
27: */
28: protected java.lang.String handleGetQueryArgumentNameSetter() {
29: StringBuffer setterName = new StringBuffer();
30: boolean specializedSetters = Boolean
31: .valueOf(
32: String
33: .valueOf(this
34: .getConfiguredProperty(USE_SPECIALIZED_SETTERS)))
35: .booleanValue();
36: ClassifierFacade classifier = this .getType();
37: if (classifier != null) {
38: if (specializedSetters) {
39: if (classifier.isPrimitive()) {
40: setterName.append("set"
41: + classifier.getWrapperName().replaceAll(
42: "(.)*\\.", ""));
43: } else if (classifier.isDateType()
44: || classifier.isStringType()) {
45: setterName.append("set" + classifier.getName());
46: } else {
47: setterName.append("setParameter");
48: }
49: } else {
50: setterName.append("setParameter");
51: }
52: if (classifier.isCollectionType()) {
53: setterName.append("List");
54: }
55: }
56: return setterName.toString();
57: }
58: }
|