001/*
002 * Copyright (c) 2015 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Benoit Delbosc
016 */
017
018package org.nuxeo.ecm.core.query.sql.model;
019
020import java.util.ArrayList;
021
022public class EsIdentifierList extends ArrayList<String> implements Operand {
023
024    private static final long serialVersionUID = 4590324482296853715L;
025
026    public EsIdentifierList() {
027        super();
028    }
029
030    public EsIdentifierList(String identifiers) {
031        for (String index: identifiers.split(",")) {
032            this.add(index);
033        }
034    }
035
036    @Override
037    public void accept(IVisitor visitor) {
038    }
039
040    @Override
041    public String toString() {
042        StringBuilder buf = new StringBuilder();
043        if (isEmpty()) {
044            return "";
045        }
046        buf.append(get(0).toString());
047        for (int i = 1, size = size(); i < size; i++) {
048            buf.append(",").append(get(i).toString());
049        }
050        return buf.toString();
051    }
052
053}