Cleanup (immutable update check result bean)

This commit is contained in:
Roman Shevchenko
2015-10-06 13:14:25 +02:00
parent 05e9191512
commit a9b024d821
2 changed files with 12 additions and 16 deletions
@@ -24,16 +24,18 @@ import java.util.List;
public class CheckForUpdateResult {
private final BuildInfo myNewBuildInSelectedChannel;
private final UpdateChannel myUpdatedChannel;
private final UpdateChannel myChannelToPropose;
private final List<String> myAllChannelIds;
private final UpdateStrategy.State myState;
private final Exception myError;
private UpdateChannel myChannelToPropose = null;
public CheckForUpdateResult(@Nullable UpdateChannel updated,
@Nullable BuildInfo newBuildInSelectedChannel,
public CheckForUpdateResult(@Nullable BuildInfo newBuildInSelectedChannel,
@Nullable UpdateChannel updated,
@Nullable UpdateChannel channelToPropose,
@NotNull List<String> allChannelsIds) {
myNewBuildInSelectedChannel = newBuildInSelectedChannel;
myUpdatedChannel = updated;
myChannelToPropose = channelToPropose;
myAllChannelIds = allChannelsIds;
myState = UpdateStrategy.State.LOADED;
myError = null;
@@ -42,6 +44,7 @@ public class CheckForUpdateResult {
public CheckForUpdateResult(@NotNull UpdateStrategy.State state, @Nullable Exception e) {
myNewBuildInSelectedChannel = null;
myUpdatedChannel = null;
myChannelToPropose = null;
myAllChannelIds = Collections.emptyList();
myState = state;
myError = e;
@@ -57,6 +60,11 @@ public class CheckForUpdateResult {
return myUpdatedChannel;
}
@Nullable
public UpdateChannel getChannelToPropose() {
return myChannelToPropose;
}
@NotNull
public List<String> getAllChannelsIds() {
return myAllChannelIds;
@@ -71,13 +79,4 @@ public class CheckForUpdateResult {
public Exception getError() {
return myError;
}
@Nullable
public UpdateChannel getChannelToPropose() {
return myChannelToPropose;
}
public void setChannelToPropose(@Nullable UpdateChannel channelToPropose) {
myChannelToPropose = channelToPropose;
}
}
@@ -72,8 +72,6 @@ public class UpdateStrategy {
}
}
CheckForUpdateResult result = new CheckForUpdateResult(updatedChannel, newBuild, product.getAllChannelIds());
UpdateChannel channelToPropose = null;
for (UpdateChannel channel : product.getChannels()) {
if (!myUpdateSettings.getKnownChannelsIds().contains(channel.getId()) &&
@@ -84,9 +82,8 @@ public class UpdateStrategy {
channelToPropose = channel;
}
}
result.setChannelToPropose(channelToPropose);
return result;
return new CheckForUpdateResult(newBuild, updatedChannel, channelToPropose, product.getAllChannelIds());
}
private List<UpdateChannel> getActiveChannels(Product product) {