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

net.openhft.collect.impl.hash.DHashSeparateKVByteShortMapFactoryImpl Maven / Gradle / Ivy

The newest version!
/* with
 DHash|QHash|LHash hash
 byte|char|short|int|long|float|double|obj key
 short|byte|char|int|long|float|double|obj value
 Separate|Parallel kv
*/
/*
 * Copyright 2014 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.openhft.collect.impl.hash;

import net.openhft.collect.*;
import net.openhft.collect.hash.*;
import net.openhft.collect.map.hash.*;
import javax.annotation.Nullable;

import static net.openhft.collect.impl.hash.LHashCapacities.configIsSuitableForMutableLHash;


public final class DHashSeparateKVByteShortMapFactoryImpl/*<>*/
        extends DHashSeparateKVByteShortMapFactoryGO/*<>*/ {

    /* define p1 */
    /* if obj key obj value //// elif obj key //
    // elif obj value //// endif */
    /* enddefine */

    /* define p2 */
    /* if obj key obj value //// elif obj key //// elif obj value //// endif */
    /* enddefine */

    /* define kAnd *//* if obj key //K, // endif *//* enddefine */
    /* define p1And *//* if obj key //K2 extends K, // endif *//* enddefine */
    /* define p2And *//* if obj key //K2, // endif *//* enddefine */

    /* define andV *//* if obj value //, V// endif *//* enddefine */
    /* define andP1 *//* if obj value //, V2 extends V// endif *//* enddefine */
    /* define andP2 *//* if obj value //, V2// endif *//* enddefine */

    /** For ServiceLoader */
    public DHashSeparateKVByteShortMapFactoryImpl() {
        this(HashConfig.getDefault(), 10
            /* if obj key */, false
            /* elif !(float|double key) */, Byte.MIN_VALUE, Byte.MAX_VALUE/* endif */);
    }

    /* define commonArgDef //
    HashConfig hashConf, int defaultExpectedSize// if obj key //, boolean isNullKeyAllowed
            // elif !(float|double key) //, byte lower, byte upper// endif //
    // enddefine */

    /* define commonArgApply //
    hashConf, defaultExpectedSize// if obj key //, isNullKeyAllowed
            // elif !(float|double key) //, lower, upper// endif //
    // enddefine */

    /* define commonArgGet //
    getHashConfig(), getDefaultExpectedSize()
        // if obj key //, isNullKeyAllowed()// elif !(float|double key) //
            , getLowerKeyDomainBound(), getUpperKeyDomainBound()// endif //
    // enddefine */

    DHashSeparateKVByteShortMapFactoryImpl(/* commonArgDef */) {
        super(/* commonArgApply */);
    }

    @Override
    HashByteShortMapFactory/*<>*/ thisWith(/* commonArgDef */) {
        return new DHashSeparateKVByteShortMapFactoryImpl/*<>*/(/* commonArgApply */);
    }

    /* with DHash|QHash|LHash hash */
    @Override
    HashByteShortMapFactory/*<>*/ dHashLikeThisWith(/* commonArgDef */) {
        return new DHashSeparateKVByteShortMapFactoryImpl/*<>*/(/* commonArgApply */);
    }
    /* endwith */

    /* if obj key */
    @Override
    public  HashObjShortMapFactory withKeyEquivalence(
            @Nullable Equivalence keyEquivalence) {
        if (keyEquivalence == null) {
            // noinspection unchecked
            return (HashObjShortMapFactory) this;
        }
        return new WithCustomKeyEquivalence(/* commonArgGet */, keyEquivalence);
    }
    /* endif */

    /* if !(obj value) */
    @Override
    public HashByteShortMapFactory/*<>*/ withDefaultValue(short defaultValue) {
        if (defaultValue == /* const value 0 */0)
            return this;
        return new WithCustomDefaultValue/*<>*/(/* commonArgGet */, defaultValue);
    }
    /* elif obj value */
    @Override
    public  HashByteObjMapFactory withValueEquivalence(
            @Nullable Equivalence valueEquivalence) {
        if (valueEquivalence == null) {
            // noinspection unchecked
            return (HashByteObjMapFactory) this;
        }
        return new WithCustomValueEquivalence(/* commonArgGet */, valueEquivalence);
    }
    /* endif */

    /* if obj key */
    static class WithCustomKeyEquivalence
            extends DHashSeparateKVObjShortMapFactoryGO {

        private final Equivalence keyEquivalence;

        WithCustomKeyEquivalence(/* commonArgDef */, Equivalence keyEquivalence) {
            super(/* commonArgApply */);
            this.keyEquivalence = keyEquivalence;
        }

        @Override
        public Equivalence getKeyEquivalence() {
            return keyEquivalence;
        }

        /* with Mutable|Updatable|Immutable mutability */
        @Override
         MutableDHashSeparateKVObjShortMapGO
        uninitializedMutableMap() {
            MutableDHashSeparateKVObjShortMap.WithCustomKeyEquivalence map =
                    new MutableDHashSeparateKVObjShortMap.WithCustomKeyEquivalence();
            map.keyEquivalence = keyEquivalence;
            return map;
        }
        /* endwith */

        @Override
        public  HashObjShortMapFactory withKeyEquivalence(
                @Nullable Equivalence keyEquivalence) {
            if (keyEquivalence == null)
                return new DHashSeparateKVObjShortMapFactoryImpl(/* commonArgGet */);
            if (keyEquivalence.equals(this.keyEquivalence)) {
                // noinspection unchecked
                return (HashObjShortMapFactory) this;
            }
            return new WithCustomKeyEquivalence(/* commonArgGet */, keyEquivalence);
        }

        /* if !(obj value) */
        @Override
        public HashObjShortMapFactory withDefaultValue(short defaultValue) {
            if (defaultValue == /* const value 0 */0)
                return this;
            return new WithCustomKeyEquivalenceAndDefaultValue(
                    /* commonArgGet */, keyEquivalence, defaultValue);
        }
        /* elif obj value */
        @Override
        public  HashObjObjMapFactory withValueEquivalence(
                @Nullable Equivalence valueEquivalence) {
            if (valueEquivalence == null) {
                // noinspection unchecked
                return (HashObjObjMapFactory) this;
            }
            return new WithCustomEquivalences(/* commonArgGet */,
                    keyEquivalence, valueEquivalence);
        }
        /* endif */

        @Override
        HashByteShortMapFactory/*<>*/ thisWith(/* commonArgDef */) {
            return new WithCustomKeyEquivalence(/* commonArgApply */, keyEquivalence);
        }

        /* with DHash|QHash|LHash hash */
        @Override
        HashByteShortMapFactory/*<>*/ dHashLikeThisWith(/* commonArgDef */) {
            return new DHashSeparateKVByteShortMapFactoryImpl.WithCustomKeyEquivalence(
                    /* commonArgApply */, keyEquivalence);
        }
        /* endwith */
    }
    /* endif */

    /* if !(obj value) */
    static final class WithCustomDefaultValue/*<>*/
            extends DHashSeparateKVByteShortMapFactoryGO/*<>*/ {
        private final short defaultValue;

        WithCustomDefaultValue(/* commonArgDef */, short defaultValue) {
            super(/* commonArgApply */);
            this.defaultValue = defaultValue;
        }

        @Override
        public short getDefaultValue() {
            return defaultValue;
        }

        /* with Mutable|Updatable|Immutable mutability */
        @Override
        /*p1*/ MutableDHashSeparateKVByteShortMapGO/*p2*/ uninitializedMutableMap() {
            MutableDHashSeparateKVByteShortMap.WithCustomDefaultValue/*p2*/ map =
                    new MutableDHashSeparateKVByteShortMap.WithCustomDefaultValue/*p2*/();
            map.defaultValue = defaultValue;
            return map;
        }
        /* endwith */

        /* if obj key */
        @Override
        public  HashObjShortMapFactory withKeyEquivalence(
                @Nullable Equivalence keyEquivalence) {
            if (keyEquivalence == null) {
                // noinspection unchecked
                return (HashObjShortMapFactory) this;
            }
            return new WithCustomKeyEquivalenceAndDefaultValue(/* commonArgGet */,
                    keyEquivalence, defaultValue);
        }
        /* endif */

        @Override
        public HashByteShortMapFactory/*<>*/ withDefaultValue(short defaultValue) {
            if (defaultValue == /* const value 0 */0)
                return new DHashSeparateKVByteShortMapFactoryImpl/*<>*/(/* commonArgGet */);
            if (defaultValue == this.defaultValue)
                return this;
            return new WithCustomDefaultValue/*<>*/(/* commonArgGet */, defaultValue);
        }

        @Override
        HashByteShortMapFactory/*<>*/ thisWith(/* commonArgDef */) {
            return new WithCustomDefaultValue/*<>*/(/* commonArgApply */, defaultValue);
        }

        /* with DHash|QHash|LHash hash */
        @Override
        HashByteShortMapFactory/*<>*/ dHashLikeThisWith(/* commonArgDef */) {
            return new DHashSeparateKVByteShortMapFactoryImpl.WithCustomDefaultValue/*<>*/(
                    /* commonArgApply */, defaultValue);
        }
        /* endwith */
    }
    /* elif obj value */
    static final class WithCustomValueEquivalence
            extends DHashSeparateKVByteObjMapFactoryGO {

        private final Equivalence valueEquivalence;
        WithCustomValueEquivalence(/* commonArgDef */,
                Equivalence valueEquivalence) {
            super(/* commonArgApply */);
            this.valueEquivalence = valueEquivalence;
        }

        @Override
        public Equivalence getValueEquivalence() {
            return valueEquivalence;
        }

        /* with Mutable|Updatable|Immutable mutability */
        @Override
         MutableDHashSeparateKVByteObjMapGO
        uninitializedMutableMap() {
            MutableDHashSeparateKVByteObjMap.WithCustomValueEquivalence map =
                    new MutableDHashSeparateKVByteObjMap.WithCustomValueEquivalence();
            map.valueEquivalence = valueEquivalence;
            return map;
        }
        /* endwith */

        /* if obj key */
        @Override
        public  HashObjObjMapFactory withKeyEquivalence(
                @Nullable Equivalence keyEquivalence) {
            if (keyEquivalence == null) {
                // noinspection unchecked
                return (HashObjObjMapFactory) this;
            }
            return new WithCustomEquivalences(/* commonArgGet */,
                    keyEquivalence, valueEquivalence);
        }
        /* endif */

        @Override
        public  HashByteObjMapFactory withValueEquivalence(
                @Nullable Equivalence valueEquivalence) {
            if (valueEquivalence == null)
                return new DHashSeparateKVByteObjMapFactoryImpl(/* commonArgGet */);
            if (valueEquivalence.equals(this.valueEquivalence))
                // noinspection unchecked
                return (HashByteObjMapFactory) this;
            return new WithCustomValueEquivalence(/* commonArgGet */, valueEquivalence);
        }

        @Override
        HashByteShortMapFactory/*<>*/ thisWith(/* commonArgDef */) {
            return new WithCustomValueEquivalence(/* commonArgApply */,
                    valueEquivalence);
        }

        /* with DHash|QHash|LHash hash */
        @Override
        HashByteShortMapFactory/*<>*/ dHashLikeThisWith(/* commonArgDef */) {
            return new DHashSeparateKVByteShortMapFactoryImpl.WithCustomValueEquivalence(
                    /* commonArgApply */, valueEquivalence);
        }
        /* endwith */
    }
    /* endif */

    /* if obj key && !(obj value) */
    static final class WithCustomKeyEquivalenceAndDefaultValue
            extends DHashSeparateKVObjShortMapFactoryGO {
        private final Equivalence keyEquivalence;
        private final short defaultValue;

        WithCustomKeyEquivalenceAndDefaultValue(/* commonArgDef */,
                Equivalence keyEquivalence, short defaultValue) {
            super(/* commonArgApply */);
            this.keyEquivalence = keyEquivalence;
            this.defaultValue = defaultValue;
        }

        @Override
        public Equivalence getKeyEquivalence() {
            return keyEquivalence;
        }

        @Override
        public short getDefaultValue() {
            return defaultValue;
        }

        /* with Mutable|Updatable|Immutable mutability */
        @Override
         MutableDHashSeparateKVObjShortMapGO uninitializedMutableMap() {
            MutableDHashSeparateKVObjShortMap.WithCustomKeyEquivalenceAndDefaultValue map =
                    new MutableDHashSeparateKVObjShortMap
                            .WithCustomKeyEquivalenceAndDefaultValue();
            map.keyEquivalence = keyEquivalence;
            map.defaultValue = defaultValue;
            return map;
        }
        /* endwith */

        @Override
        public  HashObjShortMapFactory withKeyEquivalence(
                @Nullable Equivalence keyEquivalence) {
            if (keyEquivalence == null)
                return new WithCustomDefaultValue(/* commonArgGet */, defaultValue);
            if (keyEquivalence.equals(this.keyEquivalence)) {
                // noinspection unchecked
                return (HashObjShortMapFactory) this;
            }
            return new WithCustomKeyEquivalenceAndDefaultValue(
                    /* commonArgGet */, keyEquivalence, defaultValue);
        }

        @Override
        public HashObjShortMapFactory withDefaultValue(short defaultValue) {
            if (defaultValue == /* const value 0 */0)
                return new WithCustomKeyEquivalence(/* commonArgGet */, keyEquivalence);
            if (defaultValue == this.defaultValue)
                return this;
            return new WithCustomKeyEquivalenceAndDefaultValue(
                    /* commonArgGet */, keyEquivalence, defaultValue);
        }

        @Override
        HashByteShortMapFactory/*<>*/ thisWith(/* commonArgDef */) {
            return new WithCustomKeyEquivalenceAndDefaultValue(/* commonArgApply */,
                    keyEquivalence, defaultValue);
        }

        /* with DHash|QHash|LHash hash */
        @Override
        HashByteShortMapFactory/*<>*/ dHashLikeThisWith(/* commonArgDef */) {
            return new DHashSeparateKVByteShortMapFactoryImpl
                        .WithCustomKeyEquivalenceAndDefaultValue(/* commonArgApply */,
                    keyEquivalence, defaultValue);
        }
        /* endwith */
    }
    /* elif obj key obj value */
    static final class WithCustomEquivalences
            extends DHashSeparateKVObjObjMapFactoryGO {
        private final Equivalence keyEquivalence;
        private final Equivalence valueEquivalence;

        WithCustomEquivalences(/* commonArgDef */,
                Equivalence keyEquivalence, Equivalence valueEquivalence) {
            super(/* commonArgApply */);
            this.keyEquivalence = keyEquivalence;
            this.valueEquivalence = valueEquivalence;
        }

        @Override
        public Equivalence getKeyEquivalence() {
            return keyEquivalence;
        }

        @Override
        public Equivalence getValueEquivalence() {
            return valueEquivalence;
        }

        /* with Mutable|Updatable|Immutable mutability */
        @Override
         MutableDHashSeparateKVObjObjMapGO
        uninitializedMutableMap() {
            MutableDHashSeparateKVObjObjMap.WithCustomEquivalences map =
                    new MutableDHashSeparateKVObjObjMap.WithCustomEquivalences();
            map.keyEquivalence = keyEquivalence;
            map.valueEquivalence = valueEquivalence;
            return map;
        }
        /* endwith */

        @Override
        public  HashObjObjMapFactory withKeyEquivalence(
                @Nullable Equivalence keyEquivalence) {
            if (keyEquivalence == null)
                return new WithCustomValueEquivalence(/* commonArgGet */,
                        valueEquivalence);
            if (keyEquivalence.equals(this.keyEquivalence)) {
                // noinspection unchecked
                return (HashObjObjMapFactory) this;
            }
            return new WithCustomEquivalences(/* commonArgGet */,
                    keyEquivalence, valueEquivalence);
        }

        @Override
        public  HashObjObjMapFactory withValueEquivalence(
                @Nullable Equivalence valueEquivalence) {
            if (valueEquivalence == null)
                return new WithCustomKeyEquivalence(/* commonArgGet */, keyEquivalence);
            if (valueEquivalence.equals(this.valueEquivalence)) {
                // noinspection unchecked
                return (HashObjObjMapFactory) this;
            }
            return new WithCustomEquivalences(/* commonArgGet */,
                    keyEquivalence, valueEquivalence);
        }

        @Override
        HashByteShortMapFactory/*<>*/ thisWith(/* commonArgDef */) {
            return new WithCustomEquivalences(/* commonArgApply */,
                    keyEquivalence, valueEquivalence);
        }

        /* with DHash|QHash|LHash hash */
        @Override
        HashByteShortMapFactory/*<>*/ dHashLikeThisWith(/* commonArgDef */) {
            return new DHashSeparateKVByteShortMapFactoryImpl.WithCustomEquivalences(
                    /* commonArgApply */, keyEquivalence, valueEquivalence);
        }
        /* endwith */
    }
    /* endif */
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy