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

org.hibernate.type.descriptor.java.JavaTypeDescriptor Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha1
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.type.descriptor.java;

import java.io.Serializable;
import java.util.Comparator;

import org.hibernate.type.descriptor.WrapperOptions;

/**
 * Descriptor for the Java side of a value mapping.
 *
 * @author Steve Ebersole
 */
public interface JavaTypeDescriptor extends Serializable {
	/**
	 * Retrieve the Java type handled here.
	 *
	 * @return The Java type.
	 */
	public Class getJavaTypeClass();

	/**
	 * Retrieve the mutability plan for this Java type.
	 *
	 * @return The mutability plan
	 */
	public MutabilityPlan getMutabilityPlan();

	/**
	 * Retrieve the natural comparator for this type.
	 *
	 * @return The natural comparator.
	 */
	public Comparator getComparator();

	/**
	 * Extract a proper hash code for this value.
	 *
	 * @param value The value for which to extract a hash code.
	 *
	 * @return The extracted hash code.
	 */
	public int extractHashCode(T value);

	/**
	 * Determine if two instances are equal
	 *
	 * @param one One instance
	 * @param another The other instance
	 *
	 * @return True if the two are considered equal; false otherwise.
	 */
	public boolean areEqual(T one, T another);

	/**
	 * Extract a loggable representation of the value.
	 *
	 * @param value The value for which to extract a loggable representation.
	 *
	 * @return The loggable representation
	 */
	public String extractLoggableRepresentation(T value);

	public String toString(T value);

	public T fromString(String string);

	/**
	 * Unwrap an instance of our handled Java type into the requested type.
	 * 

* As an example, if this is a {@code JavaTypeDescriptor} and we are asked to unwrap * the {@code Integer value} as a {@code Long} we would return something like * Long.valueOf( value.longValue() ). *

* Intended use is during {@link java.sql.PreparedStatement} binding. * * @param value The value to unwrap * @param type The type as which to unwrap * @param options The options * @param The conversion type. * * @return The unwrapped value. */ public X unwrap(T value, Class type, WrapperOptions options); /** * Wrap a value as our handled Java type. *

* Intended use is during {@link java.sql.ResultSet} extraction. * * @param value The value to wrap. * @param options The options * @param The conversion type. * * @return The wrapped value. */ public T wrap(X value, WrapperOptions options); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy