Example usage for java.util Collections copy

List of usage examples for java.util Collections copy

Introduction

In this page you can find the example usage for java.util Collections copy.

Prototype

public static <T> void copy(List<? super T> dest, List<? extends T> src) 

Source Link

Document

Copies all of the elements from one list into another.

Usage

From source file:com.isomorphic.maven.util.AntPathMatcherFilter.java

/**
 * Copies this object's inclusions and exclusions to a new instance.
 * //from www . ja  va 2s  . co  m
 * @return a new AntPathMAtcherFilter instance with copies of this instance's inclusions and exclusions
 */
public AntPathMatcherFilter copy() {
    AntPathMatcherFilter source = this;
    AntPathMatcherFilter destination = new AntPathMatcherFilter();
    Collections.copy(destination.includes, source.includes);
    Collections.copy(destination.excludes, source.excludes);
    return destination;
}

From source file:eu.scape_project.pit.proc.CommandLineProcess.java

/**
 * Construct from a list of string commands
 * @param commands/* w  ww  .ja  v a2 s.  c  o m*/
 */
public CommandLineProcess(List<String> commands) {
    this();
    Collections.copy(this.commands, commands);
}

From source file:org.apache.sqoop.shell.SqoopCommand.java

@SuppressWarnings({ "rawtypes", "unchecked" })
protected void resolveVariables(List arg) {
    List temp = new ArrayList();
    GroovyShell gs = new GroovyShell(getBinding());
    for (Object obj : arg) {
        Script scr = gs.parse("\"" + (String) obj + "\"");
        try {/*w  w w.j  a  v  a2 s  .  c  om*/
            temp.add(scr.run().toString());
        } catch (MissingPropertyException e) {
            throw new SqoopException(ShellError.SHELL_0004, e.getMessage(), e);
        }
    }
    Collections.copy(arg, temp);
}

From source file:org.kuali.coeus.common.committee.impl.web.struts.action.CommitteeScheduleActionBase.java

/**
 * This method is UI hook to delete CommitteeScheduleBase from list.
 * @param mapping/*from www . java  2 s .  c om*/
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward deleteCommitteeSchedule(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    CommitteeFormBase committeeForm = (CommitteeFormBase) form;
    Object question = request.getParameter(KRADConstants.QUESTION_INST_ATTRIBUTE_NAME);
    String methodToCall = committeeForm.getMethodToCall();
    if (question == null) {
        if (applyRules(getNewDeleteCommitteeScheduleEventInstanceHook(Constants.EMPTY_STRING,
                committeeForm.getDocument(), null,
                committeeForm.getCommitteeDocument().getCommittee().getCommitteeSchedules(),
                ErrorType.HARDERROR))) {
            return performQuestionWithoutInput(mapping, form, request, response, DELETE_QUESTION_ID,
                    DELETE_QUESTION, KRADConstants.CONFIRMATION_QUESTION, methodToCall, "");
        }
    } else {
        Object buttonClicked = request.getParameter(KRADConstants.QUESTION_CLICKED_BUTTON);
        if ((DELETE_QUESTION_ID.equals(question)) && ConfirmationQuestion.YES.equals(buttonClicked)) {

            List<CommitteeScheduleBase> list = committeeForm.getCommitteeDocument().getCommittee()
                    .getCommitteeSchedules();
            List<CommitteeScheduleBase> updatedlist = new ArrayList<CommitteeScheduleBase>(list);
            Collections.copy(updatedlist, list);
            for (CommitteeScheduleBase schedule : list) {
                if (schedule.isSelected())
                    updatedlist.remove(schedule);
            }
            committeeForm.getCommitteeDocument().getCommittee().setCommitteeSchedules(updatedlist);
        }
    }
    return mapping.findForward(Constants.MAPPING_BASIC);
}

From source file:com.alibaba.dragoon.common.protocol.MBeanServerMessageHandler.java

/**
 * @param current/*from  www  .j ava2s.  c o  m*/
 * @param current2
 * @return
 */
@SuppressWarnings("unchecked")
private List<Object> deepCopyList(Object current) throws ArrayIndexOutOfBoundsException {
    List<Object> list = new LinkedList<Object>();
    addAll(list, new Object[((List<Object>) current).size()]);
    Collections.copy(list, (List<Object>) current);

    return list;
}

From source file:org.kuali.kra.committee.web.struts.action.CommitteeScheduleAction.java

/**
 * This method is UI hook to delete CommitteeSchedule from list.
 * @param mapping/*from  www.j  a  v a2 s. c o m*/
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward deleteCommitteeSchedule(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    CommitteeForm committeeForm = (CommitteeForm) form;
    Object question = request.getParameter(KNSConstants.QUESTION_INST_ATTRIBUTE_NAME);
    String methodToCall = committeeForm.getMethodToCall();
    if (question == null) {
        if (applyRules(new DeleteCommitteeScheduleEvent(Constants.EMPTY_STRING, committeeForm.getDocument(),
                null, committeeForm.getCommitteeDocument().getCommittee().getCommitteeSchedules(),
                ErrorType.HARDERROR))) {
            return performQuestionWithoutInput(mapping, form, request, response, DELETE_QUESTION_ID,
                    DELETE_QUESTION, KNSConstants.CONFIRMATION_QUESTION, methodToCall, "");
        }
    } else {
        Object buttonClicked = request.getParameter(KNSConstants.QUESTION_CLICKED_BUTTON);
        if ((DELETE_QUESTION_ID.equals(question)) && ConfirmationQuestion.YES.equals(buttonClicked)) {

            List<CommitteeSchedule> list = committeeForm.getCommitteeDocument().getCommittee()
                    .getCommitteeSchedules();
            List<CommitteeSchedule> updatedlist = new ArrayList<CommitteeSchedule>(list);
            Collections.copy(updatedlist, list);
            for (CommitteeSchedule schedule : list) {
                if (schedule.isSelected())
                    updatedlist.remove(schedule);
            }
            committeeForm.getCommitteeDocument().getCommittee().setCommitteeSchedules(updatedlist);
        }
    }
    return mapping.findForward(Constants.MAPPING_BASIC);
}

From source file:org.exoplatform.social.portlet.UIMembersPortlet.java

/**
 * initialize members, called from {@link #getMembers()}
 *
 * @throws Exception//ww w  .  ja  v  a  2 s  .com
 */
@SuppressWarnings("unchecked")
public void initMember() throws Exception {
    Space space = getSpace();
    memberList = new ArrayList<User>();
    OrganizationService orgSrc = getApplicationComponent(OrganizationService.class);
    UserHandler userHandler = orgSrc.getUserHandler();
    if (space.getMembers() != null) {
        List<String> members = Arrays.asList(space.getMembers());
        List<String> copyMembers = new ArrayList<String>(members);
        Collections.copy(copyMembers, members);
        for (String member : members) {
            if (ArrayUtils.contains(space.getManagers(), member)) {
                copyMembers.remove(member);
            }
        }
        List<Identity> matchIdentities = getIdentityList();
        if (matchIdentities != null) {
            List<String> searchResultUserNames = new ArrayList<String>();
            String userName = null;
            for (Identity id : matchIdentities) {
                userName = id.getRemoteId();
                if (copyMembers.contains(userName)) {
                    searchResultUserNames.add(userName);
                }
            }
            copyMembers = searchResultUserNames;
        }

        for (String name : copyMembers) {
            memberList.add(userHandler.findUserByName(name));
        }
    }
}

From source file:ca.mcgill.music.ddmal.mei.MeiElement.java

/**
 * Get a list of peers of this element (not including this one).
 * Peers are defined as this element's parent's children. If this element
 * does not have a parent, an empty list is returned.
 * @return/*from   w w w.  j a v a 2  s. c  om*/
 */
public List<MeiElement> getPeers() {
    if (parent == null) {
        return new ArrayList<MeiElement>();
    }
    List<MeiElement> peers = new ArrayList<MeiElement>(parent.getChildren());
    Collections.copy(parent.getChildren(), peers);
    peers.remove(this);
    return peers;
}

From source file:com.strider.datadefender.DataDefender.java

/**
 * Returns the list of unparsed arguments as a list of table names by
 * transforming the strings to lower case.
 *
 * This guarantees table names to be in lower case, so functions comparing
 * can use contains() with a lower case name.
 *
 * If tables names are not supplied via command line, then will search the property file
 * for space separated list of table names.
 *
 * @param tableNames//from   w w w . ja v a  2 s  .  co  m
 * @param appProperties application property file
 * @param dbProperties database property file
 * @return The list of table names
 */
public static Set<String> getTableNames(final List<String> tableNames, final Properties dbProperties) {
    List<String> tableNameList = new ArrayList<String>(Arrays.asList(new String[tableNames.size()]));

    Collections.copy(tableNameList, tableNames);

    if (tableNameList.isEmpty()) {
        final String tableStr = dbProperties.getProperty("include-tables");

        if (tableStr != null) {
            tableNameList = Arrays.asList(tableStr.split(","));
            LOG.debug("Adding tables from property file.");
        }
    }

    final Set<String> tables = tableNameList.stream().map(s -> s.toLowerCase(Locale.ENGLISH))
            .collect(Collectors.toSet());

    LOG.info("Tables: " + Arrays.toString(tables.toArray()));

    return tables;
}

From source file:org.exoplatform.social.client.core.service.ActivitiesRealtimeListAccessV1Alpha1.java

/**
 * Gets the list activities from response.
 * /* w  w  w .j a  va  2  s.com*/
 * @param response
 * @return
 */
private List<RestActivity> getListActivitiesFromResponse(HttpResponse response) {
    try {
        JSONObject jsonObject = (JSONObject) JSONValue.parse(getContent(response));
        JSONArray jsonArray = (JSONArray) jsonObject.get("activities");
        List<RestActivity> activities = SocialJSONDecodingSupport.JSONArrayObjectParser(RestActivity.class,
                jsonArray.toJSONString());
        List<RestActivity> copyRestActivities = new ArrayList(activities);
        Collections.copy(copyRestActivities, activities);
        return copyRestActivities;
    } catch (Exception e) {
        throw new ServiceException(ActivityService.class, "invalid response", null);
    }
}