• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:56 PST 2010 -->
6<TITLE>
7Objects (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">
15function windowTitle()
16{
17    if (location.href.indexOf('is-external=true') == -1) {
18        parent.document.title="Objects (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/Objects.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/base/Joiner.MapJoiner.html" title="class in com.google.common.base"><B>PREV CLASS</B></A>&nbsp;
59&nbsp;<A HREF="../../../../com/google/common/base/Objects.ToStringHelper.html" title="class in com.google.common.base"><B>NEXT CLASS</B></A></FONT></TD>
60<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
61  <A HREF="../../../../index.html?com/google/common/base/Objects.html" target="_top"><B>FRAMES</B></A>  &nbsp;
62&nbsp;<A HREF="Objects.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;<A HREF="#nested_class_summary">NESTED</A>&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
80<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
81DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&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">
91com.google.common.base</FONT>
92<BR>
93Class Objects</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.base.Objects</B>
97</PRE>
98<HR>
99<DL>
100<DT><PRE>public final class <B>Objects</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>
101</PRE>
102
103<P>
104Helper functions that can operate on any <code>Object</code>.
105<P>
106
107<P>
108<DL>
109<DT><B>Since:</B></DT>
110  <DD>2010.01.04 <b>stable</b> (imported from Google Collections Library)</DD>
111<DT><B>Author:</B></DT>
112  <DD>Laurence Gonsalves</DD>
113</DL>
114<HR>
115
116<P>
117<!-- ======== NESTED CLASS SUMMARY ======== -->
118
119<A NAME="nested_class_summary"><!-- --></A>
120<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
121<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
122<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
123<B>Nested Class Summary</B></FONT></TH>
124</TR>
125<TR BGCOLOR="white" CLASS="TableRowColor">
126<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
127<CODE>static&nbsp;class</CODE></FONT></TD>
128<TD><CODE><B><A HREF="../../../../com/google/common/base/Objects.ToStringHelper.html" title="class in com.google.common.base">Objects.ToStringHelper</A></B></CODE>
129
130<BR>
131&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Support class for <A HREF="../../../../com/google/common/base/Objects.html#toStringHelper(java.lang.Object)"><CODE>toStringHelper(java.lang.Object)</CODE></A>.</TD>
132</TR>
133</TABLE>
134&nbsp;
135<!-- ========== METHOD SUMMARY =========== -->
136
137<A NAME="method_summary"><!-- --></A>
138<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
139<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
140<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
141<B>Method Summary</B></FONT></TH>
142</TR>
143<TR BGCOLOR="white" CLASS="TableRowColor">
144<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
145<CODE>static&nbsp;boolean</CODE></FONT></TD>
146<TD><CODE><B><A HREF="../../../../com/google/common/base/Objects.html#equal(java.lang.Object, java.lang.Object)">equal</A></B>(<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>&nbsp;a,
147      <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>&nbsp;b)</CODE>
148
149<BR>
150&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Determines whether two possibly-null objects are equal.</TD>
151</TR>
152<TR BGCOLOR="white" CLASS="TableRowColor">
153<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
154<CODE>static&nbsp;int</CODE></FONT></TD>
155<TD><CODE><B><A HREF="../../../../com/google/common/base/Objects.html#hashCode(java.lang.Object...)">hashCode</A></B>(<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>...&nbsp;objects)</CODE>
156
157<BR>
158&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Generates a hash code for multiple values.</TD>
159</TR>
160<TR BGCOLOR="white" CLASS="TableRowColor">
161<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
162<CODE>static&nbsp;<A HREF="../../../../com/google/common/base/Objects.ToStringHelper.html" title="class in com.google.common.base">Objects.ToStringHelper</A></CODE></FONT></TD>
163<TD><CODE><B><A HREF="../../../../com/google/common/base/Objects.html#toStringHelper(java.lang.Object)">toStringHelper</A></B>(<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>&nbsp;object)</CODE>
164
165<BR>
166&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates an instance of <A HREF="../../../../com/google/common/base/Objects.ToStringHelper.html" title="class in com.google.common.base"><CODE>Objects.ToStringHelper</CODE></A>.</TD>
167</TR>
168</TABLE>
169&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
170<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
171<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
172<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>
173</TR>
174<TR BGCOLOR="white" CLASS="TableRowColor">
175<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#toString()" title="class or interface in java.lang">toString</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>
176</TR>
177</TABLE>
178&nbsp;
179<P>
180
181<!-- ============ METHOD DETAIL ========== -->
182
183<A NAME="method_detail"><!-- --></A>
184<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
185<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
186<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
187<B>Method Detail</B></FONT></TH>
188</TR>
189</TABLE>
190
191<A NAME="equal(java.lang.Object, java.lang.Object)"><!-- --></A><H3>
192equal</H3>
193<PRE>
194public static boolean <B>equal</B>(<FONT SIZE="-1"><A HREF="http://jsr-305.googlecode.com/svn/trunk/javadoc/javax/annotation/Nullable.html?is-external=true" title="class or interface in javax.annotation">@Nullable</A></FONT>
195                            <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>&nbsp;a,
196                            <FONT SIZE="-1"><A HREF="http://jsr-305.googlecode.com/svn/trunk/javadoc/javax/annotation/Nullable.html?is-external=true" title="class or interface in javax.annotation">@Nullable</A></FONT>
197                            <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>&nbsp;b)</PRE>
198<DL>
199<DD>Determines whether two possibly-null objects are equal. Returns:
200
201 <ul>
202 <li><code>true</code> if <code>a</code> and <code>b</code> are both null.
203 <li><code>true</code> if <code>a</code> and <code>b</code> are both non-null and they are
204     equal according to <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"><CODE>Object.equals(Object)</CODE></A>.
205 <li><code>false</code> in all other situations.
206 </ul>
207
208 <p>This assumes that any non-null objects passed to this function conform
209 to the <code>equals()</code> contract.
210<P>
211<DD><DL>
212</DL>
213</DD>
214</DL>
215<HR>
216
217<A NAME="hashCode(java.lang.Object...)"><!-- --></A><H3>
218hashCode</H3>
219<PRE>
220public static int <B>hashCode</B>(<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>...&nbsp;objects)</PRE>
221<DL>
222<DD>Generates a hash code for multiple values. The hash code is generated by
223 calling <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Arrays.html?is-external=true#hashCode(java.lang.Object[])" title="class or interface in java.util"><CODE>Arrays.hashCode(Object[])</CODE></A>.
224
225 <p>This is useful for implementing <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"><CODE>Object.hashCode()</CODE></A>. For example,
226 in an object that has three properties, <code>x</code>, <code>y</code>, and
227 <code>z</code>, one could write:
228 <pre>
229 public int hashCode() {
230   return Objects.hashCode(getX(), getY(), getZ());
231 }</pre>
232
233 <b>Warning</b>: When a single object is supplied, the returned hash code
234 does not equal the hash code of that object.
235<P>
236<DD><DL>
237</DL>
238</DD>
239</DL>
240<HR>
241
242<A NAME="toStringHelper(java.lang.Object)"><!-- --></A><H3>
243toStringHelper</H3>
244<PRE>
245public static <A HREF="../../../../com/google/common/base/Objects.ToStringHelper.html" title="class in com.google.common.base">Objects.ToStringHelper</A> <B>toStringHelper</B>(<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>&nbsp;object)</PRE>
246<DL>
247<DD>Creates an instance of <A HREF="../../../../com/google/common/base/Objects.ToStringHelper.html" title="class in com.google.common.base"><CODE>Objects.ToStringHelper</CODE></A>.
248
249 <p>This is helpful for implementing <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"><CODE>Object.toString()</CODE></A>. For
250 example, in an object that contains two member variables, <code>x</code>,
251 and <code>y</code>, one could write:<pre>   <tt>
252   public class ClassName {
253     public String toString() {
254       return Objects.toStringHelper(this)
255           .add("x", x)
256           .add("y", y)
257           .toString();
258     }
259   }</tt>
260 </pre>
261
262 Assuming the values of <code>x</code> and <code>y</code> are 1 and 2,
263 this code snippet returns the string <tt>"ClassName{x=1, y=2}"</tt>.
264<P>
265<DD><DL>
266<DT><B>Since:</B></DT>
267  <DD>2010.01.04 <b>tentative</b></DD>
268</DL>
269</DD>
270</DL>
271<!-- ========= END OF CLASS DATA ========= -->
272<HR>
273
274
275<!-- ======= START OF BOTTOM NAVBAR ====== -->
276<A NAME="navbar_bottom"><!-- --></A>
277<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
278<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
279<TR>
280<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
281<A NAME="navbar_bottom_firstrow"><!-- --></A>
282<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
283  <TR ALIGN="center" VALIGN="top">
284  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
285  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
286  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
287  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Objects.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
288  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
289  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
290  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
291  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
292  </TR>
293</TABLE>
294</TD>
295<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
296</EM>
297</TD>
298</TR>
299
300<TR>
301<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
302&nbsp;<A HREF="../../../../com/google/common/base/Joiner.MapJoiner.html" title="class in com.google.common.base"><B>PREV CLASS</B></A>&nbsp;
303&nbsp;<A HREF="../../../../com/google/common/base/Objects.ToStringHelper.html" title="class in com.google.common.base"><B>NEXT CLASS</B></A></FONT></TD>
304<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
305  <A HREF="../../../../index.html?com/google/common/base/Objects.html" target="_top"><B>FRAMES</B></A>  &nbsp;
306&nbsp;<A HREF="Objects.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
307&nbsp;<SCRIPT type="text/javascript">
308  <!--
309  if(window==top) {
310    document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
311  }
312  //-->
313</SCRIPT>
314<NOSCRIPT>
315  <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
316</NOSCRIPT>
317
318
319</FONT></TD>
320</TR>
321<TR>
322<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
323  SUMMARY:&nbsp;<A HREF="#nested_class_summary">NESTED</A>&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
324<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
325DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
326</TR>
327</TABLE>
328<A NAME="skip-navbar_bottom"></A>
329<!-- ======== END OF BOTTOM NAVBAR ======= -->
330
331<HR>
332
333</BODY>
334</HTML>
335