org.tensorics.expression.IterableResolvingExpression Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tensorics-expression Show documentation
Show all versions of tensorics-expression Show documentation
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 extends Node> getChildren() {
return expressions;
}
public List extends Expression> 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 + "]";
}
}