/*
 * Copyright 2014-2017 Web Firm Framework
 *
 * 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.
 * @author WFF
 */
package com.webfirmframework.wffweb.tag.html.html5.attribute.global;

import com.webfirmframework.wffweb.InvalidValueException;
import com.webfirmframework.wffweb.tag.html.attribute.AttributeNameConstants;
import com.webfirmframework.wffweb.tag.html.attribute.core.AbstractAttribute;
import com.webfirmframework.wffweb.tag.html.identifier.GlobalAttributable;

/**
 * {@code <element hidden> }
 *
 * <pre>
 * The hidden attribute is a boolean attribute.
 *
 * When present, it specifies that an element is not yet, or is no longer, relevant.
 *
 * Browsers should not display elements that have the hidden attribute specified.
 *
 * The hidden attribute can also be used to keep a user from seeing an element until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the hidden attribute, and make the element visible.
 * </pre>
 *
 * @author WFF
 *
 */
public class Hidden extends AbstractAttribute implements GlobalAttributable {

    private static final long serialVersionUID = 1_0_0L;

    private Boolean hidden;

    {
        super.setAttributeName(AttributeNameConstants.HIDDEN);
        init();
    }

    public Hidden() {
        setAttributeValue(null);
    }

    /**
     *
     *
     * @param value
     *            the value should be either true or false
     * @author WFF
     * @since 1.1.4
     */
    public Hidden(final String value) {
        if ("hidden".equals(value)) {
            hidden = true;
        } else if ("true".equals(value) || "false".equals(value)) {
            hidden = Boolean.parseBoolean(value);
        } else {
            throw new InvalidValueException(
                    "the value should be either true or false");
        }
        setAttributeValue(value);
    }

    public Hidden(final Boolean hidden) {
        if (hidden == null) {
            setAttributeValue(null);
        } else {
            setAttributeValue(
                    hidden.booleanValue() ? "hidden" : String.valueOf(hidden));
        }
        this.hidden = hidden;
    }

    /**
     * invokes only once per object
     *
     * @author WFF
     * @since 1.0.0
     */
    protected void init() {
        // to override and use this method
    }

    /**
     * @return the hidden
     * @author WFF
     * @since 1.0.0
     */
    public boolean isHidden() {
        return hidden == null || hidden.booleanValue() ? true : false;
    }

    /**
     * @param hidden
     *            the hidden to set. {@code null} will remove the value.
     * @author WFF
     * @since 1.0.0
     */
    public void setHidden(final Boolean hidden) {
        if (hidden == null) {
            setAttributeValue(null);
        } else {
            setAttributeValue(
                    hidden.booleanValue() ? "hidden" : String.valueOf(hidden));
        }
        this.hidden = hidden;
    }

}

@@ -899,16 +899,89 @@
 ribute;%0A
+import com.webfirmframework.wffweb.tag.html.identifier.BooleanAttribute;%0A
 import c
@@ -1635,16 +1635,24 @@
 ttribute
+%0A       
  impleme
@@ -1673,16 +1673,34 @@
 ibutable
+, BooleanAttribute
  %7B%0A%0A    
@@ -1866,32 +1866,188 @@
  init();%0A    %7D%0A%0A
+    /**%0A     * sets the default value as %3Ccode%3Ehidden%3C/code%3E (since 2.1.5). If value is%0A     * not required then use %3Ccode%3Enew Hidden(null)%3C/code%3E.%0A     */%0A
     public Hidde
@@ -2074,28 +2074,53 @@
 ributeValue(
-null
+AttributeNameConstants.HIDDEN
 );%0A    %7D%0A%0A  

Added default value for Hidden attribute class