Skip to content

Commit

Permalink
Remove hashCode and equals from base class, support null default value
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard committed Jun 3, 2016
1 parent 71cd868 commit 996bae5
Showing 1 changed file with 1 addition and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.google.cloud;

import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkArgument;

import com.google.common.base.MoreObjects;
Expand Down Expand Up @@ -185,26 +184,10 @@ final boolean baseEquals(WaitForOption option) {
return Objects.equals(option.optionType, option.optionType);
}

@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj == null || !(obj.getClass().equals(WaitForOption.class))) {
return false;
}
return baseEquals((WaitForOption) obj);
}

final int baseHashCode() {
return Objects.hash(optionType);
}

@Override
public int hashCode() {
return baseHashCode();
}

@SuppressWarnings("unchecked")
private static <T extends WaitForOption> T getOrDefaultInternal(OptionType optionType,
T defaultValue, WaitForOption... options) {
Expand All @@ -215,7 +198,7 @@ private static <T extends WaitForOption> T getOrDefaultInternal(OptionType optio
foundOption = (T) option;
}
}
return firstNonNull(foundOption, defaultValue);
return foundOption != null ? foundOption : defaultValue;
}

/**
Expand Down

0 comments on commit 996bae5

Please sign in to comment.