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.LeicaWatermarkOperator;
import com.ycwl.basic.image.watermark.operator.NormalWatermarkOperator;
import com.ycwl.basic.image.watermark.operator.PrinterDefaultWatermarkOperator;

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 NORMAL -> new NormalWatermarkOperator();
            case LEICA -> new LeicaWatermarkOperator();
            case PRINTER_DEFAULT -> new PrinterDefaultWatermarkOperator();
            case PUZZLE_PRINT -> throw new ImageWatermarkUnsupportedException(
                    "PUZZLE_PRINT 仅支持边缘端处理，请使用 WatermarkEdgeService");
        };
    }
}
