NamedObject.java :  » Game » jin-2.14.1 » free » util » Java Open Source

Java Open Source » Game » jin 2.14.1 
jin 2.14.1 » free » util » NamedObject.java
package free.util;



/**
 * Allows one to attach a name to an object. The name is also returned by the
 * <code>toString</code> method, making this class useful for objects put into
 * Swing container classes (<code>JTables</code> and such).
 */

public class NamedObject{
  
  
  
  /**
   * The object.
   */
  
  private final Object target;
  
  
  
  /**
   * The name.
   */
  
  private final String name;
  
  
  
  /**
   * Creates a new <code>NamedObject</code> with the specified target and name.
   */

  public NamedObject(Object target, String name){
    this.target = target;
    this.name = name;    
  }
  
  
  
  /**
   * Returns the target.
   */
  
  public Object getTarget(){
    return target;
  }
  
  
  
  /**
   * Returns the name.
   */
  
  public String getName(){
    return name;
  }

  
  
  /**
   * Returns the name.
   */
  
  public String toString(){
    return getName();
  }
  
  
  
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.