001/* 002 * (C) Copyright 2017 Nuxeo SA (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 * bdelbosc 018 */ 019package org.nuxeo.ecm.platform.importer.mqueues.mqueues.internals; 020 021import org.nuxeo.ecm.platform.importer.mqueues.mqueues.MQPartition; 022 023/** 024 * @since 9.2 025 */ 026public class MQPartitionGroup { 027 public final String group; 028 public final String name; 029 public final int partition; 030 031 public MQPartitionGroup(String group, MQPartition mqp) { 032 this.group = group; 033 this.name = mqp.name(); 034 this.partition = mqp.partition(); 035 } 036 037 038 public MQPartitionGroup(String group, String name, int partition) { 039 this.group = group; 040 this.name = name; 041 this.partition = partition; 042 } 043 044 @Override 045 public boolean equals(Object o) { 046 if (this == o) return true; 047 if (o == null || getClass() != o.getClass()) return false; 048 049 MQPartitionGroup that = (MQPartitionGroup) o; 050 051 if (partition != that.partition) return false; 052 if (group != null ? !group.equals(that.group) : that.group != null) return false; 053 return name != null ? name.equals(that.name) : that.name == null; 054 } 055 056 @Override 057 public int hashCode() { 058 int result = group != null ? group.hashCode() : 0; 059 result = 31 * result + (name != null ? name.hashCode() : 0); 060 result = 31 * result + partition; 061 return result; 062 } 063 064 @Override 065 public String toString() { 066 return String.format("%s:%s-%02d", group, name, partition); 067 } 068 069}