Compare commits
No commits in common. '29a1f8cc217b2528adcdcedd331adaf3fcf84c59' and 'c9a09bcb1447bfb4e893303d731db2c11b490cf2' have entirely different histories.
29a1f8cc21
...
c9a09bcb14
@ -1,46 +0,0 @@ |
|||||||
package me.bearns.fias.xml; |
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
|
|
||||||
import javax.xml.bind.ValidationEventHandler; |
|
||||||
import javax.xml.bind.annotation.adapters.XmlAdapter; |
|
||||||
import java.math.BigInteger; |
|
||||||
|
|
||||||
@Slf4j |
|
||||||
public class DecimalAdapter extends XmlAdapter<String, BigInteger> { |
|
||||||
|
|
||||||
/** |
|
||||||
* Convert a value type to a bound type. |
|
||||||
* |
|
||||||
* @param v The value to be converted. Can be null. |
|
||||||
* @throws Exception if there's an error during the conversion. The caller is responsible for |
|
||||||
* reporting the error to the user through {@link ValidationEventHandler}. |
|
||||||
*/ |
|
||||||
@Override |
|
||||||
public BigInteger unmarshal(String v) throws Exception { |
|
||||||
if (v == null) return null; |
|
||||||
if (v.isEmpty()) { |
|
||||||
log.trace("BigInteger bug bypassed"); |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
if (!v.matches("^\\d+$")) return null; |
|
||||||
|
|
||||||
return new BigInteger(v); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Convert a bound type to a value type. |
|
||||||
* |
|
||||||
* @param v The value to be convereted. Can be null. |
|
||||||
* @throws Exception if there's an error during the conversion. The caller is responsible for |
|
||||||
* reporting the error to the user through {@link ValidationEventHandler}. |
|
||||||
*/ |
|
||||||
@Override |
|
||||||
public String marshal(BigInteger v) throws Exception { |
|
||||||
//TODO BigInteger marshaling impl
|
|
||||||
//throw new Exception("Marshalling not implemented");
|
|
||||||
|
|
||||||
return v == null ? null : v.toString(); |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue