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

org.tensorics.core.resolve.domain.DetailedExpressionResult Maven / Gradle / Ivy

Go to download

Tensorics is a java framework which uses a tensor as a central object. A tensor represents a set of values placed in an N-dimensional space. Wherever you are tempted to use maps of maps, a tensor might be a good choice ;-) Tensorics provides methods to create, transform and performing calculations with those tensors.

There is a newer version: 0.0.81
Show newest version
/**
 * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved.
 */

package org.tensorics.core.resolve.domain;

import static java.util.Objects.requireNonNull;

import org.tensorics.core.tree.domain.Expression;
import org.tensorics.core.tree.domain.ResolvingContext;

public class DetailedExpressionResult> {

    private final E rootExpression;
    private final R value;
    private final ResolvingContext context;

    private DetailedExpressionResult(E rootExpression, R value, ResolvingContext context) {
        super();
        this.rootExpression = requireNonNull(rootExpression, "rootExpression must not be null");
        this.value = requireNonNull(value, "value must not be null");
        this.context = requireNonNull(context, "context must not be null");
    }

    public static final > DetailedExpressionResult of(E rootExpression, R value,
            ResolvingContext context) {
        return new DetailedExpressionResult<>(rootExpression, value, context);
    }

    public R value() {
        return value;
    }

    public ResolvingContext context() {
        return context;
    }

    public E rootExpression() {
        return this.rootExpression;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((context == null) ? 0 : context.hashCode());
        result = prime * result + ((rootExpression == null) ? 0 : rootExpression.hashCode());
        result = prime * result + ((value == null) ? 0 : value.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        DetailedExpressionResult other = (DetailedExpressionResult) obj;
        if (context == null) {
            if (other.context != null) {
                return false;
            }
        } else if (!context.equals(other.context)) {
            return false;
        }
        if (rootExpression == null) {
            if (other.rootExpression != null) {
                return false;
            }
        } else if (!rootExpression.equals(other.rootExpression)) {
            return false;
        }
        if (value == null) {
            if (other.value != null) {
                return false;
            }
        } else if (!value.equals(other.value)) {
            return false;
        }
        return true;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy