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:forge.game.combat.CombatUtil.java

/**
 * <p>/*ww w  . j a  v a  2  s .  c  o m*/
 * finishedMandatotyBlocks.
 * </p>
 * 
 * @param combat
 *            a {@link forge.game.combat.Combat} object.
 * @return a boolean.
 */
public static String validateBlocks(final Combat combat, final Player defending) {
    final List<Card> defendersArmy = defending.getCreaturesInPlay();
    final List<Card> attackers = combat.getAttackers();
    final List<Card> blockers = CardLists.filterControlledBy(combat.getAllBlockers(), defending);

    // if a creature does not block but should, return false
    for (final Card blocker : defendersArmy) {
        if (blocker.getMustBlockCards() != null) {
            final CardCollectionView blockedSoFar = combat.getAttackersBlockedBy(blocker);
            for (Card cardToBeBlocked : blocker.getMustBlockCards()) {
                if (!blockedSoFar.contains(cardToBeBlocked)
                        && CombatUtil.canBlockMoreCreatures(blocker, blockedSoFar)
                        && combat.isAttacking(cardToBeBlocked)
                        && CombatUtil.canBlock(cardToBeBlocked, blocker)) {
                    return String.format("%s must still block %s.", blocker, cardToBeBlocked);
                }
            }
        }
        // lure effects
        if (!blockers.contains(blocker) && CombatUtil.mustBlockAnAttacker(blocker, combat)) {
            return String.format("%s must block an attacker, but has not been assigned to block any.", blocker);
        }

        // "CARDNAME blocks each turn if able."
        if (!blockers.contains(blocker) && blocker.hasKeyword("CARDNAME blocks each turn if able.")) {
            for (final Card attacker : attackers) {
                if (CombatUtil.canBlock(attacker, blocker, combat)) {
                    boolean must = true;
                    if (attacker.hasStartOfKeyword("CantBeBlockedByAmount LT")
                            || attacker.hasKeyword("Menace")) {
                        final List<Card> possibleBlockers = Lists.newArrayList(defendersArmy);
                        possibleBlockers.remove(blocker);
                        if (!CombatUtil.canBeBlocked(attacker, possibleBlockers, combat)) {
                            must = false;
                        }
                    }
                    if (must) {
                        return String.format(
                                "%s must block each turn, but was not assigned to block any attacker now",
                                blocker);
                    }
                }
            }
        }
    }

    for (final Card attacker : attackers) {
        int cntBlockers = combat.getBlockers(attacker).size();
        // don't accept blocker amount for attackers with keyword defining valid blockers amount
        if (cntBlockers > 0 && !canAttackerBeBlockedWithAmount(attacker, cntBlockers, combat))
            return String.format("%s cannot be blocked with %d creatures you've assigned", attacker,
                    cntBlockers);
    }

    return null;
}

From source file:net.chrisrichardson.foodToGo.viewOrdersTransactionScripts.dao.OrderDAOIBatisImpl.java

/** 
 * This is one of the examples from the book
 * It uses ROWNUM/* w  ww  . ja  va 2s .co m*/
 * 
 * @param startingIndex
 * @param pageSize
 * @param criteria
 * @return
 */
public PagedQueryResult findOrdersInline(int startingIndex, int pageSize, OrderSearchCriteria criteria) {
    Map map = new HashMap();
    map.put("start", new Integer(startingIndex));
    map.put("pageSize", new Integer(pageSize + startingIndex + 2));
    map.put("criteria", criteria);
    List result = getSqlMapClientTemplate().queryForList("findOrders", map);
    boolean more = result.size() > pageSize;
    if (more) {
        result.remove(pageSize);
    }
    return new PagedQueryResult(result, more);
}

From source file:com.marvelution.bamboo.plugins.sonar.tasks.web.actions.metrics.EditMetrics.java

/**
 * Method to delete a metric from the configuration
 * //w w  w.  j a  v  a  2  s  .  c  om
 * @return the view name
 */
public String doDeleteMetric() {
    if (!bambooPermissionManager.hasPlanPermission(BambooPermission.WRITE.toString(), getPlan().getKey())) {
        addActionError("Cannot add Metrics. You need edit permission to plan " + getPlan().getName());
    }
    if (StringUtils.isBlank(getSelectedMetric())) {
        addActionError("Cannot find the metric to delete");
    }
    if (hasAnyErrors()) {
        return ERROR;
    }
    LOGGER.debug("Deleting metric: " + getSelectedMetric());
    List<String> metrics = getMetrics();
    metrics.remove(getSelectedMetric());
    sonarMetricsManager.setTimeMachineMetrics(getPlan(), getUser(), metrics);
    return SUCCESS;
}

From source file:fr.gmjgav.controller.BarController.java

@RequestMapping(value = "/{barId}/{beerId}", method = DELETE)
public ResponseEntity<?> deleteBeerInBar(@PathVariable long barId, @PathVariable long beerId) {
    Bar bar = barRepository.findOne(barId);
    List<Beer> beersOfTheBar = bar.getBeers();
    Beer searchedBeer = beerRepository.findOne(beerId);
    beersOfTheBar.remove(searchedBeer);
    bar.setBeers(beersOfTheBar);//  w  ww.  j  av a2 s . c o m
    barRepository.save(bar);
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

From source file:org.kew.rmf.matchconf.web.CustomMatcherController.java

void populateEditForm(Model uiModel, String configType, String configName, Matcher matcher) {
    uiModel.addAttribute("availableItems", LibraryScanner.availableItems());
    Configuration config = Configuration.findConfigurationsByNameEquals(configName).getSingleResult();
    List<Matcher> matchers = config.getMatchers();
    matchers.remove(matcher);
    uiModel.addAttribute("matcher", matcher);
    uiModel.addAttribute("matchers", matchers);
    uiModel.addAttribute("configType", configType);
    uiModel.addAttribute("configName", configName);
}

From source file:com.smile.moment.model.impl.AudioModelImpl.java

@Override
public void load(final OnAudioLoadListener listener, final String text) {
    if (!NetWorkUtil.isNetworkAvailable(SmileApplication.getContext())) {
        listener.networkError();//from   w  w w. j  a va 2 s .c o m
        return;
    }
    VolleyHttpClient.getInstance(SmileApplication.getContext())
            .get(ApiUtil.MOMENT_VOICE_CONTENT.replace("docId", text), null, new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    try {
                        JSONObject jsonObject = new JSONObject(response);
                        JSONObject jsonObject1 = jsonObject.getJSONObject(text);
                        String time = jsonObject1.getString("ptime");
                        JSONArray video = jsonObject1.getJSONArray("video");
                        String book = video.toString();
                        List<Voice> list = new Gson().fromJson(book, new TypeToken<List<Voice>>() {
                        }.getType());
                        list.remove(list.size() - 1);
                        listener.onSuccess(list, "(" + DateTimeFormatUtil.long2stringByFormatForZh(
                                DateTimeFormatUtil.string2longSecondByFormat(time)) + ")");
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    listener.onError(error);
                }
            });
}

From source file:hr.fer.zemris.vhdllab.platform.manager.editor.impl.DefaultEditorContainer.java

@Override
public List<Editor> getAllButSelected() {
    List<Editor> openedEditors = getAll();
    Editor selectedEditor = getSelected();
    if (selectedEditor != null) {
        openedEditors.remove(selectedEditor);
    }//from w  w  w .  j  a v a  2 s  . c om
    return openedEditors;
}

From source file:com.griddynamics.banshun.web.ScanChildrenHandlerMapping.java

public void createHandlerMappingsAndRegisterHandlers(ApplicationContext child) {
    Map<String, HandlerMapping> matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(child,
            HandlerMapping.class, true, false);

    List<HandlerMapping> handlerMappings = new ArrayList<HandlerMapping>(matchingBeans.values());
    OrderComparator.sort(handlerMappings);
    handlerMappings.remove(this);
    if (handlerMappings.isEmpty()) {
        handlerMappings = createDefaultHandlerMappings(child);
        if (logger.isDebugEnabled()) {
            logger.debug("No HandlerMappings found in context '" + child.getDisplayName() + "': using default");
        }//w w w. ja v a2s .co  m
    }
    registerHandlers(handlerMappings);
}

From source file:com.croer.services.ItembusqManagement.java

@Transactional
public void borraOrtograma(List<Ortograma> ortoList, Itembusq itembusq) {
    for (Ortograma ortograma : ortoList) {
        String tmpType = itembusq.getItembusqPK().getType();
        System.out.println("itemOrtogramaRepository " + itemOrtogramaRepository);
        System.out.println("Ortis " + ortograma);
        List<ItemOrtograma> tmp = itemOrtogramaRepository.findByOrtogramaAndType(ortograma.getOrtograma(),
                tmpType);//from www . j  a  va2s  . c o m
        if (!tmp.isEmpty()) { //* Se usa para describir otros types?
            return;
        }

        List<DiccionarioOrtograma> dol = ortograma.getDiccionarioOrtogramaList();
        dol.remove(new DiccionarioOrtograma(tmpType, ortograma.getOrtograma())); //* Borra del diccionario de Productos
        if (dol.size() > 0) { //* Se usa en otros diccionarios?  
            ortogramaRepository.save(ortograma); //* Actualiza BD
            return;
        }

        //Dame sus simigramas asociados (va sus alineaciones) 
        List<Alineacion> alinList = ortograma.getAlineacionList();
        List<Simigrama> simiList = new ArrayList<>();
        for (Alineacion alineacion : alinList) {
            simiList.add(alineacion.getSimigrama1());
        }

        //Borra las alineaciones del ortograma a borrar, y en su caso el simigrama 
        for (Simigrama simigrama : simiList) {
            List<Alineacion> alinListT = simigrama.getAlineacionList();
            System.out.println("D " + simigrama.getSimigrama() + ":" + alinListT);
            System.out.println("MemEAM " + simigrama.hashCode() + ':' + alinListT.hashCode());

            Alineacion t = new Alineacion(simigrama.getSimigrama(), ortograma.getOrtograma());
            alinListT.remove(t); //* Borra las Alineacion(es) del ortograma
            if (alinListT.isEmpty()) {
                System.out.println("Borrando simigrama " + simigrama.getSimigrama() + ":" + alinListT);
                simigramaRepository.delete(simigrama); //* Borra Simigrama y todas sus Alineacion(es)
            } else {
                System.out.println("Dejando simigrama " + simigrama.getSimigrama() + ":" + alinListT);
                simigramaRepository.save(simigrama); //* Solo conserva las alineaciones de los otros ortogramas 
            }
        }

        ortogramaRepository.delete(ortograma); //* Borra el ortograma y sus DiccOrto
    }
}