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

org.neo4j.values.storable.NoValue Maven / Gradle / Ivy

There is a newer version: 5.25.1
Show newest version
/*
 * Copyright (c) "Neo4j"
 * Neo4j Sweden AB [http://neo4j.com]
 *
 * This file is part of Neo4j.
 *
 * Neo4j is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */
package org.neo4j.values.storable;

import org.neo4j.hashing.HashFunction;
import org.neo4j.values.AnyValue;
import org.neo4j.values.Equality;
import org.neo4j.values.ValueMapper;

/**
 * Not a value.
 *
 * The NULL object of the Value world. Is implemented as a singleton, to allow direct reference equality checks (==),
 * and avoid unnecessary object creation.
 */
public final class NoValue extends Value
{
    public static final NoValue NO_VALUE = new NoValue();

    private NoValue()
    {
    }

    @Override
    public boolean equalTo( Object other )
    {
        return this == other;
    }

    @Override
    public Equality ternaryEquals( AnyValue other )
    {
        return Equality.UNDEFINED;
    }

    @Override
    boolean ternaryUndefined()
    {
        return true;
    }

    @Override
    public  T map( ValueMapper mapper )
    {
        return mapper.mapNoValue();
    }

    @Override
    public long updateHash( HashFunction hashFunction, long hash )
    {
        return hashFunction.update( hash, hashCode() );
    }

    @Override
    protected int computeHash()
    {
        return System.identityHashCode( this );
    }

    @Override
    public boolean equals( Value other )
    {
        return this == other;
    }

    @Override
    public  void writeTo( ValueWriter writer ) throws E
    {
        writer.writeNull();
    }

    @Override
    public Object asObjectCopy()
    {
        return null;
    }

    @Override
    public String toString()
    {
        return prettyPrint();
    }

    @Override
    public String prettyPrint()
    {
        return getTypeName();
    }

    @Override
    public String getTypeName()
    {
        return "NO_VALUE";
    }

    @Override
    public ValueRepresentation valueRepresentation()
    {
        return ValueRepresentation.NO_VALUE;
    }

    @Override
    public NumberType numberType()
    {
        return NumberType.NO_NUMBER;
    }

    @Override
    protected int unsafeCompareTo( Value other )
    {
        return 0;
    }

    @Override
    public long estimatedHeapUsage()
    {
        return 0L;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy