1   package org.pojomatic.formatter;
2   
3   import java.util.Arrays;
4   
5   import org.pojomatic.annotations.Property;
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  @Deprecated
22  public class AccountNumberFormatter extends DefaultPropertyFormatter {
23    private static final int DEFAULT_PLAINTEXT_CHARS = 4;
24    private static final int DEFAULT_FILL_CHAR = '*';
25  
26    private int plaintextChars = DEFAULT_PLAINTEXT_CHARS;
27    private char fillChar = DEFAULT_FILL_CHAR;
28  
29    @Override
30    public String format(Object value) {
31      String rep = super.format(value);
32      int repLength = rep.length();
33      if (repLength <= getPlaintextChars()) {
34        return rep;
35      } else {
36        char[] repChars = rep.toCharArray();
37        Arrays.fill(repChars, 0, repLength - getPlaintextChars(), getFillChar());
38        return String.valueOf(repChars);
39      }
40    }
41  
42    protected int getPlaintextChars() {
43      return plaintextChars;
44    }
45  
46    protected void setPlaintextChars(int plaintextChars) {
47      this.plaintextChars = plaintextChars;
48    }
49  
50    protected char getFillChar() {
51      return fillChar;
52    }
53  
54    protected void setFillChar(char fillChar) {
55      this.fillChar = fillChar;
56    }
57  
58  }