2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.xpath.api;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.Beta;
13 import com.google.common.collect.ImmutableSet;
14 import java.util.Collection;
18 * YANG XPath binary operator.
20 * @author Robert Varga
23 public enum YangNaryOperator {
25 * Logical 'and' operator on operands.
27 * @see <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#NT-AndExpr">AndExpr</a>
31 * Logical 'or' operator on operands.
33 * @see <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#NT-OrExpr">OrExpr</a>
37 * Set union operator on operands.
39 * @see <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#NT-UnionExpr">UnionExpr</a>
43 private final class Expr extends YangNaryExpr {
44 private static final long serialVersionUID = 1L;
46 Expr(final Set<YangExpr> exprs) {
51 public YangNaryOperator getOperator() {
52 return YangNaryOperator.this;
56 private final String str;
58 YangNaryOperator(final String str) {
59 this.str = requireNonNull(str);
63 public String toString() {
67 public YangExpr exprWith(final Collection<YangExpr> exprs) {
68 final Set<YangExpr> set = ImmutableSet.copyOf(exprs);
69 return set.size() == 1 ? set.iterator().next() : new Expr(set);