/** * Tests if this list contains a node with the given name. * * @param name the name of the node, must not be <code>null</code> * * @return true if this list contains a node with the given name. * * @throws IllegalArgumentException if the name is <code>null</code> */ public final boolean contains(String name) { return indexOf(name) >= 0; }
public int indexOf(T element) { return nodeList.indexOf(element); }
public int indexOf(String name) { return nodeList.indexOf(name); }
public int getProductIndex(Product product) { return productList.indexOf(product); }
/** * Gets the element with the given name. The method performs a case insensitive search. * * @param name the name of the node, must not be <code>null</code> * * @return the node with the given name or <code>null</code> if a node with the given name is not contained in this * list * * @throws IllegalArgumentException if the name is <code>null</code> */ public final T get(String name) { int index = indexOf(name); return index >= 0 ? nodes.get(index) : null; }
public void testIndexOf() { addAllNodes(); assertEquals(_nodeList.indexOf("attribute1"), 0); assertEquals(_nodeList.indexOf("attribute2"), 1); assertEquals(_nodeList.indexOf("attribute3"), 2); assertEquals(_nodeList.indexOf("attribute4"), 3); assertEquals(_nodeList.indexOf("ATTRIBUTE1"), 0); assertEquals(_nodeList.indexOf("ATTRIBUTE2"), 1); assertEquals(_nodeList.indexOf("ATTRIBUTE3"), 2); assertEquals(_nodeList.indexOf("ATTRIBUTE4"), 3); assertEquals(_nodeList.indexOf("ATTRIBUTEX"), -1); removeAllNodes(); }
/** * Removes the given product from this product manager if it exists. * * @param product the product to be removed, ignored if <code>null</code> * @return true, if the product was removed */ public boolean removeProduct(Product product) { if (product != null) { int index = productList.indexOf(product); if (index >= 0) { if (productList.remove(product)) { productList.clearRemovedList(); product.removeProductNodeListener(productNodeNameChangeListener); product.resetRefNo(); clearProductManager(product); fireEvent(product, PRODUCT_REMOVED); return true; } } } return false; }
private Product newProductImpl() { if (getProductManager().getProductCount() == 0) { return null; } final ProductNodeList<Product> products = new ProductNodeList<>(); products.copyInto(getProductManager().getProducts()); final Product selectedProduct = getSelectedProduct(); if (selectedProduct == null) { return null; } final int selectedSourceIndex = products.indexOf(selectedProduct); final NewProductDialog dialog = new NewProductDialog(getMainFrame(), products, selectedSourceIndex, false); if (dialog.show() != NewProductDialog.ID_OK) { return null; } final Product product = dialog.getResultProduct(); if (product != null) { addProduct(product); updateState(); } else if (dialog.getException() != null) { showErrorDialog("The product subset could not be created:\n" + dialog.getException().getMessage()); } return product; }