Home | History | Annotate | Download | only in collect
      1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      2 <!--NewPage-->
      3 <HTML>
      4 <HEAD>
      5 <!-- Generated by javadoc (build 1.6.0-google-internal) on Mon Jan 04 20:47:58 PST 2010 -->
      6 <TITLE>
      7 ForwardingObject (Guava Libraries 2010.01.04)
      8 </TITLE>
      9 
     10 <META NAME="date" CONTENT="2010-01-04">
     11 
     12 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
     13 
     14 <SCRIPT type="text/javascript">
     15 function windowTitle()
     16 {
     17     if (location.href.indexOf('is-external=true') == -1) {
     18         parent.document.title="ForwardingObject (Guava Libraries 2010.01.04)";
     19     }
     20 }
     21 </SCRIPT>
     22 <NOSCRIPT>
     23 </NOSCRIPT>
     24 
     25 </HEAD>
     26 
     27 <BODY BGCOLOR="white" onload="windowTitle();">
     28 <HR>
     29 
     30 
     31 <!-- ========= START OF TOP NAVBAR ======= -->
     32 <A NAME="navbar_top"><!-- --></A>
     33 <A HREF="#skip-navbar_top" title="Skip navigation links"></A>
     34 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
     35 <TR>
     36 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
     37 <A NAME="navbar_top_firstrow"><!-- --></A>
     38 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
     39   <TR ALIGN="center" VALIGN="top">
     40   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
     41   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
     42   <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
     43   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/ForwardingObject.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
     44   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
     45   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
     46   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
     47   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
     48   </TR>
     49 </TABLE>
     50 </TD>
     51 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
     52 </EM>
     53 </TD>
     54 </TR>
     55 
     56 <TR>
     57 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
     58 &nbsp;<A HREF="../../../../com/google/common/collect/ForwardingMultiset.html" title="class in com.google.common.collect"><B>PREV CLASS</B></A>&nbsp;
     59 &nbsp;<A HREF="../../../../com/google/common/collect/ForwardingQueue.html" title="class in com.google.common.collect"><B>NEXT CLASS</B></A></FONT></TD>
     60 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
     61   <A HREF="../../../../index.html?com/google/common/collect/ForwardingObject.html" target="_top"><B>FRAMES</B></A>  &nbsp;
     62 &nbsp;<A HREF="ForwardingObject.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
     63 &nbsp;<SCRIPT type="text/javascript">
     64   <!--
     65   if(window==top) {
     66     document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
     67   }
     68   //-->
     69 </SCRIPT>
     70 <NOSCRIPT>
     71   <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
     72 </NOSCRIPT>
     73 
     74 
     75 </FONT></TD>
     76 </TR>
     77 <TR>
     78 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
     79   SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
     80 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
     81 DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
     82 </TR>
     83 </TABLE>
     84 <A NAME="skip-navbar_top"></A>
     85 <!-- ========= END OF TOP NAVBAR ========= -->
     86 
     87 <HR>
     88 <!-- ======== START OF CLASS DATA ======== -->
     89 <H2>
     90 <FONT SIZE="-1">
     91 com.google.common.collect</FONT>
     92 <BR>
     93 Class ForwardingObject</H2>
     94 <PRE>
     95 <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A>
     96   <IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>com.google.common.collect.ForwardingObject</B>
     97 </PRE>
     98 <DL>
     99 <DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../../../com/google/common/collect/ForwardingCollection.html" title="class in com.google.common.collect">ForwardingCollection</A>, <A HREF="../../../../com/google/common/util/concurrent/ForwardingFuture.html" title="class in com.google.common.util.concurrent">ForwardingFuture</A>, <A HREF="../../../../com/google/common/collect/ForwardingIterator.html" title="class in com.google.common.collect">ForwardingIterator</A>, <A HREF="../../../../com/google/common/collect/ForwardingMap.html" title="class in com.google.common.collect">ForwardingMap</A>, <A HREF="../../../../com/google/common/collect/ForwardingMapEntry.html" title="class in com.google.common.collect">ForwardingMapEntry</A>, <A HREF="../../../../com/google/common/collect/ForwardingMultimap.html" title="class in com.google.common.collect">ForwardingMultimap</A>, <A HREF="../../../../com/google/common/util/concurrent/ForwardingService.html" title="class in com.google.common.util.concurrent">ForwardingService</A></DD>
    100 </DL>
    101 <HR>
    102 <DL>
    103 <DT><PRE>public abstract class <B>ForwardingObject</B><DT>extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></DL>
    104 </PRE>
    105 
    106 <P>
    107 An abstract base class for implementing the <a
    108  href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
    109  The <A HREF="../../../../com/google/common/collect/ForwardingObject.html#delegate()"><CODE>delegate()</CODE></A> method must be overridden to return the instance
    110  being decorated.
    111 
    112  This class does <i>not</i> forward the <code>hashCode</code> and <code>equals</code>
    113  methods through to the backing object, but relies on <code>Object</code>'s
    114  implementation. This is necessary to preserve the symmetry of <code>equals</code>.
    115  Custom definitions of equality are usually based on an interface, such as
    116  <code>Set</code> or <code>List</code>, so that the implementation of <code>equals</code> can
    117  cast the object being tested for equality to the custom interface. <code>ForwardingObject</code> implements no such custom interfaces directly; they
    118  are implemented only in subclasses. Therefore, forwarding <code>equals</code>
    119  would break symmetry, as the forwarding object might consider itself equal to
    120  the object being tested, but the reverse could not be true. This behavior is
    121  consistent with the JDK's collection wrappers, such as
    122  <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Collections.html?is-external=true#unmodifiableCollection(java.util.Collection)" title="class or interface in java.util"><CODE>Collections.unmodifiableCollection(java.util.Collection<? extends T>)</CODE></A>. Use an
    123  interface-specific subclass of <code>ForwardingObject</code>, such as <A HREF="../../../../com/google/common/collect/ForwardingList.html" title="class in com.google.common.collect"><CODE>ForwardingList</CODE></A>, to preserve equality behavior, or override <code>equals</code>
    124  directly.
    125 
    126  <p>The <code>toString</code> method is forwarded to the delegate. Although this
    127  class does not implement <A HREF="http://java.sun.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io"><CODE>Serializable</CODE></A>, a serializable subclass may be
    128  created since this class has a parameter-less constructor.
    129 <P>
    130 
    131 <P>
    132 <DL>
    133 <DT><B>Since:</B></DT>
    134   <DD>2010.01.04 <b>stable</b> (imported from Google Collections Library)</DD>
    135 <DT><B>Author:</B></DT>
    136   <DD>Mike Bostock</DD>
    137 </DL>
    138 <HR>
    139 
    140 <P>
    141 
    142 <!-- ======== CONSTRUCTOR SUMMARY ======== -->
    143 
    144 <A NAME="constructor_summary"><!-- --></A>
    145 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
    146 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
    147 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
    148 <B>Constructor Summary</B></FONT></TH>
    149 </TR>
    150 <TR BGCOLOR="white" CLASS="TableRowColor">
    151 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
    152 <CODE>protected </CODE></FONT></TD>
    153 <TD><CODE><B><A HREF="../../../../com/google/common/collect/ForwardingObject.html#ForwardingObject()">ForwardingObject</A></B>()</CODE>
    154 
    155 <BR>
    156 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sole constructor.</TD>
    157 </TR>
    158 </TABLE>
    159 &nbsp;
    160 <!-- ========== METHOD SUMMARY =========== -->
    161 
    162 <A NAME="method_summary"><!-- --></A>
    163 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
    164 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
    165 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
    166 <B>Method Summary</B></FONT></TH>
    167 </TR>
    168 <TR BGCOLOR="white" CLASS="TableRowColor">
    169 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
    170 <CODE>protected abstract &nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></CODE></FONT></TD>
    171 <TD><CODE><B><A HREF="../../../../com/google/common/collect/ForwardingObject.html#delegate()">delegate</A></B>()</CODE>
    172 
    173 <BR>
    174 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the backing delegate instance that methods are forwarded to.</TD>
    175 </TR>
    176 <TR BGCOLOR="white" CLASS="TableRowColor">
    177 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
    178 <CODE>&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD>
    179 <TD><CODE><B><A HREF="../../../../com/google/common/collect/ForwardingObject.html#toString()">toString</A></B>()</CODE>
    180 
    181 <BR>
    182 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the string representation generated by the delegate's
    183  <code>toString</code> method.</TD>
    184 </TR>
    185 </TABLE>
    186 &nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
    187 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
    188 <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
    189 <TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH>
    190 </TR>
    191 <TR BGCOLOR="white" CLASS="TableRowColor">
    192 <TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
    193 </TR>
    194 </TABLE>
    195 &nbsp;
    196 <P>
    197 
    198 <!-- ========= CONSTRUCTOR DETAIL ======== -->
    199 
    200 <A NAME="constructor_detail"><!-- --></A>
    201 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
    202 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
    203 <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
    204 <B>Constructor Detail</B></FONT></TH>
    205 </TR>
    206 </TABLE>
    207 
    208 <A NAME="ForwardingObject()"><!-- --></A><H3>
    209 ForwardingObject</H3>
    210 <PRE>
    211 protected <B>ForwardingObject</B>()</PRE>
    212 <DL>
    213 <DD>Sole constructor.
    214 <P>
    215 </DL>
    216 
    217 <!-- ============ METHOD DETAIL ========== -->
    218 
    219 <A NAME="method_detail"><!-- --></A>
    220 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
    221 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
    222 <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
    223 <B>Method Detail</B></FONT></TH>
    224 </TR>
    225 </TABLE>
    226 
    227 <A NAME="delegate()"><!-- --></A><H3>
    228 delegate</H3>
    229 <PRE>
    230 protected abstract <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A> <B>delegate</B>()</PRE>
    231 <DL>
    232 <DD>Returns the backing delegate instance that methods are forwarded to.
    233  Abstract subclasses generally override this method with an abstract method
    234  that has a more specific return type, such as <A HREF="../../../../com/google/common/collect/ForwardingSet.html#delegate()"><CODE>ForwardingSet.delegate()</CODE></A>. Concrete subclasses override this method to supply
    235  the instance being decorated.
    236 <P>
    237 <DD><DL>
    238 </DL>
    239 </DD>
    240 </DL>
    241 <HR>
    242 
    243 <A NAME="toString()"><!-- --></A><H3>
    244 toString</H3>
    245 <PRE>
    246 public <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <B>toString</B>()</PRE>
    247 <DL>
    248 <DD>Returns the string representation generated by the delegate's
    249  <code>toString</code> method.
    250 <P>
    251 <DD><DL>
    252 <DT><B>Overrides:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A></CODE> in class <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></CODE></DL>
    253 </DD>
    254 <DD><DL>
    255 </DL>
    256 </DD>
    257 </DL>
    258 <!-- ========= END OF CLASS DATA ========= -->
    259 <HR>
    260 
    261 
    262 <!-- ======= START OF BOTTOM NAVBAR ====== -->
    263 <A NAME="navbar_bottom"><!-- --></A>
    264 <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
    265 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
    266 <TR>
    267 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
    268 <A NAME="navbar_bottom_firstrow"><!-- --></A>
    269 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
    270   <TR ALIGN="center" VALIGN="top">
    271   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
    272   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
    273   <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
    274   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/ForwardingObject.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
    275   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
    276   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
    277   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
    278   <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
    279   </TR>
    280 </TABLE>
    281 </TD>
    282 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
    283 </EM>
    284 </TD>
    285 </TR>
    286 
    287 <TR>
    288 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
    289 &nbsp;<A HREF="../../../../com/google/common/collect/ForwardingMultiset.html" title="class in com.google.common.collect"><B>PREV CLASS</B></A>&nbsp;
    290 &nbsp;<A HREF="../../../../com/google/common/collect/ForwardingQueue.html" title="class in com.google.common.collect"><B>NEXT CLASS</B></A></FONT></TD>
    291 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
    292   <A HREF="../../../../index.html?com/google/common/collect/ForwardingObject.html" target="_top"><B>FRAMES</B></A>  &nbsp;
    293 &nbsp;<A HREF="ForwardingObject.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
    294 &nbsp;<SCRIPT type="text/javascript">
    295   <!--
    296   if(window==top) {
    297     document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
    298   }
    299   //-->
    300 </SCRIPT>
    301 <NOSCRIPT>
    302   <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
    303 </NOSCRIPT>
    304 
    305 
    306 </FONT></TD>
    307 </TR>
    308 <TR>
    309 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
    310   SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
    311 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
    312 DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
    313 </TR>
    314 </TABLE>
    315 <A NAME="skip-navbar_bottom"></A>
    316 <!-- ======== END OF BOTTOM NAVBAR ======= -->
    317 
    318 <HR>
    319 
    320 </BODY>
    321 </HTML>
    322