All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ircclouds.irc.api.utils.StateUtils Maven / Gradle / Ivy

There is a newer version: 1.0-0014
Show newest version
package com.ircclouds.irc.api.utils;

import java.util.*;
import java.util.Map.Entry;

import com.ircclouds.irc.api.domain.*;

public class StateUtils
{
	public static IRCChannel cloneChannel(IRCChannel aChan)
	{
		IRCChannel _copy = new IRCChannel();
		
		_copy.setName(aChan.getName());
		_copy.setTopic(cloneTopic(aChan.getTopic()));
		_copy.setUsers(cloneUsers(aChan.getUsers()));
		
		return _copy;
	}

	public static Map> cloneUsers(Map> aUsers)
	{
		Map> _uCopy = new HashMap>();
		for (Entry> _entry : aUsers.entrySet())
		{
			Set _cUS = new HashSet();
			for (IRCUserStatus _us : _entry.getValue())
			{
				_cUS.add(cloneUserStatus(_us));
			}
			_uCopy.put(cloneUser(_entry.getKey()), _cUS);
		}
		
		return _uCopy;
	}
	
	public static IRCTopic cloneTopic(IRCTopic aTopic)
	{
		return new IRCTopic(aTopic.getSetBy(), aTopic.getDate(), aTopic.getValue());
	}
	
	public static IRCUser cloneUser(IRCUser aUser)
	{
		IRCUser _copy = new IRCUser();
		_copy.setNick(aUser.getNick());
		_copy.setIdent(aUser.getIdent());
		_copy.setHostname(aUser.getHostname());
		
		return _copy;
	}
	
	public static IRCUserStatus cloneUserStatus(IRCUserStatus aStatus)
	{
		return new IRCUserStatus(aStatus.getChanModeType(), aStatus.getPrefix(), aStatus.getPriority());
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy