1 package org.djutils.base;
2
3 import java.util.Objects;
4
5
6
7
8
9
10
11
12
13
14
15 public class MutableBoolean
16 {
17
18 private boolean value;
19
20
21
22
23
24 public MutableBoolean(final boolean value)
25 {
26 set(value);
27 }
28
29
30
31
32
33 public void set(final boolean newValue)
34 {
35 this.value = newValue;
36 }
37
38
39
40
41 public boolean get()
42 {
43 return this.value;
44 }
45
46
47
48
49 public void flip()
50 {
51 this.value = !this.value;
52 }
53
54 @Override
55 public int hashCode()
56 {
57 return Objects.hash(this.value);
58 }
59
60 @Override
61 @SuppressWarnings("checkstyle:needbraces")
62 public boolean equals(final Object obj)
63 {
64 if (this == obj)
65 return true;
66 if (obj == null)
67 return false;
68 if (getClass() != obj.getClass())
69 return false;
70 MutableBoolean other = (MutableBoolean) obj;
71 return this.value == other.value;
72 }
73
74 @Override
75 public String toString()
76 {
77 return "MutableBoolean [value=" + this.value + "]";
78 }
79
80 }