package com.speedment.runtime.compute;

import com.speedment.common.function.ByteUnaryOperator;
import com.speedment.common.function.CharUnaryOperator;
import com.speedment.common.function.ToCharFunction;
import com.speedment.runtime.compute.expression.Expression;
import com.speedment.runtime.compute.expression.ExpressionType;
import com.speedment.runtime.compute.internal.expression.CastUtil;
import com.speedment.runtime.compute.internal.expression.MapperUtil;
import com.speedment.runtime.compute.trait.*;

/**
 * Expression that given an entity returns a {@code char} value. This expression
 * can be implemented using a lambda, or it can be a result of another
 * operation. It has additional methods for operating on it.
 *
 * @param <T> type to extract from
 *
 * @see ToCharFunction
 *
 * @author Emil Forslund
 * @since 3.1.0
 */
@FunctionalInterface
public interface ToChar<T>
    extends Expression,
    ToCharFunction<T>,
    HasAsDouble<T>,
    HasAsInt<T>,
    HasAsLong<T>,
    HasHash<T>,
    HasCompare<T> {

    @Override
    default ExpressionType getExpressionType() {
        return ExpressionType.CHAR;
    }

    @Override
    default ToDouble<T> asDouble() {
        return CastUtil.castToDouble(this);
    }

    @Override
    default ToInt<T> asInt() {
        return CastUtil.castToInt(this);
    }

    @Override
    default ToLong<T> asLong() {
        return CastUtil.castToLong(this);
    }

    default ToChar<T> map(CharUnaryOperator operator) {
        return MapperUtil.map(this, operator);
    }

    @Override
    default long hash(T object) {
        return applyAsChar(object);
    }

    @Override
    default int compare(T first, T second) {
        final char f = applyAsChar(first);
        final char s = applyAsChar(second);
        return Character.compare(f, s);
    }
}

@@ -1520,32 +1520,210 @@
 erator);%0A    %7D%0A%0A
+    default ToChar%3CT%3E toUpperCase() %7B%0A        return map(Character::toUpperCase);%0A    %7D%0A%0A    default ToChar%3CT%3E toLowerCase() %7B%0A        return map(Character::toUpperCase);%0A    %7D%0A%0A
     @Override%0A  

Add methods for switching case of characters