Example usage for java.util List remove

List of usage examples for java.util List remove

Introduction

In this page you can find the example usage for java.util List remove.

Prototype

E remove(int index);

Source Link

Document

Removes the element at the specified position in this list (optional operation).

Usage

From source file:com.sapienter.jbilling.server.metafields.MetaFieldHelper.java

/**
 * Usefull method for updating meta fields with validation before entity saving
 * @param entity    target entity/*from   w  ww . j  av  a2s  . co  m*/
 * @param dto       dto with new data
 */
public static void updateMetaFieldsWithValidation(Integer languageId, Integer entityId, Integer accountTypeId,
        MetaContent entity, MetaContent dto, Boolean global) {
    List<EntityType> entityTypes = new LinkedList(Arrays.asList(entity.getCustomizedEntityType()));
    if (entityTypes.contains(EntityType.ACCOUNT_TYPE)) {
        entityTypes.remove(EntityType.ACCOUNT_TYPE);
    }

    Map<String, MetaField> availableMetaFields = MetaFieldBL.getAvailableFields(entityId,
            entityTypes.toArray(new EntityType[entityTypes.size()]));

    for (String fieldName : availableMetaFields.keySet()) {
        MetaFieldValue newValue = dto.getMetaField(fieldName, null);
        MetaFieldValue prevValue = entity.getMetaField(fieldName, null);
        if (newValue == null) { // try to search by id, may be temp fix
            MetaField metaFieldName = availableMetaFields.get(fieldName);
            newValue = dto.getMetaField(metaFieldName.getId());
        }
        // TODO: (VCA) - we want the null values for the validation
        // if ( null != newValue && null != newValue.getValue() ) {

        if (newValue != null) {
            entity.setMetaField(entityId, null, fieldName, newValue.getValue());
        } else if ((global != null) && global.equals(Boolean.TRUE) && (prevValue != null)) {
            /*
             * if user edits a global category and retains its global scope
             * then don't filter out null meta-fields and retain previous values
             * */
            entity.setMetaField(entityId, null, fieldName, prevValue.getValue());
        } else {
            /*
             * if user edits a global category and marks it as non-global only then filter out null meta-fields
             * */
            entity.setMetaField(entityId, null, fieldName, null);
        }
        // } //else {
        //no point creating null/empty-value records in db
        //}
    }

    // Updating and validating of ait meta fields is done in a separate method
    for (MetaFieldValue value : entity.getMetaFields()) {
        MetaFieldBL.validateMetaField(languageId, value.getField(), value, entity);
    }

    removeEmptyMetaFields(entity);
}

From source file:de.unisb.cs.st.javalanche.mutation.runtime.testDriver.junit.Junit4MutationTestDriver.java

public static Map<String, Description> getTests(Runner r) {
    Map<String, Description> testMap = new HashMap<String, Description>();
    List<Description> descs = new ArrayList<Description>();
    Description description = r.getDescription();
    logger.debug(description);/*w w  w .j  av  a 2  s. com*/
    descs.add(description);
    while (descs.size() > 0) {
        Description d = descs.remove(0);
        ArrayList<Description> children = d.getChildren();
        if (children != null && children.size() > 0) {
            descs.addAll(children);
        } else {
            String testName = getTestName(d);
            String insertTestName = testName;
            int count = 0;
            while (testMap.containsKey(insertTestName)) {
                count++;
                insertTestName = testName + "-instance-" + count;
            }
            logger.debug("Got test case: " + insertTestName + " Desc: " + d);
            testMap.put(insertTestName, d);
        }

    }
    return testMap;
}

From source file:com.projecttango.examples.java.floorplan.PlanBuilder.java

/**
 * Creates a new Floorplan object beased on the measurements that we have so far.
 *
 * @param wallMeasurementList List of WallMeasurements to use as input to build the plan.
 *                            It must have only one measurement per wall.
 * @param closed              If true, close the floor plan and intersect the first and last
 *                            measurements. If false, continue the floor plan.
 *//*from w w  w . ja  v a 2  s.c o  m*/
public static Floorplan buildPlan(List<WallMeasurement> wallMeasurementList, boolean closed) {
    List<float[]> planPoints = new ArrayList<float[]>();
    WallMeasurement lastWallMeasurement = null;
    // Intersect every measurement with the previous one and add the result to the plan.
    if (!wallMeasurementList.isEmpty()) {
        boolean first = true;
        float[] lastAddedPoint = null;
        for (WallMeasurement wallMeasurement : wallMeasurementList) {
            if (lastWallMeasurement != null) {
                if (!first) {
                    planPoints.remove(lastAddedPoint);
                }
                planPoints.add(wallMeasurement.intersect(lastWallMeasurement));
                first = false;
            }
            float[] openGlWall = wallMeasurement.getPlaneTransform();
            float[] measurementPoint = new float[] { openGlWall[12], openGlWall[13], openGlWall[14] };
            planPoints.add(measurementPoint);
            lastWallMeasurement = wallMeasurement;
            lastAddedPoint = measurementPoint;
        }

        // If closing the floor plan, intersect the first and last measurements.
        if (closed) {
            planPoints.remove(lastAddedPoint);
            planPoints.add(lastWallMeasurement.intersect(wallMeasurementList.get(0)));
            planPoints.remove(planPoints.get(0));
        }
    }
    return new Floorplan(planPoints);
}

From source file:Commander.Main.java

private static void prepareCommand(String string) {
    String extension = null;/*  w  w  w . j  a va 2s. c o  m*/
    List<String> options;
    String command;
    String[] commands = string.split(",");
    //Split to extension, options and command

    for (String s : commands) {
        options = getOptions(string);
        string = options.remove(options.size() - 1); //Get command without options
        String website = string;
        if (!website.contains("http") && !website.contains("https")) {
            if (!website.contains("www.")) {
                website = "http://www." + website;
            } else {
                website = "http://" + website;
            }
        }
        if (new UrlValidator().isValid(website)) {
            //Website
            System.out.println("website");
            runWebsite(website);
        } else {
            //Not a website
            if (string.lastIndexOf(".") < string.length() - 1 && string.lastIndexOf(".") > 0) {
                extension = string.substring(string.lastIndexOf("."), string.length() - 1);
                command = string.replace("." + extension, "");
            } else {
                command = string;
            }
        }
    }
    System.out.println(string);
}

From source file:com.mattermost.service.Promise.java

public static Promise<String> whenAll(Promise... promises) {
    final Promise<String> promise = new Promise<String>();
    final StringBuilder sb = new StringBuilder();
    final List<Object> pending = new ArrayList<Object>(promises.length);
    for (Promise p : promises) {
        pending.add(p);/*from w  w w . jav  a  2s  .  com*/
        p.then(new IResultListener() {
            @Override
            public void onResult(Promise result) {
                if (result.getError() != null) {
                    sb.append(result.getError());
                }
                pending.remove(result);
                if (pending.isEmpty()) {
                    String errors = sb.toString().trim();
                    if (errors.length() > 0) {
                        promise.onResult(null, errors);
                    } else {
                        promise.onResult(null, null);
                    }
                }
            }
        });
    }
    return promise;
}

From source file:com.ace.erp.service.sys.impl.ResourceServiceImpl.java

private static void removeNoLeafMenu(List<Menu> menus) {
    if (menus.size() == 0) {
        return;//from  w w  w  .j a  v a2s  . c  om
    }
    for (int i = menus.size() - 1; i >= 0; i--) {
        Menu m = menus.get(i);
        removeNoLeafMenu(m.getChildren());
        if (!m.isHasChildren() && StringUtils.isEmpty(m.getUrl())) {
            menus.remove(i);
        }
    }
}

From source file:com.streamsets.datacollector.util.SystemProcessImpl.java

static void clean(File tempDir, int limit) {
    String[] files = tempDir.list(new FilenameFilter() {
        @Override/*  w w  w  .  j  a  va 2 s . co  m*/
        public boolean accept(File dir, String name) {
            return name.endsWith(OUT_EXT) || name.endsWith(ERR_EXT);
        }
    });
    if (files != null && files.length > limit) {
        List<String> fileList = new ArrayList<>(files.length);
        fileList.addAll(Arrays.asList(files));
        Collections.sort(fileList);
        while (fileList.size() > limit) {
            File file = new File(tempDir, fileList.remove(0));
            if (!FileUtils.deleteQuietly(file)) {
                LOG.warn("Could not delete: {}", file);
            }
        }
    }
}

From source file:gov.nih.nci.protexpress.util.ManageProtAppInputOutputHelper.java

/**
 * Removes potential duplicate inputs from the list.
 *
 * @param lstInputs the protocol application inputs.
 * @param lstPotentialInputs the list of potential inputs.
 *//* ww w  . j  ava  2s  . c  om*/
private static void removeDuplicateInputs(List<InputOutputObject> lstInputs,
        List<InputOutputObject> lstPotentialInputs) {
    ListIterator<InputOutputObject> iterPAInputs = lstInputs.listIterator();
    while (iterPAInputs.hasNext()) {
        InputOutputObject currentInput = iterPAInputs.next();
        if ((currentInput.getId() != null) && !StringUtils.isBlank(currentInput.getId().toString())
                && lstPotentialInputs.contains(currentInput)) {
            lstPotentialInputs.remove(currentInput);
        }
    }
}

From source file:com.ace.erp.service.sys.impl.ResourceServiceImpl.java

private static void recursiveMenu(Menu menu, List<Resource> resources) {
    for (int i = resources.size() - 1; i >= 0; i--) {
        Resource resource = resources.get(i);
        if (resource.getParentId() != null && resource.getParentId().equals(menu.getId())) {
            menu.getChildren().add(convertToMenu(resource));
            resources.remove(i);
        }/* w ww .  j a  v  a 2 s .c om*/
    }

    for (Menu subMenu : menu.getChildren()) {
        recursiveMenu(subMenu, resources);
    }
}

From source file:com.open.cas.shiro.util.CollectionsUtils.java

/**
 * a-bList./*from  ww  w .ja  v a 2  s.c om*/
 */
public static <T> List<T> subtract(final Collection<T> a, final Collection<T> b) {
    List<T> list = new ArrayList<T>(a);
    for (T element : b) {
        if (list.contains(element)) {
            list.remove(element);
        }
    }
    return list;
}