/*
 * Copyright 2016 PantherCode
 *
 * 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 org.panthercode.arctic.core.processing.modules.helper;

import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.panthercode.arctic.core.arguments.ArgumentUtils;

/**
 * TODO: documentation
 * TODO: Exceptions in function signature
 */
public class TimerOptions extends RepeaterOptions {

    /**
     *
     */
    private long maximalDurationInMillis = 60000L;

    /**
     *
     */
    public TimerOptions() {
        super();
    }

    /**
     * @param maximalDurationInMillis
     */
    public TimerOptions(long maximalDurationInMillis) {
        this(maximalDurationInMillis, 1000L);
    }

    /**
     * @param maximalDurationInMillis
     * @param delayTimeInMillis
     */
    public TimerOptions(long maximalDurationInMillis, long delayTimeInMillis) {
        this(maximalDurationInMillis, delayTimeInMillis, true, true);
    }

    /**
     * @param maximalDurationInMillis
     * @param delayTimeInMillis
     * @param ignoreExceptions
     * @param canQuit
     */
    public TimerOptions(long maximalDurationInMillis,
                        long delayTimeInMillis,
                        boolean ignoreExceptions,
                        boolean canQuit) {
        super(delayTimeInMillis, ignoreExceptions, canQuit);

        this.setMaximalDuration(maximalDurationInMillis);
    }

    /**
     * @return
     */
    public long getMaximalDuration() {
        return this.maximalDurationInMillis;
    }

    /**
     * @param maximalDurationInMillis
     */
    public void setMaximalDuration(long maximalDurationInMillis) {
        ArgumentUtils.assertGreaterOrEqualsZero(maximalDurationInMillis, "maximal duration");

        this.maximalDurationInMillis = maximalDurationInMillis;
    }

    @Override
    public String toString() {
        return super.toString() + " maximal duration = " + this.maximalDurationInMillis + " ms";
    }

    /**
     * Returns a hash code value of this object.
     *
     * @return Returns a hash code value of this object.
     */
    @Override
    public int hashCode() {
        return Math.abs(new HashCodeBuilder()
                .append(super.hashCode())
                .append(this.maximalDurationInMillis)
                .toHashCode());
    }

    /**
     * Checks if this object is equals to another one.
     *
     * @param obj other object for comparison
     * @return Returns <code>true</code> if both objects are equal; Otherwise <tt>false</tt>.
     */
    @Override
    public boolean equals(final Object obj) {
        if (obj == this) {
            return true;
        }

        if (!(obj instanceof TimerOptions)) {
            return false;
        }

        TimerOptions options = (TimerOptions) obj;

        return super.equals(obj) &&
                this.getMaximalDuration() == options.getMaximalDuration();
    }
}

@@ -784,68 +784,132 @@
 %0A * 
-TODO: documentation%0A * TODO: Exceptions in function signatur
+Builder class to configure parameters for controlling the loop process of the %3Ctt%3ETimer%3C/tt%3E class.%0A *%0A * @author PantherCod
 e%0A *
@@ -969,32 +969,81 @@
 %0A%0A    /**%0A     *
+ actual value of maximal duration of loop process
 %0A     */%0A    pri
@@ -1097,24 +1097,44 @@
   /**%0A     *
+ Default Constructor
 %0A     */%0A   
@@ -1182,32 +1182,58 @@
 %0A    %7D%0A%0A    /**%0A
+     * Constructor%0A     *%0A
      * @param ma
@@ -1245,32 +1245,65 @@
 DurationInMillis
+ maximal duration of loop process
 %0A     */%0A    pub
@@ -1404,32 +1404,58 @@
 %0A    %7D%0A%0A    /**%0A
+     * Constructor%0A     *%0A
      * @param ma
@@ -1479,40 +1479,111 @@
 llis
-%0A     * @param delayTimeInMillis
+ maximal duration of loop process%0A     * @param delayTimeInMillis       delay time after each loop step
 %0A   
@@ -1744,32 +1744,58 @@
 %0A    %7D%0A%0A    /**%0A
+     * Constructor%0A     *%0A
      * @param ma
@@ -1819,93 +1819,243 @@
 llis
-%0A     * @param delayTimeInMillis%0A     * @param ignoreExceptions%0A     * @param canQuit
+ maximal duration of loop process%0A     * @param delayTimeInMillis       delay time after each loop step%0A     * @param ignoreExceptions        flag to ignore occurred exceptions%0A     * @param canQuit                 flag to quit process
 %0A   
@@ -2400,159 +2400,387 @@
   * 
-@return%0A     */%0A    public long getMaximalDuration() %7B%0A        return this.maximalDurationInMillis;%0A    %7D%0A%0A    /**%0A     * @param maximalDurationInMilli
+Returns the actual value of maximal duration of loop process.%0A     *%0A     * @return Returns the actual value of maximal duration of loop process.%0A     */%0A    public long getMaximalDuration() %7B%0A        return this.maximalDurationInMillis;%0A    %7D%0A%0A    /**%0A     * Sets the maximal duration of loop process.%0A     *%0A     * @param maximalDurationInMillis maximal duration of loop proces
 s%0A  
@@ -3014,24 +3014,163 @@
 lis;%0A    %7D%0A%0A
+    /**%0A     * Returns a string representation of the object.%0A     *%0A     * @return Returns a string representation of the object.%0A     */%0A
     @Overrid
@@ -3802,23 +3802,19 @@
 ns %3C
-code
+tt
 %3Etrue%3C/
-code
+tt
 %3E if

modify documentation