001// -------------------------------------------------------------------------------- 002// Copyright 2002-2024 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 /** Creates a new instance of FieldDefinition */ 033 public FieldDefinition(String fieldName, FieldType fieldType, Boolean isRequired, Long minimumValue, Long maximumValue) { 034 this.fieldName = fieldName; 035 this.fieldType = fieldType; 036 this.isRequired = isRequired; 037 this.minimumValue = minimumValue; 038 this.maximumValue = maximumValue; 039 } 040 041 /** Creates a new instance of FieldDefinition 042 */ 043 /** Creates a new instance of FieldDefinition */ 044 public FieldDefinition(FieldDefinition fieldDefinition) { 045 fieldName = fieldDefinition.getFieldName(); 046 fieldType = fieldDefinition.getFieldType(); 047 isRequired = fieldDefinition.getIsRequired(); 048 minimumValue = fieldDefinition.getMinimumValue(); 049 maximumValue = fieldDefinition.getMaximumValue(); 050 } 051 052 /** Creates a new instance of FieldDefinition */ 053 public FieldDefinition() { 054 } 055 056 /** fieldName is a colon separated list of values. The first value should be the name 057 * of the field in the submitted form. Following that, there may be zero or more values 058 * that should be in the format "name,field" - where name is the name of the parameter, and 059 * field is the form field that the parameter's value may be found in. For example: 060 * "unitPrice:currencyIsoName,currencyIsoName" 061 */ 062 public void setFieldName(String fieldName) { 063 this.fieldName = fieldName; 064 } 065 066 public String getFieldName() { 067 return fieldName; 068 } 069 070 public void setFieldType(FieldType fieldType) { 071 this.fieldType = fieldType; 072 } 073 074 public FieldType getFieldType() { 075 return fieldType; 076 } 077 078 public void setIsRequired(Boolean isRequired) { 079 this.isRequired = isRequired; 080 } 081 082 public Boolean getIsRequired() { 083 return isRequired; 084 } 085 086 /** minimumValue has two meanings. When dealing with Integers or Longs, it sets 087 * a lower limit for the acceptable value of the field, if its not equal to null. 088 * However, if the field is a String, it will set a minimum length required for 089 * the String, if its not equal to null. 090 * @param minimumValue The new minimumValue, may be null 091 */ 092 public void setMinimumValue(Long minimumValue) { 093 this.minimumValue = minimumValue; 094 } 095 096 /** Get the current minimumValue 097 * @return The current minimumValue, may be null 098 */ 099 public Long getMinimumValue() { 100 return minimumValue; 101 } 102 103 /** maximumValue has two meanings. When dealing with Integers or Longs, it sets 104 * an upper limit for the acceptable value of the field, if its not equal to null. 105 * However, if the field is a String, it will set a maximum length for the String, 106 * if its not equal to null. 107 * @param maximumValue The new maximumValue, may be null 108 */ 109 public void setMaximumValue(Long maximumValue) { 110 this.maximumValue = maximumValue; 111 } 112 113 /** Get the current maximumValue 114 * @return The current maximumValue, may be null 115 */ 116 public Long getMaximumValue() { 117 return maximumValue; 118 } 119 120}