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

28
LINES

< > BotCompany Repo | #1006559 // convertToField - convert arbitrary value to fit a field

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

Transpiled version (9520L) is out of date.

1  
static O convertToField(O o, Class c, S field) {
2  
  Field f = setOpt_findField(c, field);
3  
  if (f == null) ret o;
4  
  Class t = f.getType();
5  
  if (t == Long.class || t == long.class)
6  
    ret toLong(o);
7  
  else if (t == Int.class || t == int.class)
8  
    ret toInt(o);
9  
  else if (t == Float.class || t == float.class)
10  
    ret toFloat(o);
11  
  else if (t == Double.class || t == double.class)
12  
    ret toDouble(o);
13  
  else if (t == S.class)
14  
    ret o cast S ? o : str(o);
15  
  else if (t == File.class) {
16  
    if (o cast S) ret new File(o).getAbsoluteFile();
17  
  } else if (t == Pt.class) {
18  
    if (o cast S) ret parsePt(o);
19  
  } else if (t == Rect) {
20  
    if (o cast S) ret parseRect(o);
21  
  }
22  
  
23  
  ifclass GlobalID
24  
    else if (t == GlobalID.class && o instanceof S)
25  
      ret GlobalID((S) o);
26  
  endif
27  
  ret o;
28  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1006559
Snippet name: convertToField - convert arbitrary value to fit a field
Eternal ID of this version: #1006559/8
Text MD5: 6e44f7d63b647d6affb0ae4d237b9d9c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-09-14 20:32:16
Source code size: 818 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 719 / 828
Version history: 7 change(s)
Referenced in: [show references]