private <N> void addMetricAndAvailInstances( ID resourceId, ResourceType<L> type, L parentLocation, N baseNode, Resource.Builder<L> builder, Session<L> session) { for (MetricType<L> metricType : type.getMetricTypes()) { AttributeLocation<L> location = metricType.getAttributeLocation(); try { final AttributeLocation<L> instanceLocation = session.getLocationResolver().absolutize(parentLocation, location); if (session.getDriver().attributeExists(instanceLocation)) { ID id = InventoryIdUtil.generateMetricInstanceId(session.getFeedId(), resourceId, metricType); Name name = metricType.getName(); MeasurementInstance<L, MetricType<L>> metricInstance = new MeasurementInstance<>(id, name, instanceLocation, metricType); builder.metric(metricInstance); } } catch (ProtocolException e) { log.warnFailedToLocate( e, metricType.getClass().getName(), String.valueOf(location), String.valueOf(parentLocation)); } } for (AvailType<L> availType : type.getAvailTypes()) { AttributeLocation<L> location = availType.getAttributeLocation(); try { final AttributeLocation<L> instanceLocation = session.getLocationResolver().absolutize(parentLocation, location); if (session.getDriver().attributeExists(instanceLocation)) { ID id = InventoryIdUtil.generateAvailInstanceId(session.getFeedId(), resourceId, availType); Name name = availType.getName(); MeasurementInstance<L, AvailType<L>> availInstance = new MeasurementInstance<>(id, name, instanceLocation, availType); builder.avail(availInstance); } } catch (ProtocolException e) { log.warnFailedToLocate( e, availType.getClass().getName(), String.valueOf(location), String.valueOf(parentLocation)); } } }