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

com.tangosol.io.pof.EvolvableHolder Maven / Gradle / Ivy

There is a newer version: 24.09
Show newest version
/*
 * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
 *
 * Licensed under the Universal Permissive License v 1.0 as shown at
 * http://oss.oracle.com/licenses/upl.
 */
package com.tangosol.io.pof;

import com.tangosol.io.Evolvable;

import com.tangosol.io.SimpleEvolvable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Storage for evolvable classes.
 *
 * @author as  2013.07.25
 * @since  12.2.1
 */
public class EvolvableHolder
    {
    /**
     * Return an {@link Evolvable} for the specified type id.
     *
     * @param idType  type identifier
     *
     * @return  an Evolvable instance
     */
    public Evolvable get(Integer idType)
        {
        return m_mapEvolvable.computeIfAbsent(idType, key -> new SimpleEvolvable(0));
        }

    /**
     * Return type identifiers for all the Evolvables within this holder.
     *
     * @return  type identifiers for all the Evolvables within this holder
     */
    public Set getTypeIds()
        {
        return m_mapEvolvable.keySet();
        }

    /**
     * Return true if this holder is empty.
     *
     * @return  true if this holder is empty, false otherwise
     */
    public boolean isEmpty()
        {
        return m_mapEvolvable.isEmpty();
        }

    // ---- data members ----------------------------------------------------

    /**
     * Map of Evolvable objects, keyed by type id.
     */
    protected Map m_mapEvolvable = new HashMap<>();
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy