class IntersectionFeatureCollection implements VectorProcess {

    @DescribeResult(description = "Output feature collection")
    public SimpleFeatureCollection execute(
            @DescribeParameter(name = "first feature collection", description = "First feature collection") SimpleFeatureCollection firstFeatures,
            @DescribeParameter(name = "second feature collection", description = "Second feature collection") SimpleFeatureCollection secondFeatures,
            @DescribeParameter(name = "first attributes to retain", collectionType = String.class, min = 0, description = "First feature collection attribute to include") List<String> firstAttributes,
            @DescribeParameter(name = "second attributes to retain", collectionType = String.class, min = 0, description = "Second feature collection attribute to include") List<String> sndAttributes,
            @DescribeParameter(name = "intersectionMode", min = 0, description = "Specifies geometry computed for intersecting features.  INTERSECTION (default) computes the spatial intersection of the inputs. FIRST copies geometry A.  SECOND copies geometry B.", defaultValue="INTERSECTION") IntersectionMode intersectionMode,
            @DescribeParameter(name = "percentagesEnabled", min = 0, description = "Indicates whether to output feature area percentages (attributes percentageA and percentageB)") Boolean percentagesEnabled,
            @DescribeParameter(name = "areasEnabled", min = 0, description = "Indicates whether to output feature areas (attributes areaA and areaB)") Boolean areasEnabled) {
        // assign defaults
        logger.fine("INTERSECTION FEATURE COLLECTION WPS STARTED");
       
        if (percentagesEnabled == null) {
            percentagesEnabled = false;
        }
        if (areasEnabled == null) {
            areasEnabled = false;
        }
        if (intersectionMode == null) {
            intersectionMode = IntersectionMode.INTERSECTION;
        }

        // basic geometry checks
        Class firstGeomType = firstFeatures.getSchema().getGeometryDescriptor().getType()
                .getBinding();
        Class secondGeomType = secondFeatures.getSchema().getGeometryDescriptor().getType()
                .getBinding();
        if ((percentagesEnabled || areasEnabled)
                && (!isGeometryTypeIn(firstGeomType, MultiPolygon.class, Polygon.class) || !isGeometryTypeIn(
                        secondGeomType, MultiPolygon.class, Polygon.class))) {
            throw new IllegalArgumentException(
                    "In case of opMode or areaMode are true, the features in the first and second collection must be polygonal");
        }
        if (!isGeometryTypeIn(firstGeomType, MultiPolygon.class, Polygon.class,
                MultiLineString.class, LineString.class)) {
            throw new IllegalArgumentException(
                    "First feature collection must be polygonal or linear");
        }

        return new IntersectedFeatureCollection(firstFeatures, firstAttributes, secondFeatures,
                sndAttributes, intersectionMode, percentagesEnabled, areasEnabled);
    }

}