List of usage examples for java.util Collection add
boolean add(E e);
From source file:com.googlecode.jtiger.modules.ecside.core.TableModelUtils.java
/** * Retrieve the current page of rows.//w w w . ja v a 2 s . com * * @param rows The Collection of Beans after filtering and sorting. * @return The current page of rows. */ public static Collection getCurrentRows(TableModel model, Collection rows) { Limit limit = model.getLimit(); int rowStart = limit.getRowStart(); int rowEnd = limit.getRowEnd(); // Normal case. Using Limit and paginating for a specific set of rows. if (rowStart >= rows.size()) { if (logger.isDebugEnabled()) { logger.debug("The Limit row start is >= items.size(). Return the items available."); } return rows; } if (rowEnd > rows.size()) { if (logger.isWarnEnabled()) { logger.warn("The Limit row end is > items.size(). Return as many items as possible."); } rowEnd = rows.size(); } Collection results = new ArrayList(); for (int i = rowStart; i < rowEnd; i++) { Object bean = ((List) rows).get(i); results.add(bean); } return results; }
From source file:com.ibm.ws.lars.rest.PermissionTest.java
/** * Build the test parameters//from w w w . j a v a2s .c om * <p> * We want to test the same methods with multiple users which we expect to map to different * roles. JUnit lets us construct a list of test parameters and each test will run which each * set of test parameters. * <p> * The parameters we are passing are URL, username, password, expected role and label. The label * is just used to name the test so we can tell them apart in the test results. * * @return the test parameters */ @Parameters(name = "{4}") public static Collection<Object[]> makeParameters() { Collection<Object[]> data = new ArrayList<>(); for (User user : User.values()) { data.add(new Object[] { RESTRICTED_URL_HTTP, user.username, user.password, user.restrictedConfigRole, user + " - restricted - http" }); data.add(new Object[] { UNRESTRICTED_URL_HTTP, user.username, user.password, user.unrestrictedConfigRole, user + " - unrestricted - http" }); data.add(new Object[] { RESTRICTED_URL_HTTPS, user.username, user.password, user.restrictedConfigRole, user + " - restricted - https" }); data.add(new Object[] { UNRESTRICTED_URL_HTTPS, user.username, user.password, user.unrestrictedConfigRole, user + " - unrestricted - https" }); } System.out.println("sending data: " + data.size()); return data; }
From source file:de.iteratec.iteraplan.businesslogic.service.ecore.BuildingBlocksToEcoreServiceImpl.java
private static void setEAttribute(EObject instance, BuildingBlock bb, EAttribute eAtt, MappedEPackage mPackage) {//from w ww.jav a 2 s.c o m Object value = null; if (mPackage.isExtended(eAtt)) { Collection<Object> values = new LinkedList<Object>(); for (AttributeValueAssignment assignment : bb .getAssignmentsForId(mPackage.getAttributeType(eAtt).getId())) { values.add(assignment.getAttributeValue().getValue()); } value = values; } else { try { value = PropertyUtils.getSimpleProperty(bb, eAtt.getName()); } catch (IllegalAccessException iae) { LOGGER.error("Could not access attribute value.", iae); } catch (InvocationTargetException ite) { LOGGER.error("Could not access attribute value.", ite); } catch (NoSuchMethodException nsme) { LOGGER.error("Could not access attribute value.", nsme); } } if (eAtt.getEType() instanceof EEnum) { Map<String, EEnumLiteral> litMap = Maps.newHashMap(); for (EEnumLiteral eLit : ((EEnum) eAtt.getEType()).getELiterals()) { litMap.put(eLit.getLiteral(), eLit); } setEStructuralFeature(instance, eAtt, value, litMap); } else { setEStructuralFeature(instance, eAtt, value); } }
From source file:gov.nih.nci.caintegrator.common.PermissibleValueUtil.java
private static void addStringValue(Collection<PermissibleValue> abstractPermissibleValues, String displayString) {//from w w w . jav a2s.c o m PermissibleValue newPermissibleValue = new PermissibleValue(); newPermissibleValue.setValue(displayString); abstractPermissibleValues.add(newPermissibleValue); }
From source file:Main.java
public static Collection<Element> fetchSubElements(Element e, String subElementName) { if (e == null || subElementName == null) { return null; }//from ww w .j av a 2 s . c om subElementName = subElementName.toUpperCase(); Collection<Element> elements = new ArrayList<Element>(); NodeList list = e.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i) instanceof Element) { Element element = (Element) list.item(i); if (element.getTagName().toUpperCase().equals(subElementName)) { elements.add(element); } } } return elements; }
From source file:au.com.dw.testing.AssertUtil.java
/** * Version of assertEqualsAny() for comparing strings with the new line formatting * removed./*from www . ja v a 2s.c o m*/ * * This should make the comparison of generated logs more robust since don't have to * worry about changes in new line formatting. * * @param expected * @param actual */ public static void assertEqualsAnyWithoutFormatting(String message, Collection<String> expected, String actual) { Collection<String> expectedWithoutFormatting = new ArrayList<String>(); String actualWithoutFormatting = null; if (expected != null) { for (String expectedElement : expected) { expectedWithoutFormatting.add(expectedElement.replaceAll(SystemUtils.LINE_SEPARATOR, "")); } } if (actual != null) { actualWithoutFormatting = actual.replaceAll(SystemUtils.LINE_SEPARATOR, ""); } assertEqualsAny(message, expectedWithoutFormatting, actualWithoutFormatting); }
From source file:com.evolveum.midpoint.schema.SelectorOptions.java
public static <T> Collection<SelectorOptions<T>> createCollection(ItemPath path, T options) { Collection<SelectorOptions<T>> optionsCollection = new ArrayList<>(1); optionsCollection.add(create(path, options)); return optionsCollection; }
From source file:com.evolveum.midpoint.schema.SelectorOptions.java
public static <T> Collection<SelectorOptions<T>> createCollection(QName pathQName, T options) { Collection<SelectorOptions<T>> optionsCollection = new ArrayList<>(1); optionsCollection.add(create(pathQName, options)); return optionsCollection; }
From source file:com.evolveum.midpoint.schema.SelectorOptions.java
public static <T> Collection<SelectorOptions<T>> createCollection(T options) { Collection<SelectorOptions<T>> optionsCollection = new ArrayList<>(1); optionsCollection.add(new SelectorOptions<>(options)); return optionsCollection; }
From source file:com.stratio.deep.commons.utils.CellsUtils.java
/** * Returns a Collection of SparkSQL Row objects from a collection of Stratio Cells * objects/*from w w w. j a v a 2s. co m*/ * * @param cellsCol Collection of Cells for transforming * @return Collection of SparkSQL Row created from Cells. */ public static Collection<Row> getRowsFromsCells(Collection<Cells> cellsCol) { Collection<Row> result = new ArrayList<>(); for (Cells cells : cellsCol) { result.add(getRowFromCells(cells)); } return result; }