Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

18
LINES

< > BotCompany Repo | #1033797 // Tok_GettableFields

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (6230L) is out of date.

1  
sclass Tok_GettableFields > Tok_SettableOrGettableFields {
2  
  // causes problems because non-static inner classes cannot have
3  
  // static functions
4  
  settable bool addStaticFieldGetters = false;
5  
6  
  *() { super("gettable"); }
7  
  
8  
  S replacement() {
9  
    ret tok_formatDollarVars(
10  
      "$fMod $type $var aka $getVar() { ret $var; }\n" +
11  
      (!addStaticFieldGetters ? "" : "static public Field $metaField() { ret findFieldOfClass(selfType.class, $quoted); }\n") +
12  
      "$modifiers $type",
13  
      metaField := "f_"  + var, quoted := quoted(var),
14  
      fMod := joinWithSpace(functionModifiers()) + " public",
15  
      modifiers := joinWithSpace(modifiers),
16  
      +type, +var, getVar := "get" + firstToUpper(var));
17  
  }
18  
}

Author comment

Began life as a copy of #1033794

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033797
Snippet name: Tok_GettableFields
Eternal ID of this version: #1033797/12
Text MD5: aa83477fa4c2c5150f8c740f3412d7db
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-08 04:47:32
Source code size: 729 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 145 / 259
Version history: 11 change(s)
Referenced in: [show references]