001/*
002 * JPPF.
003 * Copyright (C) 2005-2018 JPPF Team.
004 * http://www.jppf.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.jppf.utils.collections;
020
021import java.io.Serializable;
022import java.util.Map;
023
024/**
025 * A generic dictionary of metadata.
026 * @author Laurent Cohen
027 */
028public interface Metadata extends Serializable
029{
030  /**
031   * Retrieve a parameter in the metadata.
032   * @param key the parameter's key.
033   * @return the parameter's value or null if no parameter with the specified key exists.
034   * @param <T> the type of the value to get.
035   */
036  <T> T getParameter(Object key);
037
038  /**
039   * Retrieve a parameter in the metadata.
040   * @param key the parameter's key.
041   * @param def a default value to return if no parameter with the specified key can be found.
042   * @return the parameter's value or null if no parameter with the specified key exists.
043   * @param <T> the type of the value to get.
044   */
045  <T> T getParameter(Object key, T def);
046
047  /**
048   * Set a parameter in the metadata.
049   * If a parameter with the same key already exists, its value is replaced with the new one.
050   * @param key the parameter's key.
051   * @param value the parameter's value.
052   * @return this metadata object, for method chaining.
053   */
054  Metadata setParameter(Object key, Object value);
055
056  /**
057   * Remove a parameter from the metadata.
058   * @param key the parameter's key.
059   * @return the removed parameter's value or null if no parameter with the specified key exists.
060   * @param <T> the type of the value to remove.
061   */
062  <T> T removeParameter(Object key);
063
064  /**
065   * Get a copy of the metadata map.
066   * @return a map of the metadata contained in this object.
067   */
068  Map<Object, Object> getAll();
069
070  /**
071   * Clear the underlying map.
072   * @return this metadata object, for method chaining.
073   */
074  Metadata clear();
075}