1 package com.vladmihalcea.hibernate.type.basic;
2
3 import com.vladmihalcea.hibernate.type.AbstractHibernateType;
4 import com.vladmihalcea.hibernate.type.basic.internal.Iso8601MonthMonthTypeDescriptor;
5 import com.vladmihalcea.hibernate.type.util.Configuration;
6 import org.hibernate.type.descriptor.sql.IntegerTypeDescriptor;
7
8 import java.time.Month;
9
10 /**
11  * Maps a {@link Month} object type to a {@code INT}  column type
12  * which is saved as value from 1 (January) to 12 (December),
13  * according to the ISO 8601 standard.
14  *
15  * @author Martin Panzer
16  */

17 public class Iso8601MonthType extends AbstractHibernateType<Month> {
18
19     public static final Iso8601MonthType INSTANCE = new Iso8601MonthType();
20
21     public Iso8601MonthType() {
22         super(
23             IntegerTypeDescriptor.INSTANCE,
24             Iso8601MonthMonthTypeDescriptor.INSTANCE
25         );
26     }
27
28     public Iso8601MonthType(Configuration configuration) {
29         super(
30             IntegerTypeDescriptor.INSTANCE,
31             Iso8601MonthMonthTypeDescriptor.INSTANCE,
32             configuration
33         );
34     }
35
36     @Override
37     public String getName() {
38         return "month";
39     }
40
41     @Override
42     protected boolean registerUnderJavaType() {
43         return true;
44     }
45 }