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

org.opendaylight.yangtools.yang.xpath.api.DoubleNumberExpr Maven / Gradle / Ivy

There is a newer version: 14.0.5
Show newest version
/*
 * Copyright (c) 2019 Pantheon Technologies, s.r.o.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.yangtools.yang.xpath.api;

import java.io.Serial;
import org.eclipse.jdt.annotation.Nullable;

final class DoubleNumberExpr extends YangNumberExpr {
    @Serial
    private static final long serialVersionUID = 1L;

    private final double value;

    private DoubleNumberExpr(final double value) {
        this.value = value;
    }

    static DoubleNumberExpr of(final double value) {
        return new DoubleNumberExpr(value);
    }

    double getValue() {
        return value;
    }

    @Override
    public Double getNumber() {
        return value;
    }

    @Override
    public DoubleXPathMathSupport getSupport() {
        return DoubleXPathMathSupport.INSTANCE;
    }

    @Override
    public int hashCode() {
        return Double.hashCode(value);
    }

    @Override
    public boolean equals(final @Nullable Object obj) {
        return this == obj || obj instanceof DoubleNumberExpr other && bitEqual(other.value);
    }

    private boolean bitEqual(final double other) {
        return Double.doubleToLongBits(value) == Double.doubleToLongBits(other);
    }

    @Override
    public String toString() {
        return String.valueOf(value);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy