All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.memority.citadel.shared.api.context.FeatureContext Maven / Gradle / Ivy

Go to download

This artifact provides the API classes that are necessary to implement general configuration Rules on the Memority IM platform.

There is a newer version: 3.43.1
Show newest version
/*
 * Copyright (c) 2016-2023 Memority. All Rights Reserved.
 *
 * This file is part of Memority Citadel API , a Memority project.
 *
 * This file is released under the Memority Public Artifacts End-User License Agreement,
 * see 
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 */
package com.memority.citadel.shared.api.context;

import com.memority.citadel.shared.api.im.operation.AttributePatch;
import com.memority.citadel.shared.api.im.operation.ObjectOperation;
import com.memority.citadel.shared.api.im.operation.ObjectPatch;

import java.util.List;
import java.util.Map;

import static java.util.Collections.*;

/**
 * Context information about the Feature being executed.
 */
public class FeatureContext {

    /**
     * The FeatureConfiguration id. Not null.
     */
    private final String featureId;

    /**
     * The Feature execution id. Nullable.
     */
    private final String featureExecutionId;

    /**
     * The index of current OperationExecution in FeatureExecution's OperationExecution list. Nullable.
     */
    private final Integer operationExecution;

    /**
     * The ObjectPatch (AttributePatch list) of the current Feature. Not null.
     */
    private final ObjectPatch objectPatch;

    /**
     * The fields of the current Feature. Nullable.
     */
    private final Map fields;

    /**
     * The object operation of the current Feature
     */
    private final ObjectOperation operation;

    public FeatureContext() {
        this(null, null, null, null, null, null);
    }

    public FeatureContext(String featureId) {
        this(featureId, null, null, null, null, null);
    }

    public FeatureContext(String featureId, List> attributePatches) {
        this(featureId, null, null, attributePatches, null, null);
    }

    public FeatureContext(String featureId, String featureExecutionId, List> attributePatches) {
        this(featureId, featureExecutionId, null, attributePatches, null, null);
    }

    public FeatureContext(String featureId, Integer operationExecution, List> attributePatches,
                          Map fields, ObjectOperation operation) {
        this(featureId, null, operationExecution, attributePatches, fields, operation);
    }

    public FeatureContext(String featureId, String featureExecutionId, Integer operationExecution, List> attributePatches,
                          Map fields, ObjectOperation operation) {
        this.featureId = featureId;
        this.featureExecutionId = featureExecutionId;
        this.operationExecution = operationExecution;
        this.objectPatch = new ObjectPatch(attributePatches == null ? emptyList() : attributePatches);
        this.fields = fields == null ? emptyMap() : unmodifiableMap(fields);
        this.operation = operation;
    }

    public String getFeatureId() {
        return featureId;
    }

    public String getFeatureExecutionId() {
        return featureExecutionId;
    }

    public ObjectPatch getObjectPatch() {
        return objectPatch;
    }

    public Integer getOperationExecution() {
        return operationExecution;
    }

    public Map getFields() {
        return fields;
    }

    public ObjectOperation getOperation() {
        return operation;
    }

    public static FeatureContext of(FeatureContext original) {
        return new FeatureContext(original.getFeatureId(), original.getFeatureExecutionId(),
                original.getOperationExecution(), original.getObjectPatch().getAttributePatches(),
                original.getFields(), original.getOperation());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy