001/* A mapping from an arbitrary domain of values into some range. 002 003 Copyright (c) 2003-2013 The University of Maryland. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF MARYLAND BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF MARYLAND HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF MARYLAND SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 MARYLAND HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 025 */ 026package ptolemy.graph.mapping; 027 028/////////////////////////////////////////////////////////////////// 029//// Mapping 030 031/** A mapping from some domain of values into some range. 032 Mappings are different from Maps (see {@link java.util.List}) in that the set 033 of keys (domain values) is not necessarily stored with or even known to a 034 Mapping. Enumeration of or iteration through the domain values is thus not in 035 general possible. 036 <p> 037 This is a base interface for specific mappings. For efficiency, the derived 038 mappings should define their own methods to actually perform the associated 039 mapping function. These methods can thus be specialized, for example, to return 040 the desired return type (rather than an Object). Also, derived Mappings 041 may choose, again for efficiency reasons, to forego any error-checking 042 in the methods that implement their mapping functions (i.e, they may 043 assume that the arguments are in the corresponding domains). In such cases, 044 the {@link #inDomain(Object)} method can be used when it is desired 045 to make sure that that a candidate argument is in the domain. 046 047 @since Ptolemy II 4.0 048 @Pt.ProposedRating Red (ssb) 049 @Pt.AcceptedRating Red (ssb) 050 @author Shuvra S. Bhattacharyya, Shahrooz Shahparnia 051 @version $Id$ 052 */ 053public interface Mapping { 054 /////////////////////////////////////////////////////////////////// 055 //// public methods //// 056 057 /** Returns true if a given object is in the domain of the mapping. 058 * 059 * @param object The given object. 060 * @return True if a given object is in the domain of the mapping 061 */ 062 public boolean inDomain(Object object); 063 064 /** Return the object associated with the given object in the mapping. 065 * 066 * @param object The given object. 067 * @return Return the object associated with the given object in the 068 * mapping. 069 */ 070 public Object toObject(Object object); 071}