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

com.googlecode.jmapper.conversions.explicit.ConversionMethod Maven / Gradle / Ivy

Go to download

JMapper Framework is a java bean mapper based on javassist. JMapper exposes interesting features as relational mapping, dynamic conversions and more

There is a newer version: 1.6.4
Show newest version
/**
 * Copyright (C) 2012 - 2016 Alessandro Vurro.
 *
 * 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.googlecode.jmapper.conversions.explicit;


import java.util.Arrays;

import com.googlecode.jmapper.annotations.JMapConversion;
import com.googlecode.jmapper.annotations.JMapConversion.Type;

/**
 * Bean used to centralize all the informations relative to conversion method to perform.
 * @author Alessandro Vurro
 *
 */
public class ConversionMethod {
	
	
	/** Number of the method parameter. */
	public static enum ParameterNumber {ZERO, ONE, TWO};
	
	/** conversion method name */
	private String name;
	/** array of source fields */
	private String[] from;
	/** array of destination fields */
	private String[] to;
	/** identifies the conversion type (STATIC or DYNAMIC) */
	private JMapConversion.Type type;
	/** identifies the number of the method parameter */
	private ParameterNumber parameterNumber;
	/** the body conversion method */
	private String content;
	/** true if set must be avoid */
	private boolean avoidSet;
	
	public boolean isAvoidSet() {
		return avoidSet;
	}
	public void setAvoidSet(boolean avoidSet) {
		this.avoidSet = avoidSet;
	}
	public ParameterNumber getParameterNumber() {
		return parameterNumber;
	}
	public void setParameterNumber(ParameterNumber parameterNumber) {
		this.parameterNumber = parameterNumber;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String[] getFrom() {
		return from;
	}
	public void setFrom(String[] from) {
		this.from = from;
	}
	public String[] getTo() {
		return to;
	}
	public void setTo(String[] to) {
		this.to = to;
	}
	public Type getType() {
		return type;
	}
	public void setType(Type type) {
		this.type = type;
	}
	
	/**
	 * @param name name
	 * @param from source fields
	 * @param to destination fields
	 * @param type conversion type
	 * @param parameterNumber parameters number
	 * @param content conversion method content
	 * @param avoidSet true if the set method must be avoided
	 */
	public ConversionMethod(String name, String[] from, String[] to, Type type,
			ParameterNumber parameterNumber, String content, boolean avoidSet) {
		super();
		this.name = name;
		this.from = from;
		this.to = to;
		this.type = type;
		this.parameterNumber = parameterNumber;
		this.content = content;
		this.avoidSet = avoidSet;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (avoidSet ? 1231 : 1237);
		result = prime * result + ((content == null) ? 0 : content.hashCode());
		result = prime * result + Arrays.hashCode(from);
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((parameterNumber == null) ? 0 : parameterNumber.hashCode());
		result = prime * result + Arrays.hashCode(to);
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ConversionMethod other = (ConversionMethod) obj;
		if (avoidSet != other.avoidSet)
			return false;
		if (content == null) {
			if (other.content != null)
				return false;
		} else if (!content.equals(other.content))
			return false;
		if (!Arrays.equals(from, other.from))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (parameterNumber != other.parameterNumber)
			return false;
		if (!Arrays.equals(to, other.to))
			return false;
		return type == other.type;
	}
	@Override
	public String toString() {
		return "ConversionMethod [name=" + name + ", from="
				+ Arrays.toString(from) + ", to=" + Arrays.toString(to)
				+ ", type=" + type + ", parameterNumber=" + parameterNumber
				+ ", content=" + content + ", avoidSet=" + avoidSet + "]";
	}

	
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy