@Test public void equals() throws Exception { final int baseVolume = 50; final int lowerBoundVolume = baseVolume - SenseVoiceSettings.VOLUME_EQUALS_THRESHOLD; final int upperBoundVolume = baseVolume + SenseVoiceSettings.VOLUME_EQUALS_THRESHOLD; final SenseVoiceSettings baseSetting = new SenseVoiceSettings(baseVolume, false, false); for (int volume = lowerBoundVolume; volume <= upperBoundVolume; volume++) { final SenseVoiceSettings comparisonSettings = SenseVoiceSettings.newInstance(baseSetting); comparisonSettings.setVolume(volume); assertTrue(baseSetting.equals(comparisonSettings)); } }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final SenseVoiceSettings that = (SenseVoiceSettings) o; if (this.isMuted != null && that.isMuted != null) { if (isMuted != that.isMuted) { return false; } } if (this.volume != null && that.volume != null) { if (!this.isWithinVolumeThreshold(that.volume)) { return false; } } if (this.isPrimaryUser != null && that.isPrimaryUser != null) { if (isPrimaryUser != that.isPrimaryUser) { return false; } } return true; }
SenseVoiceSettings extends ApiResponse { @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final SenseVoiceSettings that = (SenseVoiceSettings) o; if (this.isMuted != null && that.isMuted != null) { if (isMuted != that.isMuted) { return false; } } if (this.volume != null && that.volume != null) { if (!this.isWithinVolumeThreshold(that.volume)) { return false; } } if (this.isPrimaryUser != null && that.isPrimaryUser != null) { if (isPrimaryUser != that.isPrimaryUser) { return false; } } return true; } }
SenseVoiceSettings extends ApiResponse { @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final SenseVoiceSettings that = (SenseVoiceSettings) o; if (this.isMuted != null && that.isMuted != null) { if (isMuted != that.isMuted) { return false; } } if (this.volume != null && that.volume != null) { if (!this.isWithinVolumeThreshold(that.volume)) { return false; } } if (this.isPrimaryUser != null && that.isPrimaryUser != null) { if (isPrimaryUser != that.isPrimaryUser) { return false; } } return true; } SenseVoiceSettings(final Integer volume,
                              final Boolean isMuted,
                              final Boolean isPrimaryUser);  SenseVoiceSettings(final int volume,
                              final boolean isMuted,
                              final boolean isPrimaryUser); }
SenseVoiceSettings extends ApiResponse { @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final SenseVoiceSettings that = (SenseVoiceSettings) o; if (this.isMuted != null && that.isMuted != null) { if (isMuted != that.isMuted) { return false; } } if (this.volume != null && that.volume != null) { if (!this.isWithinVolumeThreshold(that.volume)) { return false; } } if (this.isPrimaryUser != null && that.isPrimaryUser != null) { if (isPrimaryUser != that.isPrimaryUser) { return false; } } return true; } SenseVoiceSettings(final Integer volume,
                              final Boolean isMuted,
                              final Boolean isPrimaryUser);  SenseVoiceSettings(final int volume,
                              final boolean isMuted,
                              final boolean isPrimaryUser); static SenseVoiceSettings newInstance(@NonNull final SenseVoiceSettings latestSettings); @Nullable Integer getVolume(); void setVolume(final int volume); @Nullable Boolean isMuted(); void setMuted(final boolean muted); @Nullable Boolean isPrimaryUser(); void setPrimaryUser(final boolean primaryUser); boolean isWithinVolumeThreshold(final int otherVolume); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); Boolean isPrimaryUserOrDefault(); Boolean isMuteOrDefault(); Integer getVolumeOrDefault(); }
SenseVoiceSettings extends ApiResponse { @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final SenseVoiceSettings that = (SenseVoiceSettings) o; if (this.isMuted != null && that.isMuted != null) { if (isMuted != that.isMuted) { return false; } } if (this.volume != null && that.volume != null) { if (!this.isWithinVolumeThreshold(that.volume)) { return false; } } if (this.isPrimaryUser != null && that.isPrimaryUser != null) { if (isPrimaryUser != that.isPrimaryUser) { return false; } } return true; } SenseVoiceSettings(final Integer volume,
                              final Boolean isMuted,
                              final Boolean isPrimaryUser);  SenseVoiceSettings(final int volume,
                              final boolean isMuted,
                              final boolean isPrimaryUser); static SenseVoiceSettings newInstance(@NonNull final SenseVoiceSettings latestSettings); @Nullable Integer getVolume(); void setVolume(final int volume); @Nullable Boolean isMuted(); void setMuted(final boolean muted); @Nullable Boolean isPrimaryUser(); void setPrimaryUser(final boolean primaryUser); boolean isWithinVolumeThreshold(final int otherVolume); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); Boolean isPrimaryUserOrDefault(); Boolean isMuteOrDefault(); Integer getVolumeOrDefault(); @VisibleForTesting
    static final int VOLUME_EQUALS_THRESHOLD; static final int TOTAL_VOLUME_LEVELS; static final int DEFAULT_START_VOLUME; }