1. Write all variable definitions.
Example:
1 public class KeywordDimension extends Model implements Serializable
2 {
3 private Long m_vendorId;
4 private Long m_keywordId;
5 private String m_vendor;
6 private String m_keyword;
2. Copy them once more below where you want to generate get-functions.
1 public class KeywordDimension extends Model implements Serializable
2 {
3 private Long m_vendorId;
4 private Long m_keywordId;
5 private String m_vendor;
6 private String m_keyword;
7
8 private Long m_vendorId;
9 private Long m_keywordId;
10 private String m_vendor;
11 private String m_keyword;
3. Run this substitute command in vi:
:8,11s/private \(.*\) m_\(.*\);/public \1 get\2() \r {\r return m_\2;\r }/gc
4. You will get this:
1 public class KeywordDimension extends Model implements Serializable
2 {
3 private Long m_vendorId;
4 private Long m_keywordId;
5 private String m_vendor;
6 private String m_keyword;
7
8 public Long getvendorId()
9 {
10 return m_vendorId;
11 }
12 public Long getkeywordId()
13 {
14 return m_keywordId;
15 }
16 public String getvendor()
17 {
18 return m_vendor;
19 }
20 public String getkeyword()
21 {
22 return m_keyword;
23 }
4. Now run this to replace getk by getK (capital) for example:
:8,23s/get\([a-z]\)/get\u\1/gc
You get this:
1 public class KeywordDimension extends Model implements Serializable
2 {
3 private Long m_vendorId;
4 private Long m_keywordId;
5 private String m_vendor;
6 private String m_keyword;
7
8 public Long getVendorId()
9 {
10 return m_vendorId;
11 }
12 public Long getKeywordId()
13 {
14 return m_keywordId;
15 }
16 public String getVendor()
17 {
18 return m_vendor;
19 }
20 public String getKeyword()
21 {
22 return m_keyword;
23 }
Voila! Just two vim substitutes and you are done! Repeat similar stuff for sets, replacing get by set, and substituting by assignments:
:25,28s/private \(.*\) m_\(.*\);/public void set\2(\1 \2) \r {\r m_\2 = \2;\r }/gc
:25,40s/set\([a-z]\)/set\u\1/gc
1 comment:
I did not get what do you want to mean to say . Maybe my lack of knowledge !
I did not get why did u replace it.
Post a Comment