Clover icon

sunshower-base

  1. Project Clover database Fri Apr 6 2018 03:41:27 UTC
  2. Package io.sunshower.persistence.core

File ByteArrayBridge.java

 

Coverage histogram

../../../../img/srcFileCovDistChart0.png
50% of files have more coverage

Code metrics

8
9
2
1
31
27
6
0.67
4.5
2
3

Classes

Class Line # Actions
ByteArrayBridge 8 9 6
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package io.sunshower.persistence.core;
2   
3    import io.sunshower.common.Identifier;
4    import io.sunshower.encodings.Base58;
5    import io.sunshower.encodings.Encoding;
6    import org.hibernate.search.bridge.TwoWayStringBridge;
7   
 
8    public class ByteArrayBridge implements TwoWayStringBridge {
9    static final Encoding encoding = Base58.getInstance(Base58.Alphabets.Default);
10   
 
11  0 toggle @Override
12    public String objectToString(Object object) {
13  0 if (object != null) {
14  0 if (object instanceof String) {
15  0 return (String) object;
16    }
17  0 if (object instanceof byte[]) {
18  0 return encoding.encode((byte[]) object);
19    }
20    }
21  0 return "null";
22    }
23   
 
24  0 toggle @Override
25    public Object stringToObject(String stringValue) {
26  0 if (stringValue != null) {
27  0 return Identifier.valueOf(stringValue);
28    }
29  0 return "null";
30    }
31    }