package com.fdkankan.dxf.parse.transformation.impl;

import com.fdkankan.dxf.parse.model.GeometricModel;
import com.fdkankan.dxf.parse.model.entities.GeometricCircle;
import com.fdkankan.dxf.parse.transformation.GeometricTransform;

import java.util.ArrayList;
import java.util.List;

public class GeometricCircleTransformImpl implements GeometricTransform<GeometricCircle> {

    /**
     * 实例对象
     */
    private static GeometricTransform geometricTransform;


    /**
     * 采用单例模式
     *
     * @return 返回实例对象
     */
    public static GeometricTransform getSingleInstance() {
        if (geometricTransform == null) {
            synchronized (GeometricCircleTransformImpl.class) {
                if (geometricTransform == null) {
                    geometricTransform = new GeometricCircleTransformImpl();
                }
            }
        }
        return geometricTransform;
    }


    /**
     * 转换几何圆
     *
     * @param objectList 转换的数据
     * @return List
     */
    @Override
    public List<GeometricCircle> transform(List<GeometricModel> objectList) {
        List<GeometricCircle> circleList = new ArrayList<>();;
        if (!(objectList == null || objectList.isEmpty())) {
            for (GeometricModel object : objectList) {
                if (object instanceof GeometricCircle) {
                    circleList.add((GeometricCircle) object);
                }
            }
        }
        return circleList;
    }
}
