Clover icon

sunshower-base

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

File IdentifierBridge.java

 

Coverage histogram

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

Code metrics

4
8
3
1
34
28
5
0.62
2.67
3
1.67

Classes

Class Line # Actions
IdentifierBridge 9 8 5
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.encodings.Base58;
4    import io.sunshower.encodings.Encoding;
5    import org.apache.lucene.document.Document;
6    import org.hibernate.search.bridge.LuceneOptions;
7    import org.hibernate.search.bridge.TwoWayFieldBridge;
8   
 
9    public class IdentifierBridge implements TwoWayFieldBridge {
10   
11    static final Encoding encoding = Base58.getInstance(Base58.Alphabets.Default);
12   
 
13  0 toggle @Override
14    public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
15  0 if (value != null) {
16  0 byte[] v = (byte[]) value;
17  0 luceneOptions.addFieldToDocument(name, encoding.encode(v), document);
18    }
19    }
20   
 
21  0 toggle @Override
22    public Object get(String name, Document document) {
23  0 String data = document.getField(name).stringValue();
24  0 return encoding.decode(data);
25    }
26   
 
27  0 toggle @Override
28    public String objectToString(Object object) {
29  0 if (object == null) {
30  0 return null;
31    }
32  0 return object.toString();
33    }
34    }