Commit c3efbd4015beab9639c398f49bb051bcb843cebd

Authored by Andrii Shvaika
1 parent d0928e4d

Minor refactoring

... ... @@ -74,7 +74,7 @@ public class LwM2mInMemorySecurityStore extends InMemorySecurityStore {
74 74 public SecurityInfo getByEndpoint(String endPoint) {
75 75 readLock.lock();
76 76 try {
77   - String registrationId = this.getByRegistrationId(endPoint, null);
  77 + String registrationId = this.getRegistrationId(endPoint, null);
78 78 return (registrationId != null && sessions.size() > 0 && sessions.get(registrationId) != null) ?
79 79 sessions.get(registrationId).getSecurityInfo() : this.addLwM2MClientToSession(endPoint);
80 80 } finally {
... ... @@ -91,7 +91,7 @@ public class LwM2mInMemorySecurityStore extends InMemorySecurityStore {
91 91 public SecurityInfo getByIdentity(String identity) {
92 92 readLock.lock();
93 93 try {
94   - String integrationId = this.getByRegistrationId(null, identity);
  94 + String integrationId = this.getRegistrationId(null, identity);
95 95 return (integrationId != null) ? sessions.get(integrationId).getSecurityInfo() : this.addLwM2MClientToSession(identity);
96 96 } finally {
97 97 readLock.unlock();
... ... @@ -177,10 +177,10 @@ public class LwM2mInMemorySecurityStore extends InMemorySecurityStore {
177 177 }
178 178 }
179 179
180   - private String getByRegistrationId(String endPoint, String identity) {
  180 + private String getRegistrationId(String endPoint, String identity) {
181 181 List<String> registrationIds = (endPoint != null) ?
182   - this.sessions.entrySet().stream().filter(model -> endPoint.equals(model.getValue().getEndPoint())).map(model -> model.getKey()).collect(Collectors.toList()) :
183   - this.sessions.entrySet().stream().filter(model -> identity.equals(model.getValue().getIdentity())).map(model -> model.getKey()).collect(Collectors.toList());
  182 + this.sessions.entrySet().stream().filter(model -> endPoint.equals(model.getValue().getEndPoint())).map(Map.Entry::getKey).collect(Collectors.toList()) :
  183 + this.sessions.entrySet().stream().filter(model -> identity.equals(model.getValue().getIdentity())).map(Map.Entry::getKey).collect(Collectors.toList());
184 184 return (registrationIds != null && registrationIds.size() > 0) ? registrationIds.get(0) : null;
185 185 }
186 186
... ...