// Path: src/skype/utils/DateUtil.java
// static public Date getMidnight() {
// 	final LocalTime midnight = LocalTime.MIDNIGHT;
// 	final LocalDate today = LocalDate.now(ZoneId.systemDefault());
// 	final LocalDateTime todayMidnight = LocalDateTime.of(today, midnight);
// 	final LocalDateTime tomorrowMidnight = todayMidnight.plusDays(1);
// 	return Date.from(tomorrowMidnight.atZone(ZoneId.systemDefault()).toInstant());
// }
// 
// Path: src/skype/utils/timers/DailyReseter.java
// public class DailyReseter extends RepetitiveTask {
// 
// 	/** The Long item that would be set 0 every 24 hours. */
// 	private MutableLong item = null;
// 
// 	/** The starting date (if given). */
// 	private Date startDate = null;
// 
// 	/**
// 	 * Instantiates a new daily reseter. The 24 hours countdown will be started
// 	 * Immediately.
// 	 *
// 	 * @param item
// 	 *            the item to be reseted
// 	 */
// 	public DailyReseter(MutableLong item) {
// 		this(item, new Date());
// 	}
// 
// 	/**
// 	 * Instantiates a new daily reseter. The 24 hours countdown will be started at
// 	 * the specified Date.
// 	 *
// 	 * @param item
// 	 *            the item to be reseted
// 	 * @param start
// 	 *            the starting date
// 	 */
// 	public DailyReseter(MutableLong item, Date start) {
// 		super("Daily Reseter");
// 		this.item = item;
// 		startDate = start;
// 	}
// 
// 
// 	/**
// 	 * Starts the timer and the given start date (if given any) and cleans the time
// 	 * on daily basis.
// 	 * 
// 	 * @see skype.utils.timers.RepetitiveTask#startTimer()
// 	 */
// 	@Override
// 	public void startTimer() {
// 		getTimer().scheduleAtFixedRate(new TimerTask() {
// 
// 			@Override
// 			public void run() {
// 				item.setValue(0);
// 			}
// 
// 		}, startDate, DAY_TO_MILLS);
// 	}
// 
// 
// 	/**
// 	 * Stop the timer after that iteration.
// 	 * 
// 	 * @see skype.utils.timers.RepetitiveTask#stopTimer()
// 	 */
// 	@Override
// 	public void stopTimer() {
// 		getTimer().cancel();
// 	}
// 
// }
// 
// Path: src/skype/utils/timers/WarningsReseters.java
// public class WarningsReseters extends RepetitiveTask {
// 
// 	/**
// 	 * Warning clean up time is given from user from config file. The user gives the
// 	 * time in minutes.
// 	 */
// 	private final long resetingTime = Config.WarningResetTime * MINUTE_TO_MILLS;
// 
// 	/** The Warnings that may reset. */
// 	private MutableLong warnings = null;
// 
// 	/** Keeps the previous value of warnings. */
// 	private MutableLong lastValueOfWarning = null;
// 
// 	/**
// 	 * Instantiates a new ten minutes reseter. The 24 hours countdown will be started
// 	 * Immediately.
// 	 *
// 	 * @param item
// 	 *            the item to be reseted
// 	 */
// 	public WarningsReseters(MutableLong warningsRef) {
// 		this.warnings = warningsRef;
// 		lastValueOfWarning = new MutableLong(warnings.longValue());
// 	}
// 
// 	/**
// 	 * Starts the timer instantly and cleans the warnings every resetingTime minutes.
// 	 * 
// 	 * @see skype.utils.timers.RepetitiveTask#startTimer()
// 	 */
// 	@Override
// 	public void startTimer() {
// 		getTimer().scheduleAtFixedRate(new TimerTask() {
// 			public void run() {
// 				if (!checkIfChanged())
// 					warnings.setValue(0);
// 
// 				lastValueOfWarning = new MutableLong(warnings.longValue());
// 			}
// 		}, 0, resetingTime);
// 
// 	}
// 
// 	/**
// 	 * Stop the timer after that iteration.
// 	 * 
// 	 * @see skype.utils.timers.RepetitiveTask#stopTimer()
// 	 */
// 	@Override
// 	public void stopTimer() {
// 		getTimer().cancel();
// 	}
// 
// 	/**
// 	 * Checks if the value of the warnings have changed.
// 	 *
// 	 * @return true, if they are different.
// 	 */
// 	private boolean checkIfChanged() {
// 		return !warnings.equals(lastValueOfWarning);
// 	}
// 
// }


import static skype.utils.DateUtil.getMidnight;
import org.apache.commons.lang.mutable.MutableLong;
import com.skype.ChatMessage;
import com.skype.User;
import skype.utils.timers.DailyReseter;
import skype.utils.timers.WarningsReseters;
/*
 *    Copyright [2016] [Thanasis Argyroudis]

   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 skype.utils.users;





/**
 * The Class UserInformation. This class keeps useful informations about the given
 * user. Information like the total number of messages today, the current number of
 * warnings and more.
 */
public class UserInformation {

	private MutableLong warnings = new MutableLong(0);
	
	private MutableLong messagesToday = new MutableLong(0);
	
	private MutableLong commandsToday = new MutableLong(0);

	private ChatMessage lastMessage = null;
	
	/**
	 * When the last message was sent. We use that field because
	 * {@link ChatMessage#getTime()} has low resolution.
	 */
	private Long lastMessageTime = null;

	/** The user for whom we keep all that informations. */
	private final User user;

	private final WarningsReseters warningsReseter = new WarningsReseters(warnings);
	
	private final DailyReseter messagesReseter = new DailyReseter(messagesToday, getMidnight());
	
// Path: src/skype/utils/DateUtil.java
// static public Date getMidnight() {
// 	final LocalTime midnight = LocalTime.MIDNIGHT;
// 	final LocalDate today = LocalDate.now(ZoneId.systemDefault());
// 	final LocalDateTime todayMidnight = LocalDateTime.of(today, midnight);
// 	final LocalDateTime tomorrowMidnight = todayMidnight.plusDays(1);
// 	return Date.from(tomorrowMidnight.atZone(ZoneId.systemDefault()).toInstant());
// }
// 
// Path: src/skype/utils/timers/DailyReseter.java
// public class DailyReseter extends RepetitiveTask {
// 
// 	/** The Long item that would be set 0 every 24 hours. */
// 	private MutableLong item = null;
// 
// 	/** The starting date (if given). */
// 	private Date startDate = null;
// 
// 	/**
// 	 * Instantiates a new daily reseter. The 24 hours countdown will be started
// 	 * Immediately.
// 	 *
// 	 * @param item
// 	 *            the item to be reseted
// 	 */
// 	public DailyReseter(MutableLong item) {
// 		this(item, new Date());
// 	}
// 
// 	/**
// 	 * Instantiates a new daily reseter. The 24 hours countdown will be started at
// 	 * the specified Date.
// 	 *
// 	 * @param item
// 	 *            the item to be reseted
// 	 * @param start
// 	 *            the starting date
// 	 */
// 	public DailyReseter(MutableLong item, Date start) {
// 		super("Daily Reseter");
// 		this.item = item;
// 		startDate = start;
// 	}
// 
// 
// 	/**
// 	 * Starts the timer and the given start date (if given any) and cleans the time
// 	 * on daily basis.
// 	 * 
// 	 * @see skype.utils.timers.RepetitiveTask#startTimer()
// 	 */
// 	@Override
// 	public void startTimer() {
// 		getTimer().scheduleAtFixedRate(new TimerTask() {
// 
// 			@Override
// 			public void run() {
// 				item.setValue(0);
// 			}
// 
// 		}, startDate, DAY_TO_MILLS);
// 	}
// 
// 
// 	/**
// 	 * Stop the timer after that iteration.
// 	 * 
// 	 * @see skype.utils.timers.RepetitiveTask#stopTimer()
// 	 */
// 	@Override
// 	public void stopTimer() {
// 		getTimer().cancel();
// 	}
// 
// }
// 
// Path: src/skype/utils/timers/WarningsReseters.java
// public class WarningsReseters extends RepetitiveTask {
// 
// 	/**
// 	 * Warning clean up time is given from user from config file. The user gives the
// 	 * time in minutes.
// 	 */
// 	private final long resetingTime = Config.WarningResetTime * MINUTE_TO_MILLS;
// 
// 	/** The Warnings that may reset. */
// 	private MutableLong warnings = null;
// 
// 	/** Keeps the previous value of warnings. */
// 	private MutableLong lastValueOfWarning = null;
// 
// 	/**
// 	 * Instantiates a new ten minutes reseter. The 24 hours countdown will be started
// 	 * Immediately.
// 	 *
// 	 * @param item
// 	 *            the item to be reseted
// 	 */
// 	public WarningsReseters(MutableLong warningsRef) {
// 		this.warnings = warningsRef;
// 		lastValueOfWarning = new MutableLong(warnings.longValue());
// 	}
// 
// 	/**
// 	 * Starts the timer instantly and cleans the warnings every resetingTime minutes.
// 	 * 
// 	 * @see skype.utils.timers.RepetitiveTask#startTimer()
// 	 */
// 	@Override
// 	public void startTimer() {
// 		getTimer().scheduleAtFixedRate(new TimerTask() {
// 			public void run() {
// 				if (!checkIfChanged())
// 					warnings.setValue(0);
// 
// 				lastValueOfWarning = new MutableLong(warnings.longValue());
// 			}
// 		}, 0, resetingTime);
// 
// 	}
// 
// 	/**
// 	 * Stop the timer after that iteration.
// 	 * 
// 	 * @see skype.utils.timers.RepetitiveTask#stopTimer()
// 	 */
// 	@Override
// 	public void stopTimer() {
// 		getTimer().cancel();
// 	}
// 
// 	/**
// 	 * Checks if the value of the warnings have changed.
// 	 *
// 	 * @return true, if they are different.
// 	 */
// 	private boolean checkIfChanged() {
// 		return !warnings.equals(lastValueOfWarning);
// 	}
// 
// }


// Path: src/skype/utils/users/UserInformation.java
import static skype.utils.DateUtil.getMidnight;
import org.apache.commons.lang.mutable.MutableLong;
import com.skype.ChatMessage;
import com.skype.User;
import skype.utils.timers.DailyReseter;
import skype.utils.timers.WarningsReseters;

/*
 *    Copyright [2016] [Thanasis Argyroudis]

   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 skype.utils.users;





/**
 * The Class UserInformation. This class keeps useful informations about the given
 * user. Information like the total number of messages today, the current number of
 * warnings and more.
 */
public class UserInformation {

	private MutableLong warnings = new MutableLong(0);
	
	private MutableLong messagesToday = new MutableLong(0);
	
	private MutableLong commandsToday = new MutableLong(0);

	private ChatMessage lastMessage = null;
	
	/**
	 * When the last message was sent. We use that field because
	 * {@link ChatMessage#getTime()} has low resolution.
	 */
	private Long lastMessageTime = null;

	/** The user for whom we keep all that informations. */
	private final User user;

	private final WarningsReseters warningsReseter = new WarningsReseters(warnings);
	
	private final DailyReseter messagesReseter = new DailyReseter(messagesToday, getMidnight());
	
	private final DailyReseter commandsReseter = new DailyReseter(commandsToday, getMidnight());