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

22
LINES

< > BotCompany Repo | #1034195 // CombinedStringifier

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

Libraryless. Click here for Pure Java version (5077L/28K).

1  
sclass CombinedStringifier<A> is IStringifier<A> {
2  
  new CopyOnWriteArrayList<IPartialStringifier<A>> stringifiers;
3  
  IStringifier<A> defaultStringifier = new Stringifier_ToString;
4  
  
5  
  *(IPartialStringifier<A>... stringifiers) {
6  
    addAll(this.stringifiers, stringifiers);
7  
  }
8  
  
9  
  public S toString(A o) {
10  
    for (stringifier : stringifiers) {
11  
      S s = stringifier.toStringOpt(o);
12  
      if (s != null) ret s;
13  
    }
14  
    ret defaultStringifier.toString(o);
15  
  }
16  
  
17  
  toString {
18  
    ret formatFunctionCall CombinedStringifier(
19  
      listPlus((L) stringifiers, defaultStringifier)
20  
    );
21  
  }
22  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1034195
Snippet name: CombinedStringifier
Eternal ID of this version: #1034195/9
Text MD5: 4394631ea98fbf9f500678c4e79e703e
Transpilation MD5: a5b7305e248224bd9335398d00357daf
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-28 19:37:19
Source code size: 616 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 166 / 307
Version history: 8 change(s)
Referenced in: [show references]