package com.ycwl.basic.image.watermark;

import com.ycwl.basic.image.watermark.enums.ImageWatermarkOperatorEnum;
import com.ycwl.basic.image.watermark.exception.ImageWatermarkUnsupportedException;
import com.ycwl.basic.image.watermark.operator.IOperator;
import com.ycwl.basic.image.watermark.operator.DefaultImageWatermarkOperator;
import com.ycwl.basic.image.watermark.operator.LeicaWatermarkOperator;
import com.ycwl.basic.image.watermark.operator.NormalWatermarkOperator;

public class ImageWatermarkFactory {
    public static IOperator get(String watermarkType) {
        ImageWatermarkOperatorEnum type = ImageWatermarkOperatorEnum.getByCode(watermarkType);
        if (type == null) {
            throw new ImageWatermarkUnsupportedException(watermarkType);
        }
        return get(type);
    }
    public static IOperator get(ImageWatermarkOperatorEnum type) {
        return switch (type) {
            case WATERMARK -> new DefaultImageWatermarkOperator();
            case NORMAL -> new NormalWatermarkOperator();
            case LEICA -> new LeicaWatermarkOperator();
            default -> throw new ImageWatermarkUnsupportedException("不支持的类型" + type.name());
        };
    }
}
