@Override
 public List<String> getAvailableSystemDefs() {
   List<String> systemDefs = new ArrayList<String>();
   for (final SnmpCollection collection :
       getContainer().getObject().getSnmpCollectionCollection()) {
     if (collection.getSystems() != null) {
       for (final SystemDef systemDef : collection.getSystems().getSystemDefCollection()) {
         systemDefs.add(systemDef.getName());
       }
     }
   }
   return systemDefs;
 }
  @Override
  public List<MibObject> getMibObjectList(
      final String cName, final String aSysoid, final String anAddress, final int ifType) {
    if (log().isDebugEnabled())
      log()
          .debug(
              "getMibObjectList: collection: "
                  + cName
                  + " sysoid: "
                  + aSysoid
                  + " address: "
                  + anAddress
                  + " ifType: "
                  + ifType);

    if (aSysoid == null) {
      if (log().isDebugEnabled()) log().debug("getMibObjectList: aSysoid parameter is NULL...");
      return new ArrayList<MibObject>();
    }

    // Retrieve the appropriate Collection object
    final SnmpCollection collection = getSnmpCollection(getContainer(), cName);
    if (collection == null) {
      return Collections.emptyList();
    }

    final Systems systems = collection.getSystems();
    if (systems == null) {
      return Collections.emptyList();
    }

    // First build a list of SystemDef objects which "match" the passed
    // sysoid and IP address parameters. The SystemDef object must match
    // on both the sysoid AND the IP address.
    //
    // SYSOID MATCH
    //
    // A SystemDef object's sysoid value may be a complete system object
    // identifier or it may be a mask (a partial sysoid).
    //
    // If the sysoid is not a mask, the 'aSysoid' string must equal the
    // sysoid value exactly in order to match.
    //
    // If the sysoid is a mask, the 'aSysoid' string need only start with
    // the sysoid mask value in order to match
    //
    // For example, a sysoid mask of ".1.3.6.1.4.1.11." would match any
    // Hewlett-Packard product which had this sysoid prefix (which should
    // include all of them).
    //
    // IPADDRESS MATCH
    //
    // In order to match on IP Address one of the following must be true:
    //
    // The SystemDef's IP address list (ipList) must contain the 'anAddress'
    // parm (must be an exact match)
    //
    // OR
    //
    // The 'anAddress' parm must have the same prefix as one of the
    // SystemDef's IP address mask list (maskList) entries.
    //
    // NOTE: A SystemDef object which contains an empty IP list and
    // an empty Mask list matches ALL IP addresses (default is INCLUDE).

    final List<SystemDef> systemList = new ArrayList<SystemDef>();

    for (final SystemDef system : systems.getSystemDefCollection()) {
      // Match on sysoid?
      boolean bMatchSysoid = false;

      // Retrieve sysoid for this SystemDef and/ set the isMask boolean.
      boolean isMask = false;
      String currSysoid = null;
      SystemDefChoice sysChoice = system.getSystemDefChoice();

      if (sysChoice.getSysoid() != null) {
        currSysoid = sysChoice.getSysoid();
      } else if (sysChoice.getSysoidMask() != null) {
        currSysoid = sysChoice.getSysoidMask();
        isMask = true;
      }

      if (currSysoid != null) {
        if (isMask) {
          // SystemDef's sysoid is a mask, 'aSysoid' need only
          // start with the sysoid mask in order to match
          if (aSysoid.startsWith(currSysoid)) {
            if (log().isDebugEnabled())
              log()
                  .debug(
                      "getMibObjectList: includes sysoid "
                          + aSysoid
                          + " for system <name>: "
                          + system.getName());
            bMatchSysoid = true;
          }
        } else {
          // System's sysoid is not a mask, 'aSysoid' must
          // match the sysoid exactly.
          if (aSysoid.equals(currSysoid)) {
            if (log().isDebugEnabled())
              log()
                  .debug(
                      "getMibObjectList: includes sysoid "
                          + aSysoid
                          + " for system <name>: "
                          + system.getName());
            bMatchSysoid = true;
          }
        }
      }

      // Match on ipAddress?
      boolean bMatchIPAddress = true; // default is INCLUDE
      if (bMatchSysoid == true) {
        if (anAddress != null) {
          List<String> addrList = null;
          List<String> maskList = null;
          if (system.getIpList() != null) {
            addrList = system.getIpList().getIpAddrCollection();
            maskList = system.getIpList().getIpAddrMaskCollection();
          }

          // If either Address list or Mask list exist then 'anAddress'
          // must be included by one of them
          if (addrList != null && addrList.size() > 0 || maskList != null && maskList.size() > 0) {
            bMatchIPAddress = false;
          }

          // First see if address is in list of specific addresses
          if (addrList != null && addrList.size() > 0) {
            if (addrList.contains(anAddress)) {
              if (log().isDebugEnabled())
                log()
                    .debug(
                        "getMibObjectList: addrList exists and does include IP address "
                            + anAddress
                            + " for system <name>: "
                            + system.getName());
              bMatchIPAddress = true;
            }
          }

          // If still no match, see if address matches any of the masks
          if (bMatchIPAddress == false) {

            if (maskList != null && maskList.size() > 0) {
              for (final String currMask : maskList) {
                if (anAddress.indexOf(currMask) == 0) {
                  if (log().isDebugEnabled())
                    log()
                        .debug(
                            "getMibObjectList: anAddress '"
                                + anAddress
                                + "' matches mask '"
                                + currMask
                                + "'");
                  bMatchIPAddress = true;
                  break;
                }
              }
            }
          }
        }
      }

      if (bMatchSysoid && bMatchIPAddress) {
        if (log().isDebugEnabled())
          log().debug("getMibObjectList: MATCH!! adding system '" + system.getName() + "'");
        systemList.add(system);
      }
    }

    // Next build list of Mib objects to collect from the list of matching SystemDefs
    final List<MibObject> mibObjectList = new ArrayList<MibObject>();

    for (final SystemDef system : systemList) {
      // Next process each of the SystemDef's groups
      for (final String grpName : system.getCollect().getIncludeGroupCollection()) {
        processGroupName(cName, grpName, ifType, mibObjectList);
      }
    }

    return mibObjectList;
  }