1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5 <!-- Generated by javadoc (build 1.5.0_06) on Wed Aug 20 17:16:44 PDT 2008 -->
7 Constraint (Google Collections Library - snapshot-
20080820 (ALPHA))
10 <META NAME=
"keywords" CONTENT=
"com.google.common.collect.Constraint interface">
12 <LINK REL =
"stylesheet" TYPE=
"text/css" HREF=
"../../../../stylesheet.css" TITLE=
"Style">
14 <SCRIPT type=
"text/javascript">
15 function windowTitle()
17 parent.document.
title=
"Constraint (Google Collections Library - snapshot-20080820 (ALPHA))";
25 <BODY BGCOLOR=
"white" onload=
"windowTitle();">
28 <!-- ========= START OF TOP NAVBAR ======= -->
29 <A NAME=
"navbar_top"><!-- --></A>
30 <A HREF=
"#skip-navbar_top" title=
"Skip navigation links"></A>
31 <TABLE BORDER=
"0" WIDTH=
"100%" CELLPADDING=
"1" CELLSPACING=
"0" SUMMARY=
"">
33 <TD COLSPAN=
2 BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1">
34 <A NAME=
"navbar_top_firstrow"><!-- --></A>
35 <TABLE BORDER=
"0" CELLPADDING=
"0" CELLSPACING=
"3" SUMMARY=
"">
36 <TR ALIGN=
"center" VALIGN=
"top">
37 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../overview-summary.html"><FONT CLASS=
"NavBarFont1"><B>Overview
</B></FONT></A> </TD>
38 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"package-summary.html"><FONT CLASS=
"NavBarFont1"><B>Package
</B></FONT></A> </TD>
39 <TD BGCOLOR=
"#FFFFFF" CLASS=
"NavBarCell1Rev"> <FONT CLASS=
"NavBarFont1Rev"><B>Class
</B></FONT> </TD>
40 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"package-tree.html"><FONT CLASS=
"NavBarFont1"><B>Tree
</B></FONT></A> </TD>
41 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../deprecated-list.html"><FONT CLASS=
"NavBarFont1"><B>Deprecated
</B></FONT></A> </TD>
42 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../index-all.html"><FONT CLASS=
"NavBarFont1"><B>Index
</B></FONT></A> </TD>
43 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../help-doc.html"><FONT CLASS=
"NavBarFont1"><B>Help
</B></FONT></A> </TD>
47 <TD ALIGN=
"right" VALIGN=
"top" ROWSPAN=
3><EM>
53 <TD BGCOLOR=
"white" CLASS=
"NavBarCell2"><FONT SIZE=
"-2">
54 <A HREF=
"../../../../com/google/common/collect/ConcurrentMultiset.html" title=
"class in com.google.common.collect"><B>PREV CLASS
</B></A>
55 <A HREF=
"../../../../com/google/common/collect/Constraints.html" title=
"class in com.google.common.collect"><B>NEXT CLASS
</B></A></FONT></TD>
56 <TD BGCOLOR=
"white" CLASS=
"NavBarCell2"><FONT SIZE=
"-2">
57 <A HREF=
"../../../../index.html?com/google/common/collect/Constraint.html" target=
"_top"><B>FRAMES
</B></A>
58 <A HREF=
"Constraint.html" target=
"_top"><B>NO FRAMES
</B></A>
59 <SCRIPT type=
"text/javascript">
62 document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
67 <A HREF=
"../../../../allclasses-noframe.html"><B>All Classes
</B></A>
74 <TD VALIGN=
"top" CLASS=
"NavBarCell3"><FONT SIZE=
"-2">
75 SUMMARY:
NESTED
|
FIELD
|
CONSTR
|
<A HREF=
"#method_summary">METHOD
</A></FONT></TD>
76 <TD VALIGN=
"top" CLASS=
"NavBarCell3"><FONT SIZE=
"-2">
77 DETAIL:
FIELD
|
CONSTR
|
<A HREF=
"#method_detail">METHOD
</A></FONT></TD>
80 <A NAME=
"skip-navbar_top"></A>
81 <!-- ========= END OF TOP NAVBAR ========= -->
84 <!-- ======== START OF CLASS DATA ======== -->
87 com.google.common.collect
</FONT>
89 Interface Constraint
<E
></H2>
92 <DT><PRE>public interface
<B>Constraint
<E
></B></DL>
96 A constraint that an element must satisfy in order to be added to a
97 collection. For example,
<A HREF=
"../../../../com/google/common/collect/Constraints.html#notNull()"><CODE>Constraints.notNull()
</CODE></A>, which prevents a
98 collection from including any null elements, could be implemented like this:
99 <pre> <code>public Object checkElement(Object element) {
100 if (element == null) {
101 throw new NullPointerException();
106 In order to be effective, constraints should be deterministic; that is,
107 they should not depend on state that can change (such as external state,
108 random variables, and time) and should only depend on the value of the
109 passed-in element. A non-deterministic constraint cannot reliably enforce
110 that all the collection's elements meet the constraint, since the constraint
111 is only enforced when elements are added.
116 <DT><B>Author:
</B></DT>
117 <DD>Mike Bostock
</DD>
118 <DT><B>See Also:
</B><DD><A HREF=
"../../../../com/google/common/collect/Constraints.html" title=
"class in com.google.common.collect"><CODE>Constraints
</CODE></A>,
119 <A HREF=
"../../../../com/google/common/collect/MapConstraint.html" title=
"interface in com.google.common.collect"><CODE>MapConstraint
</CODE></A></DL>
124 <!-- ========== METHOD SUMMARY =========== -->
126 <A NAME=
"method_summary"><!-- --></A>
127 <TABLE BORDER=
"1" WIDTH=
"100%" CELLPADDING=
"3" CELLSPACING=
"0" SUMMARY=
"">
128 <TR BGCOLOR=
"#CCCCFF" CLASS=
"TableHeadingColor">
129 <TH ALIGN=
"left" COLSPAN=
"2"><FONT SIZE=
"+2">
130 <B>Method Summary
</B></FONT></TH>
132 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
133 <TD ALIGN=
"right" VALIGN=
"top" WIDTH=
"1%"><FONT SIZE=
"-1">
134 <CODE> <A HREF=
"../../../../com/google/common/collect/Constraint.html" title=
"type parameter in Constraint">E
</A></CODE></FONT></TD>
135 <TD><CODE><B><A HREF=
"../../../../com/google/common/collect/Constraint.html#checkElement(E)">checkElement
</A></B>(
<A HREF=
"../../../../com/google/common/collect/Constraint.html" title=
"type parameter in Constraint">E
</A> element)
</CODE>
138 Throws a suitable
<code>RuntimeException
</code> if the specified element is
141 <TR BGCOLOR=
"white" CLASS=
"TableRowColor">
142 <TD ALIGN=
"right" VALIGN=
"top" WIDTH=
"1%"><FONT SIZE=
"-1">
143 <CODE> <A HREF=
"http://java.sun.com/javase/6/docs/api/java/lang/String.html" title=
"class or interface in java.lang">String
</A></CODE></FONT></TD>
144 <TD><CODE><B><A HREF=
"../../../../com/google/common/collect/Constraint.html#toString()">toString
</A></B>()
</CODE>
147 Returns a brief human readable description of this constraint, such as
148 "Not null" or
"Positive number".
</TD>
154 <!-- ============ METHOD DETAIL ========== -->
156 <A NAME=
"method_detail"><!-- --></A>
157 <TABLE BORDER=
"1" WIDTH=
"100%" CELLPADDING=
"3" CELLSPACING=
"0" SUMMARY=
"">
158 <TR BGCOLOR=
"#CCCCFF" CLASS=
"TableHeadingColor">
159 <TH ALIGN=
"left" COLSPAN=
"1"><FONT SIZE=
"+2">
160 <B>Method Detail
</B></FONT></TH>
164 <A NAME=
"checkElement(java.lang.Object)"><!-- --></A><A NAME=
"checkElement(E)"><!-- --></A><H3>
167 <A HREF=
"../../../../com/google/common/collect/Constraint.html" title=
"type parameter in Constraint">E
</A> <B>checkElement
</B>(
<A HREF=
"../../../../com/google/common/collect/Constraint.html" title=
"type parameter in Constraint">E
</A> element)
</PRE>
169 <DD>Throws a suitable
<code>RuntimeException
</code> if the specified element is
170 illegal. Typically this is either a
<A HREF=
"http://java.sun.com/javase/6/docs/api/java/lang/NullPointerException.html" title=
"class or interface in java.lang"><CODE>NullPointerException
</CODE></A>, an
171 <A HREF=
"http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html" title=
"class or interface in java.lang"><CODE>IllegalArgumentException
</CODE></A>, or a
<A HREF=
"http://java.sun.com/javase/6/docs/api/java/lang/ClassCastException.html" title=
"class or interface in java.lang"><CODE>ClassCastException
</CODE></A>, though
172 an application-specific exception class may be used if appropriate.
175 <DT><B>Parameters:
</B><DD><CODE>element
</CODE> - the element to check
176 <DT><B>Returns:
</B><DD>the provided element
</DL>
181 <A NAME=
"toString()"><!-- --></A><H3>
184 <A HREF=
"http://java.sun.com/javase/6/docs/api/java/lang/String.html" title=
"class or interface in java.lang">String
</A> <B>toString
</B>()
</PRE>
186 <DD>Returns a brief human readable description of this constraint, such as
187 "Not null" or
"Positive number".
190 <DT><B>Overrides:
</B><DD><CODE><A HREF=
"http://java.sun.com/javase/6/docs/api/java/lang/Object.html#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" title=
"class or interface in java.lang">Object
</A></CODE></DL>
194 <DT><B>Returns:
</B><DD>a string representation of the object.
</DL>
197 <!-- ========= END OF CLASS DATA ========= -->
201 <!-- ======= START OF BOTTOM NAVBAR ====== -->
202 <A NAME=
"navbar_bottom"><!-- --></A>
203 <A HREF=
"#skip-navbar_bottom" title=
"Skip navigation links"></A>
204 <TABLE BORDER=
"0" WIDTH=
"100%" CELLPADDING=
"1" CELLSPACING=
"0" SUMMARY=
"">
206 <TD COLSPAN=
2 BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1">
207 <A NAME=
"navbar_bottom_firstrow"><!-- --></A>
208 <TABLE BORDER=
"0" CELLPADDING=
"0" CELLSPACING=
"3" SUMMARY=
"">
209 <TR ALIGN=
"center" VALIGN=
"top">
210 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../overview-summary.html"><FONT CLASS=
"NavBarFont1"><B>Overview
</B></FONT></A> </TD>
211 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"package-summary.html"><FONT CLASS=
"NavBarFont1"><B>Package
</B></FONT></A> </TD>
212 <TD BGCOLOR=
"#FFFFFF" CLASS=
"NavBarCell1Rev"> <FONT CLASS=
"NavBarFont1Rev"><B>Class
</B></FONT> </TD>
213 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"package-tree.html"><FONT CLASS=
"NavBarFont1"><B>Tree
</B></FONT></A> </TD>
214 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../deprecated-list.html"><FONT CLASS=
"NavBarFont1"><B>Deprecated
</B></FONT></A> </TD>
215 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../index-all.html"><FONT CLASS=
"NavBarFont1"><B>Index
</B></FONT></A> </TD>
216 <TD BGCOLOR=
"#EEEEFF" CLASS=
"NavBarCell1"> <A HREF=
"../../../../help-doc.html"><FONT CLASS=
"NavBarFont1"><B>Help
</B></FONT></A> </TD>
220 <TD ALIGN=
"right" VALIGN=
"top" ROWSPAN=
3><EM>
226 <TD BGCOLOR=
"white" CLASS=
"NavBarCell2"><FONT SIZE=
"-2">
227 <A HREF=
"../../../../com/google/common/collect/ConcurrentMultiset.html" title=
"class in com.google.common.collect"><B>PREV CLASS
</B></A>
228 <A HREF=
"../../../../com/google/common/collect/Constraints.html" title=
"class in com.google.common.collect"><B>NEXT CLASS
</B></A></FONT></TD>
229 <TD BGCOLOR=
"white" CLASS=
"NavBarCell2"><FONT SIZE=
"-2">
230 <A HREF=
"../../../../index.html?com/google/common/collect/Constraint.html" target=
"_top"><B>FRAMES
</B></A>
231 <A HREF=
"Constraint.html" target=
"_top"><B>NO FRAMES
</B></A>
232 <SCRIPT type=
"text/javascript">
235 document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
240 <A HREF=
"../../../../allclasses-noframe.html"><B>All Classes
</B></A>
247 <TD VALIGN=
"top" CLASS=
"NavBarCell3"><FONT SIZE=
"-2">
248 SUMMARY:
NESTED
|
FIELD
|
CONSTR
|
<A HREF=
"#method_summary">METHOD
</A></FONT></TD>
249 <TD VALIGN=
"top" CLASS=
"NavBarCell3"><FONT SIZE=
"-2">
250 DETAIL:
FIELD
|
CONSTR
|
<A HREF=
"#method_detail">METHOD
</A></FONT></TD>
253 <A NAME=
"skip-navbar_bottom"></A>
254 <!-- ======== END OF BOTTOM NAVBAR ======= -->