- public Currency(MobileLedgerProfile profile, String name, Position position, boolean hasGap) {
- SQLiteDatabase db = App.getDatabase();
- int attempts = 0;
- while (true) {
- if (++attempts > 10)
- throw new RuntimeException("Giving up getting next ID after 10 attempts");
-
- try (Cursor c = db.rawQuery("select max(rowid) from currencies", null)) {
- c.moveToNext();
- int nextId = c.getInt(0) + 1;
- db.execSQL("insert into currencies(id, name, position, has_gap) values(?, ?, ?, ?)",
- new Object[]{nextId, name, position.toString(), hasGap});
-
- this.id = nextId;
- break;
+ static public boolean equal(Currency left, Currency right) {
+ if (left == null) {
+ return right == null;
+ }
+ else
+ return left.equals(right);
+ }
+ static public boolean equal(Currency left, String right) {
+ right = Misc.emptyIsNull(right);
+ if (left == null) {
+ return right == null;
+ }
+ else {
+ String leftName = Misc.emptyIsNull(left.getName());
+ if (leftName == null) {
+ return right == null;