001 /* 002 * $Id: Element.java 3031 2010-03-08 23:18:01Z kredel $ 003 */ 004 005 package edu.jas.structure; 006 007 import java.io.Serializable; 008 009 010 /** 011 * Element interface. 012 * Basic functionality of elements, e.g. compareTo, equals, clone. 013 * @param <C> element type. 014 * @author Heinz Kredel 015 */ 016 017 public interface Element<C extends Element<C>> extends Cloneable, 018 Comparable<C>, 019 Serializable { 020 021 /* 022 * Clone this Element. 023 * @return Creates and returns a copy of this Element. 024 */ 025 /*@Override*/ 026 /*public C clone();*/ 027 028 029 /** 030 * Test if this is equal to b. 031 * @param b 032 * @return true if this is equal to b, else false. 033 */ 034 public boolean equals(Object b); 035 036 037 /** 038 * Hashcode of this Element. 039 * @return the hashCode. 040 */ 041 public int hashCode(); 042 043 044 /** 045 * Compare this to b. 046 * I.e. this < b iff this.compareTo(b) < 0. 047 * <b>Note:</b> may not be meaningful if structure has no order. 048 * @param b 049 * @return 0 if this is equal to b, 050 -1 if this is less then b, else +1. 051 */ 052 public int compareTo(C b); 053 054 055 /** 056 * Get the corresponding element factory. 057 * @return factory for this Element. 058 */ 059 public ElemFactory<C> factory(); 060 061 062 /** Get a scripting compatible string representation. 063 * @return script compatible representation for this Element. 064 */ 065 public String toScript(); 066 067 068 /** Get a scripting compatible string representation of the factory. 069 * @return script compatible representation for this ElemFactory. 070 */ 071 public String toScriptFactory(); 072 073 }