Committed by
Ray Milkey
Duplicate Null Check not required
Change-Id: I31e3702b1456b8c5b50bf8e139833bd5f818df6d
Showing
1 changed file
with
19 additions
and
23 deletions
| ... | @@ -144,21 +144,19 @@ public class SubnetManager implements SubnetService { | ... | @@ -144,21 +144,19 @@ public class SubnetManager implements SubnetService { |
| 144 | @Override | 144 | @Override |
| 145 | public boolean updateSubnets(Iterable<Subnet> subnets) { | 145 | public boolean updateSubnets(Iterable<Subnet> subnets) { |
| 146 | checkNotNull(subnets, SUBNET_NOT_NULL); | 146 | checkNotNull(subnets, SUBNET_NOT_NULL); |
| 147 | - if (subnets != null) { | 147 | + for (Subnet subnet : subnets) { |
| 148 | - for (Subnet subnet : subnets) { | 148 | + if (!subnetStore.containsKey(subnet.id())) { |
| 149 | - if (!subnetStore.containsKey(subnet.id())) { | 149 | + log.debug("The subnet is not exist whose identifier is {}", |
| 150 | - log.debug("The subnet is not exist whose identifier is {}", | 150 | + subnet.id().toString()); |
| 151 | - subnet.id().toString()); | 151 | + return false; |
| 152 | - return false; | 152 | + } |
| 153 | - } | 153 | + |
| 154 | - | 154 | + subnetStore.put(subnet.id(), subnet); |
| 155 | - subnetStore.put(subnet.id(), subnet); | 155 | + |
| 156 | - | 156 | + if (!subnet.equals(subnetStore.get(subnet.id()))) { |
| 157 | - if (!subnet.equals(subnetStore.get(subnet.id()))) { | 157 | + log.debug("The subnet is updated failed whose identifier is {}", |
| 158 | - log.debug("The subnet is updated failed whose identifier is {}", | 158 | + subnet.id().toString()); |
| 159 | - subnet.id().toString()); | 159 | + return false; |
| 160 | - return false; | ||
| 161 | - } | ||
| 162 | } | 160 | } |
| 163 | } | 161 | } |
| 164 | return true; | 162 | return true; |
| ... | @@ -167,14 +165,12 @@ public class SubnetManager implements SubnetService { | ... | @@ -167,14 +165,12 @@ public class SubnetManager implements SubnetService { |
| 167 | @Override | 165 | @Override |
| 168 | public boolean removeSubnets(Iterable<SubnetId> subnetIds) { | 166 | public boolean removeSubnets(Iterable<SubnetId> subnetIds) { |
| 169 | checkNotNull(subnetIds, SUBNET_ID_NULL); | 167 | checkNotNull(subnetIds, SUBNET_ID_NULL); |
| 170 | - if (subnetIds != null) { | 168 | + for (SubnetId subnetId : subnetIds) { |
| 171 | - for (SubnetId subnetId : subnetIds) { | 169 | + subnetStore.remove(subnetId); |
| 172 | - subnetStore.remove(subnetId); | 170 | + if (subnetStore.containsKey(subnetId)) { |
| 173 | - if (subnetStore.containsKey(subnetId)) { | 171 | + log.debug("The subnet created is failed whose identifier is {}", |
| 174 | - log.debug("The subnet created is failed whose identifier is {}", | 172 | + subnetId.toString()); |
| 175 | - subnetId.toString()); | 173 | + return false; |
| 176 | - return false; | ||
| 177 | - } | ||
| 178 | } | 174 | } |
| 179 | } | 175 | } |
| 180 | return true; | 176 | return true; | ... | ... |
-
Please register or login to post a comment