package org.wikipedia.useroption.database;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import org.wikipedia.database.sync.DefaultSyncRow;
import org.wikipedia.database.sync.SyncRow;
import org.wikipedia.database.sync.SyncStatus;
import org.wikipedia.useroption.UserOption;

public class UserOptionRow extends UserOption implements SyncRow {
    public static final UserOptionDatabaseTable DATABASE_TABLE = new UserOptionDatabaseTable();

    private SyncRow sync;

    public UserOptionRow(@NonNull String key, @Nullable String val, @NonNull SyncStatus status,
                         long transactionId, long timestamp) {
        super(key, val);
        sync = new DefaultSyncRow(status, transactionId, timestamp);
    }

    @NonNull
    @Override
    public SyncStatus status() {
        return sync.status();
    }

    @Override
    public long transactionId() {
        return sync.transactionId();
    }

    @Override
    public long timestamp() {
        return sync.timestamp();
    }

    @Override
    public void resetTransaction(@NonNull SyncStatus status) {
        sync.resetTransaction(status);
    }

    @Override
    public void startTransaction() {
        sync.startTransaction();
    }

    @Override
    public boolean isTransaction(@NonNull SyncRow row) {
        return sync.isTransaction(row);
    }

    @Override
    public void completeTransaction(long timestamp) {
        sync.completeTransaction(timestamp);
    }
}
@@ -503,16 +503,326 @@
  sync;%0A%0A
+    public UserOptionRow(@NonNull String key) %7B%0A        super(key);%0A        init();%0A    %7D%0A%0A    public UserOptionRow(@NonNull UserOption option) %7B%0A        super(option);%0A        init();%0A    %7D%0A%0A    public UserOptionRow(@NonNull String key, @Nullable String val) %7B%0A        super(key, val);%0A        init();%0A    %7D%0A%0A
     publ
@@ -909,16 +909,16 @@
 status,%0A
-
         
@@ -1009,33 +1009,12 @@
     
-sync = new DefaultSyncRow
+init
 (sta
@@ -1717,32 +1717,32 @@
 ng timestamp) %7B%0A
-
         sync.com
@@ -1775,10 +1775,306 @@
 );%0A    %7D
+%0A%0A    private void init() %7B%0A        init(null, 0, 0);%0A    %7D%0A%0A    private void init(@Nullable SyncStatus status, long transactionId, long timestamp) %7B%0A        sync = status == null%0A                ? new DefaultSyncRow()%0A                : new DefaultSyncRow(status, transactionId, timestamp);%0A    %7D
 %0A%7D

Revert "Hygiene: remove unused code"