Package com.raynigon.unit_api.jpa.type
Class QuantityJavaDescriptor
- java.lang.Object
-
- org.hibernate.type.descriptor.java.AbstractTypeDescriptor<javax.measure.Quantity<?>>
-
- com.raynigon.unit_api.jpa.type.QuantityJavaDescriptor
-
- All Implemented Interfaces:
java.io.Serializable
,org.hibernate.type.descriptor.java.BasicJavaDescriptor<javax.measure.Quantity<?>>
,org.hibernate.type.descriptor.java.JavaTypeDescriptor<javax.measure.Quantity<?>>
public class QuantityJavaDescriptor extends org.hibernate.type.descriptor.java.AbstractTypeDescriptor<javax.measure.Quantity<?>>
Describes the Quantity Java Class for Hibernate- See Also:
Quantity
, Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
QuantityJavaDescriptor(javax.measure.Unit<?> unit, com.raynigon.unit_api.core.annotation.QuantityShape shape)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.measure.Quantity<?>
fromString(java.lang.String string)
org.hibernate.type.descriptor.sql.SqlTypeDescriptor
getJdbcRecommendedSqlType(org.hibernate.type.descriptor.spi.JdbcRecommendedSqlTypeMappingContext context)
Calculates the best matching sql type by the given QuantityShapecom.raynigon.unit_api.core.annotation.QuantityShape
getQuantityShape()
Exposes the value of the shape attribute, used in QuantityJavaDescriptor#getJdbcRecommendedSqlTypejavax.measure.Unit<?>
getUnit()
Exposes the value of the unit attribute, used to wrap/unwrap valuesjava.lang.String
toString(javax.measure.Quantity<?> value)
<X> X
unwrap(javax.measure.Quantity<?> value, java.lang.Class<X> type, org.hibernate.type.descriptor.WrapperOptions options)
Creates a target object for the given Quantity<X> javax.measure.Quantity<?>
wrap(X value, org.hibernate.type.descriptor.WrapperOptions options)
Creates a new Quantity object for the given value
-
-
-
Method Detail
-
getUnit
public javax.measure.Unit<?> getUnit()
Exposes the value of the unit attribute, used to wrap/unwrap values- Returns:
- the currently used Unit
-
getQuantityShape
public com.raynigon.unit_api.core.annotation.QuantityShape getQuantityShape()
Exposes the value of the shape attribute, used in QuantityJavaDescriptor#getJdbcRecommendedSqlType- Returns:
- the currently used QuantityShape
-
toString
public java.lang.String toString(javax.measure.Quantity<?> value)
-
fromString
public javax.measure.Quantity<?> fromString(java.lang.String string)
-
unwrap
public <X> X unwrap(javax.measure.Quantity<?> value, java.lang.Class<X> type, org.hibernate.type.descriptor.WrapperOptions options)
Creates a target object for the given Quantity- Parameters:
value
- the quantity which should be used to create the new objecttype
- the type of the new object, only String and Number types are supportedoptions
- unused- Throws:
QuantityPackingException
- thrown if the type is unknown to the implementation (String and Number types are supported)
-
wrap
public <X> javax.measure.Quantity<?> wrap(X value, org.hibernate.type.descriptor.WrapperOptions options)
Creates a new Quantity object for the given value- Parameters:
value
- the value which should be used to create the new Quantity object, can either be a String or a Numberoptions
- unused- Throws:
QuantityPackingException
- thrown if the type of the given value is unknown to the implementation (String or Number are accepted types)
-
getJdbcRecommendedSqlType
public org.hibernate.type.descriptor.sql.SqlTypeDescriptor getJdbcRecommendedSqlType(org.hibernate.type.descriptor.spi.JdbcRecommendedSqlTypeMappingContext context)
Calculates the best matching sql type by the given QuantityShape
-
-