That fuck shit the fascists are using
at master 38 lines 867 B view raw
1package org.tm.archive.util; 2 3import androidx.annotation.NonNull; 4import androidx.lifecycle.MutableLiveData; 5 6import org.whispersystems.signalservice.api.util.Preconditions; 7 8 9/** 10 * Helps prevent all the @Nullable warnings when working with LiveData. 11 */ 12public class DefaultValueLiveData<T> extends MutableLiveData<T> { 13 14 private final T defaultValue; 15 16 public DefaultValueLiveData(@NonNull T defaultValue) { 17 super(defaultValue); 18 this.defaultValue = defaultValue; 19 } 20 21 @Override 22 public void postValue(@NonNull T value) { 23 Preconditions.checkNotNull(value); 24 super.postValue(value); 25 } 26 27 @Override 28 public void setValue(@NonNull T value) { 29 Preconditions.checkNotNull(value); 30 super.setValue(value); 31 } 32 33 @Override 34 public @NonNull T getValue() { 35 T value = super.getValue(); 36 return value != null ? value : defaultValue; 37 } 38}