org.richfaces.cdk.model.PropertyBase Maven / Gradle / Ivy
The newest version!
/*
* JBoss, Home of Professional Open Source
* Copyright , Red Hat, Inc. and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.richfaces.cdk.model;
import java.util.Set;
import org.richfaces.cdk.util.ComparatorUtils;
import com.google.common.collect.Sets;
/**
* @author akolonitsky
* @since Mar 19, 2010
*/
public abstract class PropertyBase extends DescriptionGroupBase implements ModelElement, Named {
private static final long serialVersionUID = 3483864006602184580L;
/**
*
* The name of bean property
*
*/
private String name;
private boolean hidden = false;
private boolean literal = false;
private boolean required = false;
private boolean readOnly = false;
private boolean passThrough = false;
private Set eventNames = Sets.newLinkedHashSet();
private MethodSignature signature;
private String defaultValue;
private String suggestedValue;
private ClassName type;
private boolean bindingAttribute;
private boolean binding;
private String aliasFor;
/**
*
* Is that bean property generate in the class or should be generated ?
*
*/
private Boolean generate;
/**
*
*
*/
public PropertyBase() {
}
/**
*
*
*
* @return the name
*/
public String getName() {
return this.name;
}
/**
*
*
*
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
*
*
*
* @return the type
*/
@Merge
public ClassName getType() {
return type;
}
/**
*
*
*
* @param type the type to set
*/
public void setType(ClassName type) {
this.type = type;
}
/**
*
*
*
* @return the aliasFor
*/
@Merge
public String getAliasFor() {
return this.aliasFor;
}
/**
*
*
*
* @param aliasFor the aliasFor to set
*/
public void setAliasFor(String aliasFor) {
this.aliasFor = aliasFor;
}
/**
*
*
*
* @return the defaultValue
*/
@Merge
public String getDefaultValue() {
return defaultValue;
}
/**
*
*
*
* @param dafaultValue - the defaultValue to set
*/
public void setDefaultValue(String dafaultValue) {
this.defaultValue = dafaultValue;
}
/**
*
*
*
* @return the suggestedValue
*/
@Merge
public String getSuggestedValue() {
return suggestedValue;
}
/**
*
*
*
* @param suggestedValue the suggestedValue to set
*/
public void setSuggestedValue(String suggestedValue) {
this.suggestedValue = suggestedValue;
}
/**
*
*
*
* @return the eventNames
*/
@Merge
public Set getEventNames() {
return eventNames;
}
/**
*
*
*
* @param eventNames the eventNames to set
*/
public void setEventNames(Set eventNames) {
this.eventNames = eventNames;
}
/**
*
*
*
* @return the hidden
*/
@Merge(preferTrue = true)
public boolean isHidden() {
return hidden;
}
/**
*
*
*
* @param hidden the hidden to set
*/
public void setHidden(boolean hidden) {
this.hidden = hidden;
}
/**
*
*
*
* @return the literal
*/
public boolean isLiteral() {
return literal;
}
/**
*
*
*
* @param literal the literal to set
*/
public void setLiteral(boolean literal) {
this.literal = literal;
}
/**
*
*
*
* @return the required
*/
public boolean isRequired() {
return required;
}
/**
*
*
*
* @param required the required to set
*/
public void setRequired(boolean required) {
this.required = required;
}
/**
*
*
*
* @param readOnly the readOnly to set
*/
public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
}
/**
*
*
*
* @return the readOnly
*/
public boolean isReadOnly() {
return readOnly;
}
/**
*
*
*
* @return the passThrough
*/
public boolean isPassThrough() {
return passThrough;
}
/**
*
*
*
* @param passThrough the passThrough to set
*/
public void setPassThrough(boolean passThrough) {
this.passThrough = passThrough;
}
/**
*
*
*
* @return the signature
*/
@Merge(overwrite = true)
public MethodSignature getSignature() {
return signature;
}
/**
*
*
*
* @param signature the signature to set
*/
public void setSignature(MethodSignature signature) {
this.signature = signature;
}
public boolean isPrimitive() {
return getType().isPrimitive();
}
@Override
public void merge(PropertyBase other) {
ComponentLibrary.merge(this, other);
}
public R accept(Visitor visitor, D data) {
return visitor.visitProperty(this, data);
}
@Override
public boolean same(PropertyBase other) {
return ComparatorUtils.nullSafeEquals(this.getName(), other.getName());
}
public boolean isBindingAttribute() {
return this.bindingAttribute;
}
/**
*
*
*
* @param bindingAttribute the bindingAttribute to set
*/
public void setBindingAttribute(boolean bindingAttribute) {
this.bindingAttribute = bindingAttribute;
}
public boolean isBinding() {
return this.binding;
}
/**
*
*
*
* @param binding the binding to set
*/
public void setBinding(boolean binding) {
this.binding = binding;
}
@Override
public String toString() {
return "PropertyModel {name: " + getName() + ", type: " + getType().getName() + "}";
}
@Merge
public Boolean getGenerate() {
return generate;
}
public void setGenerate(Boolean generate) {
this.generate = generate;
}
}