UartBus source documentation
VUnsigned.java
1 package eu.javaexperience.electronic.uartbus.rpc.datatype;
2 
3 import java.math.BigInteger;
4 
5 public final class VUnsigned
6 {
7  public final BigInteger value;
8 
9  public VUnsigned(String dec)
10  {
11  this(new BigInteger(dec));
12  }
13 
14  public VUnsigned(BigInteger dec)
15  {
16  if(dec.signum() < 0)
17  {
18  throw new IllegalArgumentException("The given number is signed: "+dec);
19  }
20  this.value = dec;
21  }
22 
23  public VUnsigned(int value)
24  {
25  this(BigInteger.valueOf(value));
26  }
27 
28  public VUnsigned(long value)
29  {
30  this(BigInteger.valueOf(value));
31  }
32 
33  @Override
34  public boolean equals(Object obj)
35  {
36  if(!(obj instanceof VUnsigned))
37  {
38  return false;
39  }
40 
41  return value.equals(((VUnsigned)obj).value);
42  }
43 
44  @Override
45  public int hashCode()
46  {
47  return value.hashCode();
48  }
49 
50  @Override
51  public String toString()
52  {
53  return "VUnsigned: "+value;
54  }
55 }
56