private void createMemState(
     MemberStateImpl memberState,
     Iterator<HazelcastInstanceAwareInstance> it,
     Instance.InstanceType type) {
   int count = 0;
   while (it.hasNext()) {
     HazelcastInstanceAwareInstance proxyObject = it.next();
     if (proxyObject.getInstanceType() == type) {
       if (count < maxVisibleInstanceCount) {
         if (type.isMap()) {
           MProxy mapProxy = (MProxy) proxyObject;
           if (instanceFilterMap.visible(mapProxy.getName())) {
             memberState.putLocalMapStats(
                 mapProxy.getName(), (LocalMapStatsImpl) mapProxy.getLocalMapStats());
             count++;
           }
         } else if (type.isQueue()) {
           QProxy qProxy = (QProxy) proxyObject;
           if (instanceFilterQueue.visible(qProxy.getName())) {
             memberState.putLocalQueueStats(
                 qProxy.getName(), (LocalQueueStatsImpl) qProxy.getLocalQueueStats());
             count++;
           }
         } else if (type.isTopic()) {
           TopicProxy topicProxy = (TopicProxy) proxyObject;
           if (instanceFilterTopic.visible(topicProxy.getName())) {
             memberState.putLocalTopicStats(
                 topicProxy.getName(), (LocalTopicStatsImpl) topicProxy.getLocalTopicStats());
             count++;
           }
         } else if (type.isAtomicNumber()) {
           AtomicNumberProxy atomicLongProxy = (AtomicNumberProxy) proxyObject;
           if (instanceFilterAtomicNumber.visible(atomicLongProxy.getName())) {
             memberState.putLocalAtomicNumberStats(
                 atomicLongProxy.getName(),
                 (LocalAtomicNumberStatsImpl) atomicLongProxy.getLocalAtomicNumberStats());
             count++;
           }
         } else if (type.isCountDownLatch()) {
           CountDownLatchProxy cdlProxy = (CountDownLatchProxy) proxyObject;
           if (instanceFilterCountDownLatch.visible(cdlProxy.getName())) {
             memberState.putLocalCountDownLatchStats(
                 cdlProxy.getName(),
                 (LocalCountDownLatchStatsImpl) cdlProxy.getLocalCountDownLatchStats());
             count++;
           }
         } else if (type.isSemaphore()) {
           SemaphoreProxy semaphoreProxy = (SemaphoreProxy) proxyObject;
           if (instanceFilterSemaphore.visible(semaphoreProxy.getName())) {
             memberState.putLocalSemaphoreStats(
                 semaphoreProxy.getName(),
                 (LocalSemaphoreStatsImpl) semaphoreProxy.getLocalSemaphoreStats());
             count++;
           }
         }
       }
       it.remove();
     }
   }
 }
 private void collectInstanceNames(
     Set<String> setLongInstanceNames,
     Iterator<HazelcastInstanceAwareInstance> it,
     Instance.InstanceType type) {
   int count = 0;
   while (it.hasNext()) {
     HazelcastInstanceAwareInstance proxyObject = it.next();
     if (proxyObject.getInstanceType() == type) {
       if (count < maxVisibleInstanceCount) {
         if (type.isMap()) {
           MProxy mapProxy = (MProxy) proxyObject;
           if (instanceFilterMap.visible(mapProxy.getName())) {
             setLongInstanceNames.add(mapProxy.getLongName());
             count++;
           }
         } else if (type.isQueue()) {
           QProxy qProxy = (QProxy) proxyObject;
           if (instanceFilterQueue.visible(qProxy.getName())) {
             setLongInstanceNames.add(qProxy.getLongName());
             count++;
           }
         } else if (type.isTopic()) {
           TopicProxy topicProxy = (TopicProxy) proxyObject;
           if (instanceFilterTopic.visible(topicProxy.getName())) {
             setLongInstanceNames.add(topicProxy.getLongName());
             count++;
           }
         } else if (type.isAtomicNumber()) {
           AtomicNumberProxy atomicLongProxy = (AtomicNumberProxy) proxyObject;
           if (instanceFilterAtomicNumber.visible(atomicLongProxy.getName())) {
             setLongInstanceNames.add(atomicLongProxy.getLongName());
             count++;
           }
         } else if (type.isCountDownLatch()) {
           CountDownLatchProxy cdlProxy = (CountDownLatchProxy) proxyObject;
           if (instanceFilterCountDownLatch.visible(cdlProxy.getName())) {
             setLongInstanceNames.add(cdlProxy.getLongName());
             count++;
           }
         } else if (type.isSemaphore()) {
           SemaphoreProxy semaphoreProxy = (SemaphoreProxy) proxyObject;
           if (instanceFilterSemaphore.visible(semaphoreProxy.getName())) {
             setLongInstanceNames.add(semaphoreProxy.getLongName());
             count++;
           }
         }
       }
       it.remove();
     }
   }
 }