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 edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
15 import java.util.Collection;
19 * YANG XPath binary operator.
21 * @author Robert Varga
24 public enum YangNaryOperator {
26 * Logical 'and' operator on operands.
28 * @see <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#NT-AndExpr">AndExpr</a>
32 * Logical 'or' operator on operands.
34 * @see <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#NT-OrExpr">OrExpr</a>
38 * Set union operator on operands.
40 * @see <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#NT-UnionExpr">UnionExpr</a>
44 @SuppressFBWarnings(value = "SE_INNER_CLASS", justification = "Outer class is a retained enumeration")
45 private final class Expr extends YangNaryExpr {
46 private static final long serialVersionUID = 1L;
48 Expr(final Set<YangExpr> exprs) {
53 public YangNaryOperator getOperator() {
54 return YangNaryOperator.this;
58 private final String str;
60 YangNaryOperator(final String str) {
61 this.str = requireNonNull(str);
65 public String toString() {
69 public YangExpr exprWith(final Collection<YangExpr> exprs) {
70 final Set<YangExpr> set = ImmutableSet.copyOf(exprs);
71 return set.size() == 1 ? set.iterator().next() : new Expr(set);