001// --------------------------------------------------------------------------------
002// Copyright 2002-2026 Echo Three, LLC
003//
004// Licensed under the Apache License, Version 2.0 (the "License");
005// you may not use this file except in compliance with the License.
006// You may obtain a copy of the License at
007//
008//     http://www.apache.org/licenses/LICENSE-2.0
009//
010// Unless required by applicable law or agreed to in writing, software
011// distributed under the License is distributed on an "AS IS" BASIS,
012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013// See the License for the specific language governing permissions and
014// limitations under the License.
015// --------------------------------------------------------------------------------
016
017package com.echothree.util.common.validation;
018
019import java.io.Serializable;
020
021public class FieldDefinition
022        implements Serializable {
023    
024    private String fieldName = null;
025    private FieldType fieldType = null;
026    private Boolean isRequired = null;
027    private Long minimumValue = null;
028    private Long maximumValue = null;
029    
030    /** Creates a new instance of FieldDefinition
031     */
032    public FieldDefinition(String fieldName, FieldType fieldType, Boolean isRequired, Long minimumValue, Long maximumValue) {
033        this.fieldName = fieldName;
034        this.fieldType = fieldType;
035        this.isRequired = isRequired;
036        this.minimumValue = minimumValue;
037        this.maximumValue = maximumValue;
038    }
039    
040    /** Creates a new instance of FieldDefinition
041     */
042    public FieldDefinition(FieldDefinition fieldDefinition) {
043        fieldName = fieldDefinition.getFieldName();
044        fieldType = fieldDefinition.getFieldType();
045        isRequired = fieldDefinition.getIsRequired();
046        minimumValue = fieldDefinition.getMinimumValue();
047        maximumValue = fieldDefinition.getMaximumValue();
048    }
049    
050    /** Creates a new instance of FieldDefinition */
051    public FieldDefinition() {
052    }
053    
054    /** fieldName is a colon separated list of values. The first value should be the name
055     * of the field in the submitted form. Following that, there may be zero or more values
056     * that should be in the format "name,field" - where name is the name of the parameter, and
057     * field is the form field that the parameter's value may be found in. For example:
058     * "unitPrice:currencyIsoName,currencyIsoName"
059     */
060    public void setFieldName(String fieldName) {
061        this.fieldName = fieldName;
062    }
063    
064    public String getFieldName() {
065        return fieldName;
066    }
067    
068    public void setFieldType(FieldType fieldType) {
069        this.fieldType = fieldType;
070    }
071    
072    public FieldType getFieldType() {
073        return fieldType;
074    }
075    
076    public void setIsRequired(Boolean isRequired) {
077        this.isRequired = isRequired;
078    }
079    
080    public Boolean getIsRequired() {
081        return isRequired;
082    }
083    
084    /** minimumValue has two meanings. When dealing with Integers or Longs, it sets
085     * a lower limit for the acceptable value of the field, if its not equal to null.
086     * However, if the field is a String, it will set a minimum length required for
087     * the String, if its not equal to null.
088     * @param minimumValue The new minimumValue, may be null
089     */
090    public void setMinimumValue(Long minimumValue) {
091        this.minimumValue = minimumValue;
092    }
093    
094    /** Get the current minimumValue
095     * @return The current minimumValue, may be null
096     */    
097    public Long getMinimumValue() {
098        return minimumValue;
099    }
100    
101    /** maximumValue has two meanings. When dealing with Integers or Longs, it sets
102     * an upper limit for the acceptable value of the field, if its not equal to null.
103     * However, if the field is a String, it will set a maximum length for the String,
104     * if its not equal to null.
105     * @param maximumValue The new maximumValue, may be null
106     */
107    public void setMaximumValue(Long maximumValue) {
108        this.maximumValue = maximumValue;
109    }
110    
111    /** Get the current maximumValue
112     * @return The current maximumValue, may be null
113     */    
114    public Long getMaximumValue() {
115        return maximumValue;
116    }
117    
118}