/**
 * Copyright 2017-2018 Gregory Moyer and contributors.
 *
 * 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.openhab.binding.lametrictime.api.local.model;

public class Wifi
{
    private Boolean active;

    /*
     * API sometimes calls this field 'mac' and other times calls it 'address'.
     * Additionally, Gson uses fields only (not methods). Therefore, if use the
     * same instance of this class to read one value and then try to write the
     * other without calling the setter, it won't work (the other value will be
     * null).
     */
    private String mac;
    private String address;

    private Boolean available;
    private String encryption;

    /*
     * API sometimes calls this field 'ssid' and other times calls it 'essid'.
     * Additionally, Gson uses fields only (not methods). Therefore, if use the
     * same instance of this class to read one value and then try to write the
     * other without calling the setter, it won't work (the other value will be
     * null).
     */
    private String ssid;
    private String essid;

    /*
     * API sometimes calls this field 'ip' and other times calls it 'ipv4'.
     * Additionally, Gson uses fields only (not methods). Therefore, if use the
     * same instance of this class to read one value and then try to write the
     * other without calling the setter, it won't work (the other value will be
     * null).
     */
    private String ip;
    private String ipv4;

    private String mode;
    private String netmask;

    /*
     * API sometimes calls this field 'signal_strength' and other times calls it
     * 'strength'. Additionally, Gson uses fields only (not methods). Therefore,
     * if use the same instance of this class to read one value and then try to
     * write the other without calling the setter, it won't work (the other
     * value will be null).
     */
    private Integer signalStrength;
    private Integer strength;

    public Boolean isActive()
    {
        return active;
    }

    public void setActive(Boolean active)
    {
        this.active = active;
    }

    public Wifi withActive(Boolean active)
    {
        this.active = active;
        return this;
    }

    public String getMac()
    {
        return mac == null ? address : mac;
    }

    public void setMac(String mac)
    {
        this.mac = mac;
        this.address = mac;
    }

    public Wifi withMac(String mac)
    {
        setMac(mac);
        return this;
    }

    public Boolean isAvailable()
    {
        return available;
    }

    public void setAvailable(Boolean available)
    {
        this.available = available;
    }

    public Wifi withAvailable(Boolean available)
    {
        this.available = available;
        return this;
    }

    public String getEncryption()
    {
        return encryption;
    }

    public void setEncryption(String encryption)
    {
        this.encryption = encryption;
    }

    public Wifi withEncryption(String encryption)
    {
        this.encryption = encryption;
        return this;
    }

    public String getSsid()
    {
        return ssid == null ? essid : ssid;
    }

    public void setSsid(String ssid)
    {
        this.ssid = ssid;
        this.essid = ssid;
    }

    public Wifi withSsid(String ssid)
    {
        setSsid(ssid);
        return this;
    }

    public String getIp()
    {
        return ip == null ? ipv4 : ip;
    }

    public void setIp(String ip)
    {
        this.ip = ip;
        this.ipv4 = ip;
    }

    public Wifi withIp(String ip)
    {
        setIp(ip);
        return this;
    }

    public String getMode()
    {
        return mode;
    }

    public void setMode(String mode)
    {
        this.mode = mode;
    }

    public Wifi withMode(String mode)
    {
        this.mode = mode;
        return this;
    }

    public String getNetmask()
    {
        return netmask;
    }

    public void setNetmask(String netmask)
    {
        this.netmask = netmask;
    }

    public Wifi withNetmask(String netmask)
    {
        this.netmask = netmask;
        return this;
    }

    public Integer getSignalStrength()
    {
        return signalStrength == null ? strength : signalStrength;
    }

    public void setSignalStrength(Integer signalStrength)
    {
        this.signalStrength = signalStrength;
        this.strength = signalStrength;
    }

    public Wifi withSignalStrength(Integer signalStrength)
    {
        setSignalStrength(signalStrength);
        return this;
    }

    @Override
    public String toString()
    {
        StringBuilder builder = new StringBuilder();
        builder.append("Wifi [active=");
        builder.append(active);
        builder.append(", mac=");
        builder.append(getMac());
        builder.append(", available=");
        builder.append(available);
        builder.append(", encryption=");
        builder.append(encryption);
        builder.append(", ssid=");
        builder.append(getSsid());
        builder.append(", ip=");
        builder.append(getIp());
        builder.append(", mode=");
        builder.append(mode);
        builder.append(", netmask=");
        builder.append(netmask);
        builder.append(", signalStrength=");
        builder.append(getSignalStrength());
        builder.append("]");
        return builder.toString();
    }
}
