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

30
LINES

< > BotCompany Repo | #1023197 // Ext (extended variable with additional fields)

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

Libraryless. Click here for Pure Java version (2256L/14K).

sclass Ext<A> extends DynamicObject implements IVar<A> {
  *() {}
  *(A *v) {}
  //O equalityPredicate; // func(Ext, Ext) -> bool
  
  bool fullToString; // include values in toString

  A v; // you can access this directly if you use one thread
  
  public synchronized void set(A a) {
    if (v != a) {
      v = a;
      notifyAll();
    }
  }
  
  public synchronized A get() { ret v; }
  public synchronized bool has() { ret v != null; }
  public synchronized void clear() { v = null; }
  
  public bool equals(O o) {
    ret o instanceof Ext && eq(o/Ext.v, v);
  }
  
  public int hashCode() { ret _hashCode(v); }
  
  toString {
    ret !fullToString ? str(get()) : extToString(this);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023197
Snippet name: Ext (extended variable with additional fields)
Eternal ID of this version: #1023197/12
Text MD5: e9582aa3a586b91570a3e7bf8117c6f6
Transpilation MD5: 81e7720b91dd8543eb47cb91710982ab
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-12 21:59:23
Source code size: 726 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 310 / 783
Version history: 11 change(s)
Referenced in: [show references]