001/*
002 * (C) Copyright 2018 Nuxeo (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *       Kevin Leturc <kleturc@nuxeo.com>
018 */
019package org.nuxeo.ecm.core.bulk.message;
020
021import java.io.Serializable;
022import java.util.ArrayList;
023import java.util.List;
024
025import org.apache.commons.lang3.builder.EqualsBuilder;
026import org.apache.commons.lang3.builder.HashCodeBuilder;
027import org.apache.commons.lang3.builder.ToStringBuilder;
028
029/**
030 * A message to pass a command id and a bucket of document ids
031 *
032 * @since 10.2
033 */
034public class BulkBucket implements Serializable {
035
036    private static final long serialVersionUID = 20181021L;
037
038    protected String commandId;
039
040    protected List<String> ids = new ArrayList<>();
041
042    protected BulkBucket() {
043        // Empty constructor for Avro decoder
044    }
045
046    public BulkBucket(String commandId, List<String> ids) {
047        this.commandId = commandId;
048        this.ids = ids;
049    }
050
051    public List<String> getIds() {
052        return ids;
053    }
054
055    public void setIds(List<String> ids) {
056        this.ids = ids;
057    }
058
059    public String getCommandId() {
060        return commandId;
061    }
062
063    public void setCommandId(String commandId) {
064        this.commandId = commandId;
065    }
066
067    @Override
068    public int hashCode() {
069        return HashCodeBuilder.reflectionHashCode(this);
070    }
071
072    @Override
073    public boolean equals(Object o) {
074        return EqualsBuilder.reflectionEquals(this, o);
075    }
076
077    @Override
078    public String toString() {
079        return ToStringBuilder.reflectionToString(this);
080    }
081}