package org.seasar.doma.it.domain;

/**
 * @param <T> T
 */
@javax.annotation.Generated(value = { "Doma", "1.36.0-SNAPSHOT" }, date = "2022-09-08T03:50:53.711+0900")
public final class _Identity<T> implements org.seasar.doma.jdbc.domain.DomainType<java.lang.Integer, org.seasar.doma.it.domain.Identity<T>> {

    static {
        org.seasar.doma.internal.Artifact.validateVersion("1.36.0-SNAPSHOT");
    }

    @SuppressWarnings("rawtypes")
    private static final _Identity singleton = new _Identity();

    private _Identity() {
    }

    @Override
    public org.seasar.doma.it.domain.Identity<T> newDomain(java.lang.Integer value) {
        return new org.seasar.doma.it.domain.Identity<T>(value);
    }

    @Override
    public Class<java.lang.Integer> getValueClass() {
        return java.lang.Integer.class;
    }

    @SuppressWarnings("unchecked")
    @Override
    public Class<org.seasar.doma.it.domain.Identity<T>> getDomainClass() {
        Class<?> clazz = org.seasar.doma.it.domain.Identity.class;
        return (Class<org.seasar.doma.it.domain.Identity<T>>) clazz;
    }

    @Override
    public org.seasar.doma.jdbc.domain.DomainWrapper<java.lang.Integer, org.seasar.doma.it.domain.Identity<T>> getWrapper(org.seasar.doma.it.domain.Identity<T> domain) {
        return new Wrapper<T>(domain);
    }

    /**
     * @return the singleton
     */
    @SuppressWarnings("unchecked")
    public static <T> _Identity<T> getSingletonInternal() {
        return (_Identity<T>) singleton;
    }

    private static class Wrapper<T> extends org.seasar.doma.wrapper.IntegerWrapper implements org.seasar.doma.jdbc.domain.DomainWrapper<java.lang.Integer, org.seasar.doma.it.domain.Identity<T>> {

        private org.seasar.doma.it.domain.Identity<T> domain;

        private Wrapper(org.seasar.doma.it.domain.Identity<T> domain) {
            this.domain = domain;
        }

        @Override
        protected java.lang.Integer doGet() {
            if (domain == null) {
                return null;
            }
            return domain.getValue();
        }

        @Override
        protected void doSet(java.lang.Integer value) {
            domain = new org.seasar.doma.it.domain.Identity<T>(value);
        }

        @Override
        public org.seasar.doma.it.domain.Identity<T> getDomain() {
            return domain;
        }
    }
}
