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

22
LINES

< > BotCompany Repo | #1036350 // SignalWithStrength

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

Libraryless. Click here for Pure Java version (10115L/55K).

persistable sclass SignalWithStrength {
  settable S type;
  
  settable S reason;
  
  // 0 = no signal, 100 = full signal
  // can be outside of [0; 100] too
  settable double strength;
  
  settable O createdBy;
  
  toString {
    ret (nempty(reason) ? reason : or2(type, "Unspecified ") + " signal")
      + appendRoundBracketed( 
        strength >= 100 ? null : iround(strength) + "%"
      );
  }
  
  bool isTrigger() { ret strength >= 100; }
  bool nonNegative() { ret strength >= 0; }
  bool positive() { ret strength > 0; }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036350
Snippet name: SignalWithStrength
Eternal ID of this version: #1036350/12
Text MD5: 731186a6a1b6dc8b1e2759ffbd6df47c
Transpilation MD5: 198d3866f2f4c8e9f5134991673d8744
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-03-16 17:19:47
Source code size: 558 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 89 / 152
Version history: 11 change(s)
Referenced in: [show references]