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

org.tensorics.expression.IterableResolvingExpression Maven / Gradle / Ivy

Go to download

Tensoric expression is able to solve an expression tree. Much like a tree coming from a traditional equation, where both operations and operands can be objects and can implement custom behavior

The newest version!
/**
 * Copyright (c) 2016 European Organisation for Nuclear Research (CERN), All Rights Reserved.
 */

package org.tensorics.expression;

import java.util.List;

import org.tensorics.core.tree.domain.AbstractDeferredExpression;
import org.tensorics.core.tree.domain.Expression;
import org.tensorics.core.tree.domain.Node;
import org.tensorics.expression.resolvers.IterableResolvingExpressionResolver;

import com.google.common.collect.ImmutableList;

/**
 * Expression that given an {@link Iterable} of {@link Expression} of T, resolves to an {@link Iterable} of T. In other
 * words, it resolves the inner {@link Expression} of the {@link Iterable}.
 * 
 * @see IterableResolvingExpressionResolver
 * @author acalia, caguiler, kfuchsberger
 * @param  type of the elements of the iterable
 */
public class IterableResolvingExpression extends AbstractDeferredExpression> {

    private final List> expressions;

    public IterableResolvingExpression(Iterable> iterable) {
        this.expressions = ImmutableList.copyOf(iterable);
    }

    @Override
    public List getChildren() {
        return expressions;
    }

    public List> expressions() {
        return expressions;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((expressions == null) ? 0 : expressions.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;
        }
        IterableResolvingExpression other = (IterableResolvingExpression) obj;
        if (expressions == null) {
            if (other.expressions != null) {
                return false;
            }
        } else if (!expressions.equals(other.expressions)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "IterableResolvingExpression [expressions=" + expressions + "]";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy