Satish K
Committed by Gerrit Code Review

Duplicate Null Check not required

Change-Id: I9b150ad11572cd44b540e5b1a893b3c7a8953c30
...@@ -154,21 +154,19 @@ public class RouterManager implements RouterService { ...@@ -154,21 +154,19 @@ public class RouterManager implements RouterService {
154 @Override 154 @Override
155 public boolean updateRouters(Collection<Router> routers) { 155 public boolean updateRouters(Collection<Router> routers) {
156 checkNotNull(routers, ROUTER_NOT_NULL); 156 checkNotNull(routers, ROUTER_NOT_NULL);
157 - if (routers != null) { 157 + for (Router router : routers) {
158 - for (Router router : routers) { 158 + if (!routerStore.containsKey(router.id())) {
159 - if (!routerStore.containsKey(router.id())) { 159 + log.debug("The routers is not exist whose identifier is {}",
160 - log.debug("The routers is not exist whose identifier is {}", 160 + router.id().toString());
161 - router.id().toString()); 161 + throw new IllegalArgumentException(
162 - throw new IllegalArgumentException( 162 + "routers ID doesn't exist");
163 - "routers ID doesn't exist"); 163 + }
164 - } 164 + verifyRouterData(router);
165 - verifyRouterData(router); 165 + routerStore.put(router.id(), router);
166 - routerStore.put(router.id(), router); 166 + if (!router.equals(routerStore.get(router.id()))) {
167 - if (!router.equals(routerStore.get(router.id()))) { 167 + log.debug("The router is updated failed whose identifier is {}",
168 - log.debug("The router is updated failed whose identifier is {}", 168 + router.id().toString());
169 - router.id().toString()); 169 + return false;
170 - return false;
171 - }
172 } 170 }
173 } 171 }
174 return true; 172 return true;
...@@ -177,21 +175,19 @@ public class RouterManager implements RouterService { ...@@ -177,21 +175,19 @@ public class RouterManager implements RouterService {
177 @Override 175 @Override
178 public boolean removeRouters(Collection<RouterId> routerIds) { 176 public boolean removeRouters(Collection<RouterId> routerIds) {
179 checkNotNull(routerIds, ROUTER_ID_NULL); 177 checkNotNull(routerIds, ROUTER_ID_NULL);
180 - if (routerIds != null) { 178 + for (RouterId routerId : routerIds) {
181 - for (RouterId routerId : routerIds) { 179 + if (!routerStore.containsKey(routerId)) {
182 - if (!routerStore.containsKey(routerId)) { 180 + log.debug("The router is not exist whose identifier is {}",
183 - log.debug("The router is not exist whose identifier is {}", 181 + routerId.toString());
184 - routerId.toString()); 182 + throw new IllegalArgumentException(
185 - throw new IllegalArgumentException( 183 + "router ID doesn't exist");
186 - "router ID doesn't exist"); 184 + }
187 - } 185 + Router router = routerStore.get(routerId);
188 - Router router = routerStore.get(routerId); 186 + routerStore.remove(routerId, router);
189 - routerStore.remove(routerId, router); 187 + if (routerStore.containsKey(routerId)) {
190 - if (routerStore.containsKey(routerId)) { 188 + log.debug("The router deleted is failed whose identifier is {}",
191 - log.debug("The router deleted is failed whose identifier is {}", 189 + routerId.toString());
192 - routerId.toString()); 190 + return false;
193 - return false;
194 - }
195 } 191 }
196 } 192 }
197 return true; 193 return true;
......