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

io.deepsense.neptune.clientlibrary.models.impl.parameters.ParameterImpl Maven / Gradle / Ivy

There is a newer version: 1.6.1
Show newest version
/**
 * Copyright (c) 2016, CodiLime Inc.
 */

package io.deepsense.neptune.clientlibrary.models.impl.parameters;

import com.google.common.base.Preconditions;
import io.deepsense.neptune.clientlibrary.models.Parameter;
import io.deepsense.neptune.clientlibrary.models.ParameterType;
import io.deepsense.neptune.clientlibrary.models.ParameterValue;

import java.util.Objects;

public final class ParameterImpl implements Parameter {

    private final String name;

    private final ParameterType type;

    private final ParameterValue value;

    private ParameterImpl(String name, ParameterType type, ParameterValue value) {
        this.name = Preconditions.checkNotNull(name);
        this.type = Preconditions.checkNotNull(type);
        this.value = Preconditions.checkNotNull(value);
    }

    public static Parameter createBooleanParameter(String name, Boolean value) {
        return new ParameterImpl(name, ParameterType.BOOLEAN, ParameterValueImpl.fromBoolean(name, value));
    }

    public static Parameter createIntParameter(String name, Integer value) {
        return new ParameterImpl(name, ParameterType.INT, ParameterValueImpl.fromInteger(name, value));
    }

    public static Parameter createDoubleParameter(String name, Double value) {
        return new ParameterImpl(name, ParameterType.DOUBLE, ParameterValueImpl.fromDouble(name, value));
    }

    public static Parameter createStringParameter(String name, String value) {
        return new ParameterImpl(name, ParameterType.STRING, ParameterValueImpl.fromString(name, value));
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public ParameterType getType() {
        return type;
    }

    @Override
    public ParameterValue getValue() {
        return value;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ParameterImpl parameter = (ParameterImpl) o;
        return Objects.equals(name, parameter.name)
                && type == parameter.type
                && Objects.equals(value, parameter.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, type, value);
    }

    @Override
    public String toString() {
        return "ParameterImpl{"
                + "name='" + name + '\''
                + ", type=" + type
                + ", value=" + value
                + '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy