All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.tsl2.nano.bean.def.IAttributeDefinition Maven / Gradle / Ivy

Go to download

TSL2 Framework Descriptor (currency-handling, generic formatter, descriptors for beans, collections, actions and values)

There is a newer version: 2.5.1
Show newest version
/*
 * File: $HeadURL$
 * Id  : $Id$
 * 
 * created by: Thomas Schneider
 * created on: Feb 15, 2012
 * 
 * Copyright: (c) Thomas Schneider 2012, all rights reserved
 */
package de.tsl2.nano.bean.def;

import java.io.Serializable;
import java.text.Format;
import java.util.Collection;

import de.tsl2.nano.action.IConstraint;
import de.tsl2.nano.action.IStatus;
import de.tsl2.nano.bean.IAttributeDef;
import de.tsl2.nano.core.cls.IAttribute;
import de.tsl2.nano.core.messaging.EventController;
import de.tsl2.nano.core.secure.ISecure;

/**
 * full bean attribute definition - to validate attribute value.
 * 
 * @author Thomas Schneider
 * @version $Revision$
 */
@SuppressWarnings("rawtypes")
public interface IAttributeDefinition extends IAttribute, IAttributeDef, IPluggable, Serializable {

    /** format-constraint for the attributes value */
    Format getFormat();
    
    /** description for the attribute */
    String getDescription();

    ValueExpression getValueExpression();
    
    /**
     * @return whether the value type is a collection.
     */
    public boolean isMultiValue();

    /** returns true, if this attribute is a relation (foreign key) to another bean */
    boolean isRelation();

    /** should be true, if this attribute defines the id of the owning bean */
    @Override
    boolean id();

    /** checks, if the given value is valid for this attribute - should not throw an exception */
    IStatus isValid(T value);

    /** define some basic attribute definitions */
    IAttributeDefinition setBasicDef(int length, boolean nullable, Format format, T defaultValue, String description);

    /** if parameter isId is true, the attribute will be handled as id-attribute for the owning bean */
    IAttributeDefinition setId(boolean isId);

    /** if parameter isUnique is true, the attribute will be handled as unique-attribute for the owning bean */
    IAttributeDefinition setUnique(boolean isUnique);

    /** define number definitions - if the attribute is a number */
    IAttributeDefinition setNumberDef(int scale, int precision);

    /** defines a min/max range constraint. use {@link ValueCompare} to compare on changing values */
    IAttributeDefinition setRange(Comparable min, Comparable max);

    /**
     * defines all allowed values - if you call {@link #setRange(Comparable, Comparable)}, you shouldn't call this
     * method
     */
    IAttributeDefinition setRange(Collection allowedValues);

    /** define constraining text format. use RegularExpressionFormat to define a regexp pattern */
    IAttributeDefinition setFormat(Format format);

    /** define maximum length */
    IAttributeDefinition setLength(int length);

    /** define scale */
    IAttributeDefinition setScale(int scale);

    /** define precision */
    IAttributeDefinition setPrecision(int precision);

    /** define nullable */
    IAttributeDefinition setNullable(boolean nullable);
    /** returns the current attribute value status (ok, warn or error) */
    IStatus getStatus();

    /** returns additional/optional presentation informations */
    IPresentable getPresentation();

    /** returns additional/optional column presentation informations */
    IPresentableColumn getColumnDefinition();

    /** set definition for a column */
    void setColumnDefinition(int index, int sortIndex, boolean sortUpDirection, int width);

    /** get attribute constraints */
    IConstraint getConstraint();
    
    /**
     * renames the attribute to be a relation from another bean. relation name parts are concatenated through '.'.
     */
    void setAsRelation(String string);
    
    ISecure getSecure();

    EventController changeHandler();
    
    boolean hasRuleCover();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy