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 org.eclipse.jdt.annotation.Nullable;
16 public final class YangNegateExpr implements YangExpr {
17 private static final long serialVersionUID = 1L;
19 private final YangExpr subExpr;
21 private YangNegateExpr(final YangExpr subExpr) {
22 this.subExpr = requireNonNull(subExpr);
25 public static YangNegateExpr of(final YangExpr subExpr) {
26 return new YangNegateExpr(subExpr);
29 public YangExpr getSubExpr() {
34 public int hashCode() {
35 return subExpr.hashCode();
39 public boolean equals(final @Nullable Object obj) {
40 return this == obj || obj instanceof YangNegateExpr other && subExpr.equals(other.subExpr);
44 public String toString() {
45 return "-(" + subExpr + ")";