/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jdbi.v3.sqlobject.mixins;

import org.jdbi.v3.sqlobject.TransactionalCallback;
import org.jdbi.v3.sqlobject.TransactionalConsumer;
import org.jdbi.v3.core.transaction.TransactionIsolationLevel;

/**
 * A mixin interface to expose transaction methods on the sql object.
 *
 * @param <SelfType> must match the interface that is extending this one.
 */
public interface Transactional<SelfType extends Transactional<SelfType>>
{
    void begin();

    void commit();

    void rollback();

    void checkpoint(String name);

    void release(String name);

    void rollback(String name);

    <R, X extends Exception> R inTransaction(TransactionalCallback<R, SelfType, X> callback) throws X;

    <R, X extends Exception> R inTransaction(TransactionIsolationLevel isolation,
                                             TransactionalCallback<R, SelfType, X> callback) throws X;

    default <X extends Exception> void useTransaction(TransactionalConsumer<SelfType, X> callback) throws X {
        inTransaction((transactional, status) -> {
            callback.useTransaction(transactional, status);
            return null;
        });
    }

    default <X extends Exception> void useTransaction(TransactionIsolationLevel isolation,
                                                      TransactionalConsumer<SelfType, X> callback) throws X {
        inTransaction(isolation, (transactional, status) -> {
            callback.useTransaction(transactional, status);
            return null;
        });
    }
}

@@ -846,24 +846,20 @@
 @param %3C
-SelfType
+This
 %3E must m
@@ -940,24 +940,20 @@
 ctional%3C
-SelfType
+This
  extends
@@ -967,24 +967,20 @@
 ctional%3C
-SelfType
+This
 %3E%3E%0A%7B%0A   
@@ -1203,32 +1203,28 @@
 Callback%3CR, 
-SelfType
+This
 , X%3E callbac
@@ -1389,24 +1389,20 @@
 back%3CR, 
-SelfType
+This
 , X%3E cal
@@ -1491,32 +1491,28 @@
 nalConsumer%3C
-SelfType
+This
 , X%3E callbac
@@ -1851,16 +1851,12 @@
 mer%3C
-SelfType
+This
 , X%3E

Rename Transactional<SelfType> generic parameter to <This>