/*
*
* Goko
* Copyright (C) 2013 PsyKo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.goko.controller.grbl.v08.element.model;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
public class Property<T> {
private boolean readOnly;
private T value;
private String id;
private String label;
private List<Property<?>> children;
public Property(String id, String label, T value, boolean readOnly ) {
this.id = id;
this.label = label;
this.value = value;
this.readOnly = readOnly;
children = new ArrayList<Property<?>>();
}
public String getValue(){
String strValue = StringUtils.EMPTY;
if(value != null){
strValue = value.toString();
}
return strValue;
}
/**
* @return the children
*/
public List<Property<?>> getChildren() {
return children;
}
/**
* @param children the children to set
*/
public void setChildren(List<Property<?>> children) {
this.children = children;
}
public void addChild(Property<?> prop){
children.add(prop);
}
/**
* @return the readOnly
*/
public boolean isReadOnly() {
return readOnly;
}
/**
* @param readOnly the readOnly to set
*/
public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
}
/**
* @return the label
*/
public String getLabel() {
return label;
}
/**
* @param label the label to set
*/
public void setLabel(String label) {
this.label = label;
}
/**
* @param value the value to set
*/
public void setValue(T value) {
this.value = value;
}
public Class<T> getType(){
return (Class<T>) value.getClass();
}
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
}