/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */

package net.ranides.assira.reflection.mockup;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.List;
import net.ranides.assira.collection.arrays.ArrayUtils;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
@SuppressFBWarnings({
    "NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", 
    "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD",
    "EI_EXPOSE_REP2",
    "EI_EXPOSE_REP",
    "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD",
})
@SuppressWarnings("PMD")
public class ForBeanModel {

    public int $width;
    
    public int $height;
    
    public boolean $show;
    
    public Boolean $state;
    
    public Integer $optional;
    
    public List<String> $list; //
    
    public List<Boolean> $listFlags; //
    
    public List<String> $listOR;
    
    public List<String> $listOW;
    
    public List<String> $listIW;
    
    public List<String> $listIWs;
    
    public List<String> $listIR; // copy
    
    public List<Long> $listIA; // copy
    
    public String[] $array; // copy
    
    public boolean[] $arrayFlags; // copy
    
    public String[] $arrayOR;
    
    public String[] $arrayOW;
    
    public String[] $arrayIR; // copy
    
    public long[] $arrayIA; // copy
    
    public String $result;

    public int getWidth() {
        return $width;
    }

    public void setWidth(int width) {
        this.$width = width;
    }

    public void setHeight(int height) {
        this.$height = height;
    }

    public int getArea() {
        return $width * $height;
    }

    public Integer getOptional() {
        return $optional;
    }

    public void setOptional(Integer optional) {
        this.$optional = optional;
    }

    public List<String> getList() {
        return copy($list);
    }

    public void setList(List<String> list) {
        this.$list = copy(list);
    }

    public List<String> getListOR() {
        return $listOR;
    }

    public void setListOW(List<String> listOW) {
        this.$listOW = listOW;
    }
    
    public void setListIW(List<String> listOW) {
        this.$listIW = listOW;
    }
    
    public void setListIW(int index, String value) {
        this.$listIW.set(index,value);
    }
    
    public void setListIWs(List<String> listOW) {
        this.$listIWs = copy(listOW);
    }
    
    public void setListIWs(int index, String value) {
        this.$listIWs.set(index,value);
    }
    
    public List<String> getListIWs() {
        return copy($listIWs);
    }

    public List<String> getListIR() {
        return copy($listIR);
    }
    
    
    public String getListIR(int index) {
        return $listIR.get(index);
    }

    public List<Long> getListIA() {
        return copy($listIA);
    }

    public void setListIA(List<Long> listIA) {
        this.$listIA = copy(listIA);
    }
    
    public void setListIA(int index, Long value) {
        $listIA.set(index, value);
    }

    public Long getListIA(int index) {
        return $listIA.get(index);
    }

    public String[] getArray() {
        return ArrayUtils.copy($array);
    }

    public void setArray(String[] array) {
        this.$array = ArrayUtils.copy(array);
    }

    public String[] getArrayOR() {
        return $arrayOR;
    }

    public void setArrayOW(String[] arrayOW) {
        this.$arrayOW = arrayOW;
    }

    public String[] getArrayIR() {
        return ArrayUtils.copy($arrayIR);
    }
    
    public String getArrayIR(int index) {
        return $arrayIR[index];
    }
    
    public long[] getArrayIA() {
        return ArrayUtils.copy($arrayIA);
    }

    public void setArrayIA(long[] arrayIA) {
        this.$arrayIA = ArrayUtils.copy(arrayIA);
    }
    
    public long getArrayIA(int index) {
        return $arrayIA[index];
    }

    public void setArrayIA(int index, long value) {
        this.$arrayIA[index] = value;
    }

    public boolean isShow() {
        return $show;
    }

    public void setShow(boolean show) {
        this.$show = show;
    }

    public Boolean getState() {
        return $state;
    }

    public void setState(Boolean state) {
        this.$state = state;
    }

    public boolean[] getArrayFlags() {
        return ArrayUtils.copy($arrayFlags);
    }
    
    public boolean isArrayFlags(int index) {
        return $arrayFlags[index];
    }

    public void setArrayFlags(boolean[] flags) {
        this.$arrayFlags = ArrayUtils.copy(flags);
    }
    
    public void setArrayFlags(int index, boolean value) {
        this.$arrayFlags[index] = value;
    }
    
    public List<Boolean> getListFlags() {
        return copy($listFlags);
    }
    
    public Boolean isListFlags(int index) {
        return $listFlags.get(index);
    }

    public void setListFlags(List<Boolean> flags) {
        this.$listFlags = copy(flags);
    }
    
    public void setListFlags(int index, Boolean value) {
        this.$listFlags.set(index,value);
    }
    
    public void connect() {
        $result = "connect:void";
    }
    
    public boolean connect(int channel) {
        $result = "connect:int:"+channel;
        return 7 == channel%10;
    }
    
    public int connect(double channel) {
        $result = "connect:double:"+channel;
        return ((int)channel) % 5;
    }
    
    public String connect(float channel) {
        $result = "connect:float:"+channel;
        return "c" + (int)channel;
    }
    
    public void connect(int channel, Integer port) {
        $result = "connect:"+channel + "/" + port;
    }
    
    public void open(String file) {
        $result = "open:" + file;
    }
    
    public void open(String file, int options) {
        $result = "open:" + file + "/" + options;
    }

    public int random() {
        // do nothing
        return 777;
    }
    
    public String getMail(String user, int id) {
        return user + "#" + id;
    }
    
    public void sendMail(String user, String content) {
        // do nothing
    }
    
    public void setConfig(String name, String value) {
        $result = name + "=" + value;
    }
    
    public String configure(String name, String value) {
        $result = name + "=" + value;
        return $result;
    }
    
    private static <T> List<T> copy(List<T> source) {
        return null!=source ? new ArrayList<>(source) : null;
    }
}
