Class 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 QuantityShape
      com.raynigon.unit_api.core.annotation.QuantityShape getQuantityShape()
      Exposes the value of the shape attribute, used in QuantityJavaDescriptor#getJdbcRecommendedSqlType
      javax.measure.Unit<?> getUnit()
      Exposes the value of the unit attribute, used to wrap/unwrap values
      java.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
      • Methods inherited from class org.hibernate.type.descriptor.java.AbstractTypeDescriptor

        areEqual, extractHashCode, extractLoggableRepresentation, getComparator, getJavaType, getJavaTypeClass, getMutabilityPlan, unknownUnwrap, unknownWrap
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • QuantityJavaDescriptor

        protected QuantityJavaDescriptor​(javax.measure.Unit<?> unit,
                                         com.raynigon.unit_api.core.annotation.QuantityShape shape)
    • 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 object
        type - the type of the new object, only String and Number types are supported
        options - 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 Number
        options - 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