Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed Jul 18, 2013
1 parent ef89bd4 commit fbdcc1e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Expand Up @@ -64,7 +64,7 @@ TransHistoryItem two()
* @param newItem to be added/removed item
* @return a new object of this class
*/
public ComparingPair addOrRemove(TransHistoryItem newItem)
public ComparingPair tryAddOrRemoveIfExists(TransHistoryItem newItem)
{
if (isEmpty())
{
Expand Down
Expand Up @@ -7,7 +7,6 @@
import net.customware.gwt.presenter.client.EventBus;
import net.customware.gwt.presenter.client.widget.WidgetPresenter;

import org.zanata.common.ContentState;
import org.zanata.webtrans.client.events.CopyDataToEditorEvent;
import org.zanata.webtrans.client.events.NotificationEvent;
import org.zanata.webtrans.client.events.ReviewCommentEvent;
Expand All @@ -30,7 +29,6 @@
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.view.client.SelectionChangeEvent;
import com.google.inject.Inject;
import com.google.inject.Singleton;

Expand Down Expand Up @@ -143,7 +141,7 @@ public void copyIntoEditor(List<String> contents)
@Override
public void compareClicked(TransHistoryItem item)
{
comparingPair = comparingPair.addOrRemove(item);
comparingPair = comparingPair.tryAddOrRemoveIfExists(item);
if (comparingPair.isFull())
{
display.showDiff(comparingPair.one(), comparingPair.two(), messages.translationHistoryComparison(
Expand Down
Expand Up @@ -55,7 +55,7 @@ private static TransHistoryItem newItem(String versionNum)
public void testAddWhenItsEmpty() throws Exception
{
TransHistoryItem newItem = newItem("1");
pair = ComparingPair.empty().addOrRemove(newItem);
pair = ComparingPair.empty().tryAddOrRemoveIfExists(newItem);

assertThat(pair.one(), Matchers.sameInstance(newItem));
assertThat(pair.two(), Matchers.nullValue());
Expand All @@ -65,7 +65,7 @@ public void testAddWhenItsEmpty() throws Exception
public void addSameItemTwiceWillRemoveIt()
{
TransHistoryItem newItem = newItem("1");
pair = ComparingPair.empty().addOrRemove(newItem).addOrRemove(newItem);
pair = ComparingPair.empty().tryAddOrRemoveIfExists(newItem).tryAddOrRemoveIfExists(newItem);

assertThat(pair.one(), Matchers.nullValue());
assertThat(pair.two(), Matchers.nullValue());
Expand All @@ -77,13 +77,13 @@ public void addSameItemToFullPairWillBeIgnored() throws Exception
TransHistoryItem one = newItem("1");
TransHistoryItem two = newItem("2");
TransHistoryItem three = newItem("3");
pair = ComparingPair.empty().addOrRemove(one).addOrRemove(two);
pair = ComparingPair.empty().tryAddOrRemoveIfExists(one).tryAddOrRemoveIfExists(two);

assertThat(pair.isFull(), Matchers.is(true));
assertThat(pair.one(), Matchers.sameInstance(one));
assertThat(pair.two(), Matchers.sameInstance(two));

pair = pair.addOrRemove(three);
pair = pair.tryAddOrRemoveIfExists(three);

assertThat(pair.isFull(), Matchers.is(true));
assertThat(pair.one(), Matchers.sameInstance(one));
Expand All @@ -95,7 +95,7 @@ public void testContains() throws Exception
{
TransHistoryItem one = newItem("1");
TransHistoryItem two = newItem("2");
pair = ComparingPair.empty().addOrRemove(one);
pair = ComparingPair.empty().tryAddOrRemoveIfExists(one);

assertThat(pair.contains(one), Matchers.is(true));
assertThat(pair.contains(two), Matchers.is(false));
Expand Down

0 comments on commit fbdcc1e

Please sign in to comment.