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

org.jppf.utils.collections.MetadataImpl Maven / Gradle / Ivy

There is a newer version: 6.3-alpha
Show newest version
/*
 * JPPF.
 * Copyright (C) 2005-2015 JPPF Team.
 * http://www.jppf.org
 *
 * 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 org.jppf.utils.collections;

import java.util.*;

/**
 * An implementation of the {@link Metadata} interface backed by a {@link Hashtable}.
 * @author Laurent Cohen
 */
public class MetadataImpl implements Metadata
{
  /**
   * The map holding the mapping of keys to values.
   */
  protected final Map parameters = new Hashtable<>();

  @Override
  public  T getParameter(final Object key)
  {
    return (T) parameters.get(key);
  }

  @Override
  public  T getParameter(final Object key, final T defaultValue)
  {
    T res = (T) parameters.get(key);
    return res == null ? defaultValue : res;
  }

  @Override
  public void setParameter(final Object key, final Object value)
  {
    parameters.put(key, value);
  }

  @Override
  public  T removeParameter(final Object key)
  {
    return (T) parameters.remove(key);
  }

  @Override
  public Map getAll()
  {
    return parameters;
  }

  @Override
  public String toString()
  {
    return new StringBuilder(getClass().getSimpleName()).append(parameters).toString();
  }

  @Override
  public void clear()
  {
    parameters.clear();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy