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

13
LINES

< > BotCompany Repo | #1031578 // iSetAndGet

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

Libraryless. Click here for Pure Java version (2811L/17K).

static <A> ISetAndGet<A> iSetAndGet(ISetter<A> setter, IF0<A> getter) {
  ret new ISetAndGet<A> {
    public void set(A a) { setter?.set(a); }
    public A get() { ret getter?!; }
  };
}

static <A, B> ISetAndGet<A> iSetAndGet(B target, IVF2<B, A> setter, IF1<B, A> getter) {
  ret new ISetAndGet<A> {
    public void set(A a) { if (target != null && setter != null) setter.get(target, a); }
    public A get() { ret target == null || getter == null ? null : getter.get(target); }
  };
}

Author comment

Began life as a copy of #1031577

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031578
Snippet name: iSetAndGet
Eternal ID of this version: #1031578/8
Text MD5: 1dd126ad827d140df2c8930ebe677aa4
Transpilation MD5: 19cfd99d54729db0b666b06cc661dcf3
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-22 06:57:51
Source code size: 499 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 184 / 275
Version history: 7 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)