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

io.getunleash.variant.VariantDefinition Maven / Gradle / Ivy

There is a newer version: 9.2.4
Show newest version
package io.getunleash.variant;

import io.getunleash.Variant;
import io.getunleash.lang.Nullable;
import java.util.Collections;
import java.util.List;

public class VariantDefinition {

    private final String name;
    private final int weight;
    @Nullable private final Payload payload;
    @Nullable private final List overrides;
    @Nullable private final String stickiness;

    public VariantDefinition(
            String name,
            int weight,
            @Nullable Payload payload,
            @Nullable List overrides) {
        this(name, weight, payload, overrides, null);
    }

    public VariantDefinition(
            String name,
            int weight,
            @Nullable Payload payload,
            @Nullable List overrides,
            @Nullable String stickiness) {
        this.name = name;
        this.weight = weight;
        this.payload = payload;
        this.overrides = overrides;
        this.stickiness = stickiness;
    }

    VariantDefinition(String name, int weight) {
        this(name, weight, null, Collections.emptyList(), null);
    }

    public String getName() {
        return name;
    }

    public int getWeight() {
        return weight;
    }

    public @Nullable Payload getPayload() {
        return payload;
    }

    List getOverrides() {
        if (overrides == null) {
            return Collections.emptyList();
        } else {
            return overrides;
        }
    }

    public @Nullable String getStickiness() {
        return stickiness;
    }

    Variant toVariant() {
        return new Variant(name, payload, true, stickiness);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy