@Test public void obtainIFV() { String ifv1 = bidMachine.obtainIFV(context); String ifv2 = bidMachine.obtainIFV(context); assertNotNull(ifv1); assertNotNull(ifv2); assertEquals(ifv1, ifv2); bidMachine.ifv = null; String ifv3 = bidMachine.obtainIFV(context); assertNotNull(ifv3); assertEquals(ifv2, ifv3); }
@NonNull String obtainIFV(@NonNull Context context) { if (!TextUtils.isEmpty(ifv)) { return ifv; } SharedPreferences preferences = context.getSharedPreferences(BID_MACHINE_SHARED_PREF, Context.MODE_PRIVATE); ifv = preferences.getString(PREF_IFV, null); if (!TextUtils.isEmpty(ifv)) { return ifv; } ifv = UUID.randomUUID().toString(); preferences.edit() .putString(PREF_IFV, ifv) .apply(); return ifv; }
BidMachineImpl { @NonNull String obtainIFV(@NonNull Context context) { if (!TextUtils.isEmpty(ifv)) { return ifv; } SharedPreferences preferences = context.getSharedPreferences(BID_MACHINE_SHARED_PREF, Context.MODE_PRIVATE); ifv = preferences.getString(PREF_IFV, null); if (!TextUtils.isEmpty(ifv)) { return ifv; } ifv = UUID.randomUUID().toString(); preferences.edit() .putString(PREF_IFV, ifv) .apply(); return ifv; } }
BidMachineImpl { @NonNull String obtainIFV(@NonNull Context context) { if (!TextUtils.isEmpty(ifv)) { return ifv; } SharedPreferences preferences = context.getSharedPreferences(BID_MACHINE_SHARED_PREF, Context.MODE_PRIVATE); ifv = preferences.getString(PREF_IFV, null); if (!TextUtils.isEmpty(ifv)) { return ifv; } ifv = UUID.randomUUID().toString(); preferences.edit() .putString(PREF_IFV, ifv) .apply(); return ifv; }  }
BidMachineImpl { @NonNull String obtainIFV(@NonNull Context context) { if (!TextUtils.isEmpty(ifv)) { return ifv; } SharedPreferences preferences = context.getSharedPreferences(BID_MACHINE_SHARED_PREF, Context.MODE_PRIVATE); ifv = preferences.getString(PREF_IFV, null); if (!TextUtils.isEmpty(ifv)) { return ifv; } ifv = UUID.randomUUID().toString(); preferences.edit() .putString(PREF_IFV, ifv) .apply(); return ifv; }   }
BidMachineImpl { @NonNull String obtainIFV(@NonNull Context context) { if (!TextUtils.isEmpty(ifv)) { return ifv; } SharedPreferences preferences = context.getSharedPreferences(BID_MACHINE_SHARED_PREF, Context.MODE_PRIVATE); ifv = preferences.getString(PREF_IFV, null); if (!TextUtils.isEmpty(ifv)) { return ifv; } ifv = UUID.randomUUID().toString(); preferences.edit() .putString(PREF_IFV, ifv) .apply(); return ifv; }    }