1 package org.andromda.cartridges.hibernate.metafacades;
2
3 import org.andromda.metafacades.uml.ClassifierFacade;
4
5
6
7
8
9
10
11 public class HibernateFinderMethodArgumentLogicImpl
12 extends HibernateFinderMethodArgumentLogic
13 {
14 private static final long serialVersionUID = 34L;
15
16
17
18
19
20 public HibernateFinderMethodArgumentLogicImpl(
21 Object metaObject,
22 String context)
23 {
24 super(metaObject, context);
25 }
26
27
28
29
30
31 private static final String USE_SPECIALIZED_SETTERS = "hibernateQueryUseSpecializedSetters";
32
33
34
35
36 @Override
37 protected String handleGetQueryArgumentNameSetter()
38 {
39 StringBuilder setterName = new StringBuilder();
40 boolean specializedSetters =
41 Boolean.valueOf(String.valueOf(this.getConfiguredProperty(USE_SPECIALIZED_SETTERS))).booleanValue();
42 ClassifierFacade classifier = this.getType();
43 if (classifier != null)
44 {
45 if (specializedSetters)
46 {
47 if (classifier.isPrimitive())
48 {
49 setterName.append("set").append(classifier.getWrapperName().replaceAll("(.)*\\.", ""));
50 }
51 else if (classifier.isDateType() || classifier.isStringType())
52 {
53 setterName.append("set").append(classifier.getName());
54 }
55 else
56 {
57 setterName.append("setParameter");
58 }
59 }
60 else
61 {
62 setterName.append("setParameter");
63 }
64 if (classifier.isCollectionType())
65 {
66 setterName.append("List");
67 }
68 }
69 return setterName.toString();
70 }
71 }