com.hazelcast.config.MemberGroupConfig Maven / Gradle / Ivy
/*
* Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hazelcast.config;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import static com.hazelcast.util.Preconditions.checkHasText;
import static com.hazelcast.util.Preconditions.isNotNull;
/**
* Contains the configuration for a single member group.
*
* See the {@link PartitionGroupConfig} for more information.
*/
public class MemberGroupConfig {
private final Set interfaces = new HashSet();
/**
* Adds an interface to the member group. Duplicate elements are ignored.
*
* @param ip the ip address of the interface.
* @return the updated MemberGroupConfig
* @throws IllegalArgumentException if ip is null or empty.
* @see #getInterfaces()
* @see #clear()
*/
public MemberGroupConfig addInterface(String ip) {
interfaces.add(checkHasText(ip, "ip must contain text"));
return this;
}
/**
* Removes all interfaces from the member group.
*
* If no members are in the group, the call is ignored.
*
* @return the updated MemberGroupConfig
*/
public MemberGroupConfig clear() {
interfaces.clear();
return this;
}
/**
* Gets an unmodifiable collection containing all interfaces.
*
* @return the unmodifiable collection containing all interfaces.
* @see #setInterfaces(java.util.Collection)
*/
public Collection getInterfaces() {
return Collections.unmodifiableCollection(interfaces);
}
/**
* Sets the interfaces that are part of a group.
*
* If the interfaces is empty, it will have the same effect as calling {@link #clear()}.
*
* @param interfaces the interfaces to set that are part of a group.
* @return the updated MemberGroupConfig
* @throws IllegalArgumentException if interfaces is null.
* @see #getInterfaces()
* @see #clear()
*/
public MemberGroupConfig setInterfaces(final Collection interfaces) {
isNotNull(interfaces, "interfaces");
clear();
this.interfaces.addAll(interfaces);
return this;
}
@Override
public String toString() {
return "MemberGroupConfig{interfaces=" + interfaces + '}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy