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

com.adaptrex.core.ext.FieldDefinition Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2012 Adaptrex, LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.adaptrex.core.ext;

import com.fasterxml.jackson.annotation.JsonInclude;

public class FieldDefinition {

	private String name;
	private String type;
	private Boolean useNull;
	private String dateFormat;
	
	public FieldDefinition(String fieldName, String extType) {
		this(fieldName, extType, null);
	}
	
	public FieldDefinition(String fieldName, String extType, Boolean useNull) {
		this.name = fieldName;
		this.type = extType;
		if (useNull != null) {
			this.useNull = useNull;
		}

		/*
		 * Ext always wants "null" for number fields otherwise it generates a 0
		 */
		if (this.type.equals(ExtTypeFormatter.INT) || this.type.equals(ExtTypeFormatter.FLOAT)) {
			this.useNull = true;
		} else if (this.type.equals(ExtTypeFormatter.DATE)) {
			this.dateFormat = "Y-m-d H:i:s";
		}
	}

	@JsonInclude
	public String getName() {
		return this.name;
	}

	@JsonInclude
	public String getType() {
		return this.type;
	}

	@JsonInclude(JsonInclude.Include.NON_NULL)
	public Boolean getUseNull() {
		return this.useNull;
	}

	@JsonInclude(JsonInclude.Include.NON_NULL)
	public String getDateFormat() {
		return this.dateFormat;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy