/** * search for a specific feature * @param type type of feature that we want search * @param <T> class that will want search * @return the feature of type {@code type} exported by this node, or null if not present */ public @Nullable <T extends Feature> T getFeature(Class<T> type){ List <T> allFeature = getFeatures(type); if(!allFeature.isEmpty()) return allFeature.get(0); //else return null; }//getFeature
/** * set the logger for all the feature in the node * @param n node that will be logged */ private void registerLoggerListener(Node n){ List<Feature> features = n.getFeatures(); for (Feature f : features) { f.addFeatureLoggerListener(mCurrentLogger); }//for }//registerLoggerListener
/** * stop a logger * @param n node where stop the logger * <p> * in case we are running the {@link FeatureLogDB} logger the data will be * dumped on a csv files * </p> */ protected void stopLogging(Node n) { List<Feature> features = n.getFeatures(); for (Feature f : features) { f.removeFeatureLoggerListener(mCurrentLogger); }//for }
/** * Get all features in the list of connected nodes * @return the list of features */ private List<Feature> getAllFeatures() { List<Feature> feat = new ArrayList<>(); for(Node n : mNodeList) { for(Feature f:n.getFeatures()) { if(!isAvailable(f, feat)) feat.add(f); } } return feat; } /**
/** * stop all the enabled notification */ private void disableNeedNotification() { List<Feature> features = mNode.getFeatures(); for (Feature f : features) { if (mNode.isEnableNotification(f)) mNode.disableNotification(f); }//for sTestFeature }//disableNeedNotification
/** * create and populate the adapter with only the enabled features. */ private void populateFeatureList() { if (mNode != null) { mFeatureListAdapter = new FeatureAdapter(this, R.layout.feature_list_item); List<Feature> features = mNode.getFeatures(); for (Feature f : features) { if (f.isEnabled()) { mFeatureListAdapter.add(f); }//if }//for //set the adapter as data source for the adapter mFeatureList.setAdapter(mFeatureListAdapter); }//if }//populateFeatureList