javatuples-javatuples-1.2/0000755000175000017500000000000011646342650015217 5ustar eugeneeugenejavatuples-javatuples-1.2/NOTICE.txt0000644000175000017500000000120311646342650016735 0ustar eugeneeugene Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. javatuples-javatuples-1.2/USAGE.txt0000644000175000017500000000120011646342650016615 0ustar eugeneeugene Using javatuples from Maven 2 ----------------------------- To use it in your Maven 2 applications, you will need to add it as a dependency with: org.javatuples javatuples {version} compile In order for this to work correctly, you need to have previously installed javatuples in your local repository (as explained in BUILD.txt) or have a working internet connection to let maven automatically download javatuples binaries from Maven 2's central repositories. javatuples-javatuples-1.2/LICENSE.txt0000644000175000017500000002645011646342650017051 0ustar eugeneeugene Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. javatuples-javatuples-1.2/pom.xml0000644000175000017500000001643511646342650016545 0ustar eugeneeugene 4.0.0 org.javatuples javatuples jar 1.2 javatuples http://www.javatuples.org Java library for tuples in Java. The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo The JAVATUPLES team http://www.javatuples.org scm:svn:http://java-tuples.svn.sourceforge.net/svnroot/java-tuples/tags/javatuples/javatuples-1.2 scm:svn:https://java-tuples.svn.sourceforge.net/svnroot/java-tuples/tags/javatuples/javatuples-1.2 scm:svn:https://java-tuples.svn.sourceforge.net/svnroot/java-tuples/tags/javatuples/javatuples-1.2 dfernandez Daniel Fernandez dfernandez AT users.sourceforge.net Project admin sonatype-nexus-snapshots Sonatype Nexus Snapshots http://oss.sonatype.org/content/repositories/snapshots sonatype-nexus-snapshots Sonatype Nexus Snapshots http://oss.sonatype.org/service/local/staging/deploy/maven2 org.apache.maven.plugins maven-project-info-reports-plugin license scm src/main/resources . META-INF LICENSE.txt NOTICE.txt src/test/resources org.apache.maven.plugins maven-compiler-plugin 1.5 1.5 org.apache.maven.plugins maven-javadoc-plugin java.lang ${basedir}/src/main/javadoc/overview.html ${basedir}/src/main/javadoc ${project.reporting.outputDirectory}/api/${artifactId}/apidocs org.apache.maven.plugins maven-source-plugin package jar org.apache.maven.plugins maven-javadoc-plugin package jar org.apache.maven.plugins maven-gpg-plugin sign-artifacts verify sign org.apache.maven.plugins maven-assembly-plugin 2.2 src/assembly/dist.xml make-assembly-deps package single org.apache.maven.plugins maven-release-plugin https://java-tuples.svn.sourceforge.net/svnroot/java-tuples/tags/javatuples commons-lang commons-lang 2.5 test junit junit 4.8.2 test javatuples-javatuples-1.2/src/0000755000175000017500000000000011646342650016006 5ustar eugeneeugenejavatuples-javatuples-1.2/src/site/0000755000175000017500000000000011646342650016752 5ustar eugeneeugenejavatuples-javatuples-1.2/src/site/fml/0000755000175000017500000000000011646342650017530 5ustar eugeneeugenejavatuples-javatuples-1.2/src/site/fml/faq.fml0000644000175000017500000000447411646342650021010 0ustar eugeneeugene About javatuples Where does javatuples come from? Is it made or backed by any software company?

javatuples is Open Source Software created by a Spanish Software Engineer called Daniel Fernndez in his spare time.

It is neither made nor backed by any software (or any other type of) company, and it is offered to the public totally free of charge, both in binary and in source code forms, under the Apache License 2.0.

Does javatuples offer any type of commercial support?

No, it does not. Commercial support is not offered at the moment, but there is a User Forum/List at your disposal.

How can I contribute to javatuples?

In many ways:

  • You can write in the User Forum/List (or directly to the Team) with your ideas for improving javatuples.
  • You can contribute some code, write a patch for a new feature or behaviour (please, tell the project admins first about your idea so that effort can be correctly coordinated).
  • You can write articles, reviews, blog posts, etc. about javatuples, showing how it works or how it integrates with other technologies.
  • You can promote javatuples in your company/work and among your colleague developers.

If you want to contribute some code to javatuples, please read first the page on Contributing to javatuples.

javatuples-javatuples-1.2/src/site/resources/0000755000175000017500000000000011646342650020764 5ustar eugeneeugenejavatuples-javatuples-1.2/src/site/resources/images/0000755000175000017500000000000011646342650022231 5ustar eugeneeugenejavatuples-javatuples-1.2/src/site/resources/images/javatuples_logo.png0000644000175000017500000001344111646342650026140 0ustar eugeneeugenePNG  IHDRdsRGB pHYs  tIME PontEXtCommentCreated with GIMPWIDATx{P @*Ex!"aTMCbK m31v"3Tc4L$Z%hЀ v-ri|γ7YC9ysoϞF!@DDDD} 1$""""DDDD@""""bHDDDD  1$""""DDDD1$""""DDDD@""""bHDDDD  93wh !xv>-DDDD ȝy Hms!mHDDD@""""bHDDDD*QIDDDHDDDܙ[NԄ|嗨ݻwQYYjL&f@2dBCC &ǨQz>s;v .\@yy9  ((QQQHNN1~xckk+Ξ=/.]۷ F?ɓ'#-- -`g}"֭[0 hkkE@@BBB0 >>LD&GZٳG,]T Fh_Ɗ_]*>քTW^WBB5kQyےG}$㥷1ct.lx|h"ѿ(}vlb_~jmZۂ;   l":::˴sN_}U_׮]TU %KXUwW_ťbjkfСb޽6?KKKŔ)Sz'" >}*Scc0`T6I`MMMG ],rbtȵ81dO&I\+VV3gϪ:>4"))nR`[[t_-\'*..ƚ5kҮZJ:}YU%ۭ^Z&Fue-;wwcO~:tt3gZZZΆh䃕o{9*)_HLL1رcQRRc TWW_~hmm=455vܸqtљe-Fb`"((W 999x7z/{LWTT$ q5ND}[jZ$''^={PQQZuuu|2:իWGQݶmTZVz|駊رcRrj= [A㥗^2c֭}||s!//zO`|8Çѣy3۷oNkkkÿo;z-,_qqqH%6};#jjj`0ŋKSo}}󩧞RT'|R* zjZϐ!C͛˗EcchnnW^[n!!!UUUR]]]bܸqyNj7ntѣGT~#F7uT.\hBTVVݻw >D䞃@RRRٳgm.b3gΔ.cnnTYYYRy{{KBG4.[-lݧjd2_Q6m:8|t~ڷotw6ÇKSQQaӵ[WW'v!Ə7WhOyyye|ϗsΝRyy;w-Q `~TFFFJ777|{1]J;uꔢ󕜜lB_f3TDdw|I&I/%''cRieGʦCRR[ԣ*:zo~#otwAii~Ri(ŸuV}le|'|0W N{]4Ο?n\v :ήUK=2̝;W:Y%ЩsIؙW*//mpJe=…<#RVVeee:FaЇTxxx8d~~~bѢE"//=݉=f̛7?<\Jye=z4ݲɾ xk~=R_9=jkZsss':}@łfFʕ+:t6|R+z$Sԥ曈vh1c 鈈*8~ʼ|rxyyAK}ݶ(gyƭU)/Jsc]]]}8uƌrtvvbŊ@e2yfE$&&b׮]|2ՅN#c޼yRi~ȐN:;;]ّFm)vҥR~!88Q$=@Vݻw2x㏥ӟ8q׮]s0==]qwߕJ5H˥=zԩ}d#n}ګ-$$D:{LslذekעtFk׮7,, Gv<裘:uTڊ ڵˮ/((̙3~cbbyz D@%:t4v1̞=vkHKK8|p6l͛QRRd iO>7|y&f͚nܸy桶iSO)7rJxx81uӦY,|'HMMERR&M;cT2DkD455 (+m6(/V+*++{ejv)gGեZ,..999"44Ԫr555ㆆ1m4cMKKD$4‰*Svܩ[֮]LDDD7n@nn.~[|w9<<==q] :Tj? .n^SSPES8 5GYt)?;p7?TT#Gbٲe>}:bbb0p@h4ף(**Baa! !S&L#66111>|8???ׯ_ӧ{n"۷oǚ5kAǩ6Fxx8Z[[UBΜ9slZ-##CѨLףlƣ>j5fepB鵘z8x`JHϞtyjuݺza*Fd8b{5֣/V\f^dTⷿtH;v@zz:/2#o~/JIHH&KuttCZUÇ+h2DLLӗζ>322d}/^^G}}=0p@DDD`ĉ={6zeZ5`=iiiA^^N8N^Z!0h "%% ,pB>G} .ەBӧckкv;w|2n޼*455ZC@@F(DGG#66֦I[[JKKqݻBUU f3ZZZ`X0`aaaAll,0vX>Ĉ7obԨQRiQVVƳCK 75(Y<^ɺDDDDɓ'N2gH`EE?I6m 8d;wpqlݺ555R =;%rƶ7"<QXbTGDDDDVkn%իW1rHD-d&ɥ&o۱ctGDDDD*W^UV9go@_/x[A[Ν;EEEVDDDDd  AT#22gɜ0V@""""bHDDDD  1$""""DDDD@""""bHDDDD  1$"""bHDDDD ˘ޚApIENDB`javatuples-javatuples-1.2/src/site/site.xml0000644000175000017500000000465411646342650020451 0ustar eugeneeugene javatuples images/javatuples_logo.png http://www.javatuples.org/ org.apache.maven.skins maven-default-skin javatuples-javatuples-1.2/src/site/apt/0000755000175000017500000000000011646342650017536 5ustar eugeneeugenejavatuples-javatuples-1.2/src/site/apt/team.apt0000644000175000017500000000160411646342650021173 0ustar eugeneeugene ------- Team ------- Development Team Do never email the authors directly on the usage of JAVATUPLES, use the users list instead. <>. *-----------+----------------------+---------------------+--------------------------------------+----------------------------------+ <> | <> | <> | <> | <> | *-----------+----------------------+---------------------+--------------------------------------+----------------------------------+ dfernandez | Daniel Fernndez | Spain | dfernandez AT users.sourceforge.net | Lead Developer (Project founder) | *-----------+----------------------+---------------------+--------------------------------------+----------------------------------+ javatuples-javatuples-1.2/src/site/apt/dependencies.apt0000644000175000017500000000025011646342650022667 0ustar eugeneeugene ------- javatuples dependencies ------- javatuples requires Java version 1.5 or higher. There are no other dependencies on external libraries. javatuples-javatuples-1.2/src/site/apt/index.apt0000644000175000017500000001041611646342650021355 0ustar eugeneeugene ------- Main ------- <> (October 15th, 2011). <<{{{./download.html}[DOWNLOAD]}}>> javatuples 1.2 is an evolutive release. Now tuples are comparable --and sortable-- and new static methods have been added for obtaining tuples from iterables, even if these iterables hold more elements than needed by the new tuple. javatuples javatuples is one of the simplest java libraries ever made. Its aim is to provide a set of java classes that allow you to work with s. <> A tuple is just a sequence of objects that do not necessarily relate to each other in any way. For example: <<<[23, "Saturn", java.sql.Connection@li734s]>>> can be considered a tuple of three elements (a ) containing an Integer, a String, and a JDBC Connection object. As simple as that. Very probably, you've already written tuple classes for some of your projects, like: --- public Triplet getYearMonthDay() { .... --- ...or... --- LabelValue operatorLabelValue = new LabelValue(">=", Operator.MORE_OR_EQUAL_TO); --- ...or... --- private Map,Object> objectsByTwoKeys = ... --- <<>>>, <<>>> and <<>>> are all tuple classes. <> offers you tuple classes from one to ten elements: * <<>>> (1 element) * <<>>> (2 elements) * <<>>> (3 elements) * <<>>> (4 elements) * <<>>> (5 elements) * <<>>> (6 elements) * <<>>> (7 elements) * <<>>> (8 elements) * <<>>> (9 elements) * <<>>> (10 elements) Plus a couple of very common 2-element tuple classes equivalent to <<>>, just for the sake of code semantics: * <<>>> * <<>>> All tuple classes are: * Typesafe * Immutable * Iterable * Serializable * Comparable (implements <<>>>) * Implementing <<>> and <<>> * Implementing <<>> * Tuples vs. Lists/Arrays So, how do these <"tuples"> compare with other common structures like lists or arrays? * Lists (<<>>>) and arrays (<<>>): * Can contain an undefined number of elements. * All elements must be instances of <<>>. * Tuples: * Can only contain a specific number of elements. * Elements can be of completely different type and nature... * ...and yet, tuples will be completely typesafe. * Some example code Let's say we have some objects... --- ... String str = ...; Integer integ = ...; Double[] doubleArray = ...; ... --- ...and we want to create a 3-element tuple with them: --- Triplet triplet = Triplet.with(str, integ, doubleArray); --- Now how do we get our data back? easy: --- ... String myStr = triplet.getValue0(); Integer myInteg = triplet.getValue1(); Double[] myDoubleArray = triplet.getValue2(); ... --- Note there are no cast operations in the code above, because tuples allow <<>> methods to be completely typesafe. And what if we want to add a Boolean to the tuple? That would turn our into a : --- Quartet quartet = triplet.add(myBoolean); --- Many useful methods are also implemented. Some examples: --- ... int i = quartet.indexOf(someValue); ... Object[] array = quartet.toArray(); ... if (quartet.contains(someOtherValue)) { ... --- Tuples are also iterable, like collections and arrays: --- for (Object element : quartet) { ... } --- Have a look at the {{{using.html}Using javatuples}} page for more features and code examples. javatuples-javatuples-1.2/src/site/apt/using.apt0000644000175000017500000001706111646342650021376 0ustar eugeneeugene ------- Using javatuples ------- Using javatuples * The tuple classes There are ten tuple classes in javatuples: * <<>>> (1 element) * <<>>> (2 elements) * <<>>> (3 elements) * <<>>> (4 elements) * <<>>> (5 elements) * <<>>> (6 elements) * <<>>> (7 elements) * <<>>> (8 elements) * <<>>> (9 elements) * <<>>> (10 elements) Plus a couple of very common 2-element tuple classes equivalent to <<>>, just for the sake of code semantics: * <<>>> * <<>>> All tuple classes are: * Typesafe * Immutable * Iterable * Serializable * Comparable (implements <<>>>) * Implementing <<>> and <<>> * Implementing <<>> * Creating tuples Tuples can be instanced in a semantically elegant way, using the <<>> methods from each of the tuple classes: --- Pair pair = Pair.with("hello", Integer.valueOf(23)); ... Quintet quintet = Quintet.with("a", Integer.valueOf(3), Double.valueOf(34.2), "b", "c"); --- Of course, constructors can also be used directly: --- Pair pair = new Pair("hello", Integer.valueOf(23)); ... Quintet quintet = new Quintet("a", Integer.valueOf(3), Double.valueOf(34.2), "b", "c"); --- You can also create tuples from collections or --more generally--, any iterable: --- Quintet quintet = Quintet.fromCollection(myCollectionWith5Elements); ... // Retrieve three values from an iterable starting at a specific index Triplet triplet = Triplet.fromIterable(lotsOfInts, 7); --- * Getting values Values can be retrieved from a tuple by using the specific method for its position: --- Triplet triplet = ... ... Integer intVal = triplet.getValue1(); --- Note that: * Value numbering starts with 0, so the getter for the first position will always be <<>>. * A tuple object will only offer you methods for the specific number of positions it holds (e.g. <<>> does not have a <<>> method). * All <<>> getters are typesafe, no cast needed. Thanks to the type parameterization of the tuple classes (the "<<<>>>" in <<>>>) the compiler will know that is of type <<>>, of type <<>>, and so on. There is also a <<>> method, but its use is not recommended, because the compiler cannot know the type of the result beforehand and therefore you will need a cast: --- Triplet triplet = ... ... Integer intVal = (Integer) triplet.getValue(1); --- Note that classes <> and <> have their <<>>/<<>> methods renamed as <<>>/<<>> and <<>>/<<>>, respectively. * Setting new values In order to set new values for specific positions of a tuple, you can use the <<>> setter methods: --- Triplet triplet = ... ... triplet = triplet.setAt2(Double.valueOf(245.21)); --- <>. This means that you will have to collect the return value of your <<>> calls, and also that you will be able to change the type of a position in the tuple by changing the object that lives in that position: --- Triplet triplet = ... ... Triplet otherTriplet = triplet.setAt2("North Atlantic"); --- * Adding or removing elements New elements can be added to a tuple, converting it in a different tuple. For example, if you add a <<>> to a <<>>>, you will turn it into a <<>>>: --- Triplet triplet = ... ... Quartet quartet = triplet.add("South Pacific"); --- By default, new elements are added at the end of the tuple. But you can also add elements in other positions of the tuple by using the <<>> methods: --- Triplet triplet = ... ... Quartet quartet = triplet.addAt2("Mediterranean"); --- You can also add more than one element... --- Triplet triplet = ... ... Quintet quintet = triplet.addAt2("Red Sea", "Caspian"); --- ...or even other tuples: --- Triplet triplet1 = ... Triplet triplet2 = ... ... Sextet sextet = triplet1.addAt2(triplet2); --- Removing elements is just as easy, and it will also transform your tuple. If you remove an element from a <<>>, you will get a <<>>: --- Triplet triplet = ... ... Pair pair = triplet.removeFrom1(); --- * Converting to/from collections or arrays A tuple can be easily converted to a list or an array, but you will lose your type-safety and end up with a <<>>> or an <<>>: --- Triplet triplet = ... ... List list = triplet.toList(); ... Object[] array = triplet.toArray(); --- Inversely, you can obtain a tuple from both a collection or an array: --- String[] array = ... ... Quartet quartet = Quartet.fromArray(array); --- Note that your tuple will have all its elements set to the component type of the array (<<>>, in this case). Also, note that... --- String[] array = new String[] { "a", "b", "c", "d", "e" }; ... // Array has five elements: will raise an exception trying to create a quartet!! Quartet quartet = Quartet.fromArray(array); --- ...will raise the following exception: --- java.lang.IllegalArgumentException: Array must have exactly 4 elements in order to create a Quartet. Size is 5 at ... --- * Iterating All tuple classes in javatuples implement the <<>>> interface, so it can be iterated in the same way as collections or arrays: --- Triplet triplet = ... ... for (Object value : tuple) { ... } --- * Checking contents Tuples offer some utility methods, like <<>>, <<>>, <<>> or <<>>, which work in exactly the same way as they do in collections: --- Quartet quartet = ... ... if (quartet.contains(value)) { ... } ... if (quartet.containsAll(valueCollection)) { ... } --- javatuples-javatuples-1.2/src/site/apt/download.apt0000644000175000017500000000100411646342650022046 0ustar eugeneeugene ------- Download ------- Download javatuples <>: 1.2 (released October 15th, 2011) <<{{{https://sourceforge.net/projects/java-tuples/files/}DOWNLOAD JAVATUPLES (from SourceForge.net)}}>> Nevertheless, if you are using Apache Maven for your projects, you can obtain javatuples easily from the Maven central repositories by following these {{{./maveninfo.html}instructions}}. You can also browse the Source Repository {{{./source-repository.html}here}}. javatuples-javatuples-1.2/src/site/apt/contributing.apt0000644000175000017500000001231211646342650022752 0ustar eugeneeugene ------- Contributing to javatuples ------- Contributing to javatuples: Terms In order to contribute to javatuples, there are some terms with which you must agree: <> * Anyone, with the unique condition that he/she must be a <>, acting in his/her own name, and not being endorsed in their contributed work by any company or government. [] * Note that this condition will not only refer to the ownership of the effort invested in contributing to the project, but also to the fact that no private or public company will be mentioned as a a part of your contribution on the project's website or code, including but not limited to email addresses or package names. [] <> * First and important: your code <>. Also, the addition of any new patches to the codebase should not render it unstable in any way. [] * There should be no compilation warnings. [] * All your code should follow the Java Code Conventions. The only exception for this is that column limit is not the usual 80 characters (this is a matter of convenience -just don't make them 200 characters long and it will be OK). [] * Remember that indentation is made of four spaces, not tabs. [] * All your code should compile and run in Java 1.5, and it should be easy to read and understand by a human. [] * All public methods and classes directly available to the javatuples users should have comprehensive javadoc (e.g: functions, operators), and code should have a reasonable amount of comments in it (when needed, of course, not just comment for the sake of comment). [] * All comments, names of classes and variables, log messages, etc. must be in <>. [] <> * First and most important: please, don't feel any obligation to do anything. If you like/want/feel happy about contributing, go for it. If not, don't feel any kind of commitment just for having discussed technical details with the project maintainers or other members, just leave it behind and it will be absolutely fine, even if it is after months and you have already coded thousands of lines. [] * You will be <<<@author>>> for any new classes that you code and also co-author to any existing classes to which you make changes. Of course you can say "no" to this, but unless you do, it is a matter of basic fairness to give the credit and merit to the person who deserves it. [] * Your contributions will be applied as patches that you will send to the project maintainers, and you will have the consideration of in the team page. This means that you will not have read+write direct access to the CVS repository. This is something reserved for developers who are author to a very significant percent of the total code base. Of course, this consideration can change in the future. [] * And importantly: You will have to take the required measures, under your entire responsibility, to <>, and that all the code you contribute is original and will rise no claims over its intellectual property by any third persons or companies. Also, you agree to contribute your code or documentation <>. Contributing to javatuples: Steps If, after carefully reading the above terms, you are willing to contribute some of your effort to javatuples, first of all... THANK YOU! The steps you should take are: * 1. First, send an email to the project maintainers talking about the new features or fixes you would like to contribute. Don't forget to include your full name :-). [] * 2. If your contribution is approved, send the project maintainers an email including a copy of the terms above, with your complete name, and stating clearly that you agree with these conditions. [] * 3. If you work for a company which, by the way or place in which your code was written, by your contract terms or by the laws in your contry, could claim any rights (including intellectual property) over your contributed code, you will have to send the project maintainers (either by email from your authorised superiors or by signed fax), a statement indicating that your company agrees with the terms explained in this page, and that it both authorises your contribution to javatuples and states that will never claim any kind of rights over it. javatuples-javatuples-1.2/src/site/apt/userlist.apt0000644000175000017500000000124411646342650022117 0ustar eugeneeugene ------- User List ------- JAVATUPLES mailing lists and forums * java-tuples-users (java-tuples-users@lists.sourceforge.net) The javatuples users list and users forum. Request help, discuss your ideas or make suggestions and stay in touch with other javatuples users. <> This mailing list is equivalent to the Users forum, and you can use them interchangeabily. {{{http://javatuples-users.973651.n3.nabble.com/}[USERS FORUM]}} {{{https://lists.sourceforge.net/lists/listinfo/java-tuples-users}[SUBSCRIBE TO THE MAILING LIST]}} javatuples-javatuples-1.2/src/site/apt/maveninfo.apt0000644000175000017500000000065511646342650022234 0ustar eugeneeugene ------- Using javatuples with Maven ------- Using javatuples with Maven In order to include javatuples in your maven-managed project, you will have to declare your dependency like this: +-- org.javatuples javatuples [version] compile +-- javatuples-javatuples-1.2/src/main/0000755000175000017500000000000011646342650016732 5ustar eugeneeugenejavatuples-javatuples-1.2/src/main/java/0000755000175000017500000000000011646342650017653 5ustar eugeneeugenejavatuples-javatuples-1.2/src/main/java/org/0000755000175000017500000000000011646342650020442 5ustar eugeneeugenejavatuples-javatuples-1.2/src/main/java/org/javatuples/0000755000175000017500000000000011646342650022620 5ustar eugeneeugenejavatuples-javatuples-1.2/src/main/java/org/javatuples/Quintet.java0000644000175000017500000005674111646342650025131 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.util.Collection; import java.util.Iterator; import org.javatuples.valueintf.IValue0; import org.javatuples.valueintf.IValue1; import org.javatuples.valueintf.IValue2; import org.javatuples.valueintf.IValue3; import org.javatuples.valueintf.IValue4; /** *

* A tuple of five elements. *

* * @since 1.0 * * @author Daniel Fernández * */ public final class Quintet extends Tuple implements IValue0, IValue1, IValue2, IValue3, IValue4 { private static final long serialVersionUID = -1579008485383872628L; private static final int SIZE = 5; private final A val0; private final B val1; private final C val2; private final D val3; private final E val4; public static Quintet with(final A value0, final B value1, final C value2, final D value3, final E value4) { return new Quintet(value0,value1,value2,value3,value4); } /** *

* Create tuple from array. Array has to have exactly five elements. *

* * @param the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static Quintet fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 5) { throw new IllegalArgumentException("Array must have exactly 5 elements in order to create a Quintet. Size is " + array.length); } return new Quintet( array[0],array[1],array[2],array[3],array[4]); } /** *

* Create tuple from collection. Collection has to have exactly five elements. *

* * @param the collection component type * @param collection the collection to be converted to a tuple * @return the tuple */ public static Quintet fromCollection(final Collection collection) { return fromIterable(collection); } /** *

* Create tuple from iterable. Iterable has to have exactly five elements. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Quintet fromIterable(final Iterable iterable) { return fromIterable(iterable, 0, true); } /** *

* Create tuple from iterable, starting from the specified index. Iterable * can have more (or less) elements than the tuple to be created. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Quintet fromIterable(final Iterable iterable, int index) { return fromIterable(iterable, index, false); } private static Quintet fromIterable(final Iterable iterable, int index, final boolean exactSize) { if (iterable == null) { throw new IllegalArgumentException("Iterable cannot be null"); } boolean tooFewElements = false; X element0 = null; X element1 = null; X element2 = null; X element3 = null; X element4 = null; final Iterator iter = iterable.iterator(); int i = 0; while (i < index) { if (iter.hasNext()) { iter.next(); } else { tooFewElements = true; } i++; } if (iter.hasNext()) { element0 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element1 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element2 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element3 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element4 = iter.next(); } else { tooFewElements = true; } if (tooFewElements && exactSize) { throw new IllegalArgumentException("Not enough elements for creating a Quintet (5 needed)"); } if (iter.hasNext() && exactSize) { throw new IllegalArgumentException("Iterable must have exactly 5 available elements in order to create a Quintet."); } return new Quintet( element0, element1, element2, element3, element4); } public Quintet( final A value0, final B value1, final C value2, final D value3, final E value4) { super(value0, value1, value2, value3, value4); this.val0 = value0; this.val1 = value1; this.val2 = value2; this.val3 = value3; this.val4 = value4; } public A getValue0() { return this.val0; } public B getValue1() { return this.val1; } public C getValue2() { return this.val2; } public D getValue3() { return this.val3; } public E getValue4() { return this.val4; } @Override public int getSize() { return SIZE; } public Sextet addAt0(final X0 value0) { return new Sextet( value0, this.val0, this.val1, this.val2, this.val3, this.val4); } public Sextet addAt1(final X0 value0) { return new Sextet( this.val0, value0, this.val1, this.val2, this.val3, this.val4); } public Sextet addAt2(final X0 value0) { return new Sextet( this.val0, this.val1, value0, this.val2, this.val3, this.val4); } public Sextet addAt3(final X0 value0) { return new Sextet( this.val0, this.val1, this.val2, value0, this.val3, this.val4); } public Sextet addAt4(final X0 value0) { return new Sextet( this.val0, this.val1, this.val2, this.val3, value0, this.val4); } public Sextet addAt5(final X0 value0) { return new Sextet( this.val0, this.val1, this.val2, this.val3, this.val4, value0); } public Septet addAt0(final X0 value0, final X1 value1) { return new Septet( value0, value1, this.val0, this.val1, this.val2, this.val3, this.val4); } public Septet addAt1(final X0 value0, final X1 value1) { return new Septet( this.val0, value0, value1, this.val1, this.val2, this.val3, this.val4); } public Septet addAt2(final X0 value0, final X1 value1) { return new Septet( this.val0, this.val1, value0, value1, this.val2, this.val3, this.val4); } public Septet addAt3(final X0 value0, final X1 value1) { return new Septet( this.val0, this.val1, this.val2, value0, value1, this.val3, this.val4); } public Septet addAt4(final X0 value0, final X1 value1) { return new Septet( this.val0, this.val1, this.val2, this.val3, value0, value1, this.val4); } public Septet addAt5(final X0 value0, final X1 value1) { return new Septet( this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1); } public Octet addAt0(final X0 value0, final X1 value1, final X2 value2) { return new Octet( value0, value1, value2, this.val0, this.val1, this.val2, this.val3, this.val4); } public Octet addAt1(final X0 value0, final X1 value1, final X2 value2) { return new Octet( this.val0, value0, value1, value2, this.val1, this.val2, this.val3, this.val4); } public Octet addAt2(final X0 value0, final X1 value1, final X2 value2) { return new Octet( this.val0, this.val1, value0, value1, value2, this.val2, this.val3, this.val4); } public Octet addAt3(final X0 value0, final X1 value1, final X2 value2) { return new Octet( this.val0, this.val1, this.val2, value0, value1, value2, this.val3, this.val4); } public Octet addAt4(final X0 value0, final X1 value1, final X2 value2) { return new Octet( this.val0, this.val1, this.val2, this.val3, value0, value1, value2, this.val4); } public Octet addAt5(final X0 value0, final X1 value1, final X2 value2) { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1, value2); } public Ennead addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Ennead( value0, value1, value2, value3, this.val0, this.val1, this.val2, this.val3, this.val4); } public Ennead addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Ennead( this.val0, value0, value1, value2, value3, this.val1, this.val2, this.val3, this.val4); } public Ennead addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Ennead( this.val0, this.val1, value0, value1, value2, value3, this.val2, this.val3, this.val4); } public Ennead addAt3(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Ennead( this.val0, this.val1, this.val2, value0, value1, value2, value3, this.val3, this.val4); } public Ennead addAt4(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Ennead( this.val0, this.val1, this.val2, this.val3, value0, value1, value2, value3, this.val4); } public Ennead addAt5(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1, value2, value3); } public Decade addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Decade( value0, value1, value2, value3, value4, this.val0, this.val1, this.val2, this.val3, this.val4); } public Decade addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Decade( this.val0, value0, value1, value2, value3, value4, this.val1, this.val2, this.val3, this.val4); } public Decade addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Decade( this.val0, this.val1, value0, value1, value2, value3, value4, this.val2, this.val3, this.val4); } public Decade addAt3(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Decade( this.val0, this.val1, this.val2, value0, value1, value2, value3, value4, this.val3, this.val4); } public Decade addAt4(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Decade( this.val0, this.val1, this.val2, this.val3, value0, value1, value2, value3, value4, this.val4); } public Decade addAt5(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1, value2, value3, value4); } public Sextet addAt0(final Unit tuple) { return addAt0(tuple.getValue0()); } public Sextet addAt1(final Unit tuple) { return addAt1(tuple.getValue0()); } public Sextet addAt2(final Unit tuple) { return addAt2(tuple.getValue0()); } public Sextet addAt3(final Unit tuple) { return addAt3(tuple.getValue0()); } public Sextet addAt4(final Unit tuple) { return addAt4(tuple.getValue0()); } public Sextet addAt5(final Unit tuple) { return addAt5(tuple.getValue0()); } public Septet addAt0(final Pair tuple) { return addAt0(tuple.getValue0(),tuple.getValue1()); } public Septet addAt1(final Pair tuple) { return addAt1(tuple.getValue0(),tuple.getValue1()); } public Septet addAt2(final Pair tuple) { return addAt2(tuple.getValue0(),tuple.getValue1()); } public Septet addAt3(final Pair tuple) { return addAt3(tuple.getValue0(),tuple.getValue1()); } public Septet addAt4(final Pair tuple) { return addAt4(tuple.getValue0(),tuple.getValue1()); } public Septet addAt5(final Pair tuple) { return addAt5(tuple.getValue0(),tuple.getValue1()); } public Octet addAt0(final Triplet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Octet addAt1(final Triplet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Octet addAt2(final Triplet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Octet addAt3(final Triplet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Octet addAt4(final Triplet tuple) { return addAt4(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Octet addAt5(final Triplet tuple) { return addAt5(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Ennead addAt0(final Quartet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Ennead addAt1(final Quartet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Ennead addAt2(final Quartet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Ennead addAt3(final Quartet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Ennead addAt4(final Quartet tuple) { return addAt4(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Ennead addAt5(final Quartet tuple) { return addAt5(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Decade addAt0(final Quintet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Decade addAt1(final Quintet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Decade addAt2(final Quintet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Decade addAt3(final Quintet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Decade addAt4(final Quintet tuple) { return addAt4(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Decade addAt5(final Quintet tuple) { return addAt5(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Sextet add(final X0 value0) { return addAt5(value0); } public Sextet add(final Unit tuple) { return addAt5(tuple); } public Septet add(final X0 value0, final X1 value1) { return addAt5(value0, value1); } public Septet add(final Pair tuple) { return addAt5(tuple); } public Octet add(final X0 value0, final X1 value1, final X2 value2) { return addAt5(value0, value1, value2); } public Octet add(final Triplet tuple) { return addAt5(tuple); } public Ennead add(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return addAt5(value0, value1, value2, value3); } public Ennead add(final Quartet tuple) { return addAt5(tuple); } public Decade add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return addAt5(value0, value1, value2, value3, value4); } public Decade add(final Quintet tuple) { return addAt5(tuple); } public Quintet setAt0(final X value) { return new Quintet( value, this.val1, this.val2, this.val3, this.val4); } public Quintet setAt1(final X value) { return new Quintet( this.val0, value, this.val2, this.val3, this.val4); } public Quintet setAt2(final X value) { return new Quintet( this.val0, this.val1, value, this.val3, this.val4); } public Quintet setAt3(final X value) { return new Quintet( this.val0, this.val1, this.val2, value, this.val4); } public Quintet setAt4(final X value) { return new Quintet( this.val0, this.val1, this.val2, this.val3, value); } public Quartet removeFrom0() { return new Quartet( this.val1, this.val2, this.val3, this.val4); } public Quartet removeFrom1() { return new Quartet( this.val0, this.val2, this.val3, this.val4); } public Quartet removeFrom2() { return new Quartet( this.val0, this.val1, this.val3, this.val4); } public Quartet removeFrom3() { return new Quartet( this.val0, this.val1, this.val2, this.val4); } public Quartet removeFrom4() { return new Quartet( this.val0, this.val1, this.val2, this.val3); } } javatuples-javatuples-1.2/src/main/java/org/javatuples/Tuple.java0000644000175000017500000001527711646342650024570 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; /** *

* Abstract base class for all tuple classes. *

* * @since 1.0 * * @author Daniel Fernández * */ public abstract class Tuple implements Iterable, Serializable, Comparable { private static final long serialVersionUID = 5431085632328343101L; private final Object[] valueArray; private final List valueList; /** * * @deprecated Will be removed in 1.4. The "size" parameter is of no use at * this level, so use the simpler Tuple(values) constructor instead. */ @Deprecated protected Tuple(@SuppressWarnings("unused") final int size, final Object... values) { super(); this.valueArray = values; this.valueList = Arrays.asList(values); } protected Tuple(final Object... values) { super(); this.valueArray = values; this.valueList = Arrays.asList(values); } /** *

* Return the size of the tuple. *

* * @return the size of the tuple. */ public abstract int getSize(); /** *

* Get the value at a specific position in the tuple. This method * has to return object, so using it you will lose the type-safety you * get with the getValueX() methods. *

* * @param pos the position of the value to be retrieved. * @return the value */ public final Object getValue(final int pos) { if (pos >= getSize()) { throw new IllegalArgumentException( "Cannot retrieve position " + pos + " in " + this.getClass().getSimpleName() + ". Positions for this class start with 0 and end with " + (getSize() - 1)); } return this.valueArray[pos]; } public final Iterator iterator() { return this.valueList.iterator(); } @Override public final String toString() { return this.valueList.toString(); } public final boolean contains(final Object value) { for (final Object val : this.valueList) { if (val == null) { if (value == null) { return true; } } else { if (val.equals(value)) { return true; } } } return false; } public final boolean containsAll(final Collection collection) { for (final Object value : collection) { if (!contains(value)) { return false; } } return true; } public final boolean containsAll(final Object... values) { if (values == null) { throw new IllegalArgumentException("Values array cannot be null"); } for (final Object value : values) { if (!contains(value)) { return false; } } return true; } public final int indexOf(final Object value) { int i = 0; for (final Object val : this.valueList) { if (val == null) { if (value == null) { return i; } } else { if (val.equals(value)) { return i; } } i++; } return -1; } public final int lastIndexOf(final Object value) { for (int i = getSize() - 1; i >= 0; i--) { final Object val = this.valueList.get(i); if (val == null) { if (value == null) { return i; } } else { if (val.equals(value)) { return i; } } } return -1; } public final List toList() { return Collections.unmodifiableList(new ArrayList(this.valueList)); } public final Object[] toArray() { return this.valueArray.clone(); } @Override public final int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((this.valueList == null) ? 0 : this.valueList.hashCode()); return result; } @Override public final boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Tuple other = (Tuple) obj; return this.valueList.equals(other.valueList); } @SuppressWarnings({ "rawtypes", "unchecked" }) public int compareTo(final Tuple o) { final int tLen = this.valueArray.length; final Object[] oValues = o.valueArray; final int oLen = oValues.length; for (int i = 0; i < tLen && i < oLen; i++) { final Comparable tElement = (Comparable)this.valueArray[i]; final Comparable oElement = (Comparable)oValues[i]; final int comparison = tElement.compareTo(oElement); if (comparison != 0) { return comparison; } } return (Integer.valueOf(tLen)).compareTo(Integer.valueOf(oLen)); } } javatuples-javatuples-1.2/src/main/java/org/javatuples/KeyValue.java0000644000175000017500000001143411646342650025213 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.util.Collection; import java.util.Iterator; import org.javatuples.valueintf.IValueKey; import org.javatuples.valueintf.IValueValue; /** *

* A tuple of two elements, with positions 0 and 1 renamed as "key" and * "value", respectively. *

* * @since 1.0 * * @author Daniel Fernández * */ public final class KeyValue extends Tuple implements IValueKey, IValueValue { private static final long serialVersionUID = 3460957157833872509L; private static final int SIZE = 2; private final A key; private final B value; public static KeyValue with(final A key, final B value) { return new KeyValue(key,value); } /** *

* Create tuple from array. Array has to have exactly two elements. *

* * @param the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static KeyValue fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 2) { throw new IllegalArgumentException("Array must have exactly 2 elements in order to create a KeyValue. Size is " + array.length); } return new KeyValue(array[0],array[1]); } public static KeyValue fromCollection(final Collection collection) { return fromIterable(collection); } public static KeyValue fromIterable(final Iterable iterable) { return fromIterable(iterable, 0, true); } public static KeyValue fromIterable(final Iterable iterable, int index) { return fromIterable(iterable, index, false); } private static KeyValue fromIterable(final Iterable iterable, int index, final boolean exactSize) { if (iterable == null) { throw new IllegalArgumentException("Iterable cannot be null"); } boolean tooFewElements = false; X element0 = null; X element1 = null; final Iterator iter = iterable.iterator(); int i = 0; while (i < index) { if (iter.hasNext()) { iter.next(); } else { tooFewElements = true; } i++; } if (iter.hasNext()) { element0 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element1 = iter.next(); } else { tooFewElements = true; } if (tooFewElements && exactSize) { throw new IllegalArgumentException("Not enough elements for creating a KeyValue (2 needed)"); } if (iter.hasNext() && exactSize) { throw new IllegalArgumentException("Iterable must have exactly 2 available elements in order to create a KeyValue."); } return new KeyValue(element0, element1); } public KeyValue( final A key, final B value) { super(key, value); this.key = key; this.value = value; } public A getKey() { return this.key; } public B getValue() { return this.value; } @Override public int getSize() { return SIZE; } public KeyValue setKey(final X key) { return new KeyValue(key, this.value); } public KeyValue setValue(final Y value) { return new KeyValue(this.key, value); } } javatuples-javatuples-1.2/src/main/java/org/javatuples/Ennead.java0000644000175000017500000004162011646342650024660 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.util.Collection; import java.util.Iterator; import org.javatuples.valueintf.IValue0; import org.javatuples.valueintf.IValue1; import org.javatuples.valueintf.IValue2; import org.javatuples.valueintf.IValue3; import org.javatuples.valueintf.IValue4; import org.javatuples.valueintf.IValue5; import org.javatuples.valueintf.IValue6; import org.javatuples.valueintf.IValue7; import org.javatuples.valueintf.IValue8; /** *

* A tuple of nine elements. *

* * @since 1.0 * * @author Daniel Fernández * */ public final class Ennead extends Tuple implements IValue0
, IValue1, IValue2, IValue3, IValue4, IValue5, IValue6, IValue7, IValue8 { private static final long serialVersionUID = -4782141390960730966L; private static final int SIZE = 9; private final A val0; private final B val1; private final C val2; private final D val3; private final E val4; private final F val5; private final G val6; private final H val7; private final I val8; public static Ennead with(final A value0, final B value1, final C value2, final D value3, final E value4, final F value5, final G value6, final H value7, final I value8) { return new Ennead(value0,value1,value2,value3,value4,value5,value6,value7,value8); } /** *

* Create tuple from array. Array has to have exactly nine elements. *

* * @param the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static Ennead fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 9) { throw new IllegalArgumentException("Array must have exactly 9 elements in order to create an Ennead. Size is " + array.length); } return new Ennead( array[0],array[1],array[2],array[3],array[4], array[5],array[6],array[7],array[8]); } /** *

* Create tuple from collection. Collection has to have exactly nine elements. *

* * @param the collection component type * @param collection the collection to be converted to a tuple * @return the tuple */ public static Ennead fromCollection(final Collection collection) { return fromIterable(collection); } /** *

* Create tuple from iterable. Iterable has to have exactly nine elements. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Ennead fromIterable(final Iterable iterable) { return fromIterable(iterable, 0, true); } /** *

* Create tuple from iterable, starting from the specified index. Iterable * can have more (or less) elements than the tuple to be created. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Ennead fromIterable(final Iterable iterable, int index) { return fromIterable(iterable, index, false); } private static Ennead fromIterable(final Iterable iterable, int index, final boolean exactSize) { if (iterable == null) { throw new IllegalArgumentException("Iterable cannot be null"); } boolean tooFewElements = false; X element0 = null; X element1 = null; X element2 = null; X element3 = null; X element4 = null; X element5 = null; X element6 = null; X element7 = null; X element8 = null; final Iterator iter = iterable.iterator(); int i = 0; while (i < index) { if (iter.hasNext()) { iter.next(); } else { tooFewElements = true; } i++; } if (iter.hasNext()) { element0 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element1 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element2 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element3 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element4 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element5 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element6 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element7 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element8 = iter.next(); } else { tooFewElements = true; } if (tooFewElements && exactSize) { throw new IllegalArgumentException("Not enough elements for creating an Ennead (9 needed)"); } if (iter.hasNext() && exactSize) { throw new IllegalArgumentException("Iterable must have exactly 9 available elements in order to create an Ennead."); } return new Ennead( element0, element1, element2, element3, element4, element5, element6, element7, element8); } public Ennead( final A value0, final B value1, final C value2, final D value3, final E value4, final F value5, final G value6, final H value7, final I value8) { super(value0, value1, value2, value3, value4, value5, value6, value7, value8); this.val0 = value0; this.val1 = value1; this.val2 = value2; this.val3 = value3; this.val4 = value4; this.val5 = value5; this.val6 = value6; this.val7 = value7; this.val8 = value8; } public A getValue0() { return this.val0; } public B getValue1() { return this.val1; } public C getValue2() { return this.val2; } public D getValue3() { return this.val3; } public E getValue4() { return this.val4; } public F getValue5() { return this.val5; } public G getValue6() { return this.val6; } public H getValue7() { return this.val7; } public I getValue8() { return this.val8; } @Override public int getSize() { return SIZE; } public Decade addAt0(final X0 value0) { return new Decade( value0, this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8); } public Decade addAt1(final X0 value0) { return new Decade( this.val0, value0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8); } public Decade addAt2(final X0 value0) { return new Decade( this.val0, this.val1, value0, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8); } public Decade addAt3(final X0 value0) { return new Decade( this.val0, this.val1, this.val2, value0, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8); } public Decade addAt4(final X0 value0) { return new Decade( this.val0, this.val1, this.val2, this.val3, value0, this.val4, this.val5, this.val6, this.val7, this.val8); } public Decade addAt5(final X0 value0) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, value0, this.val5, this.val6, this.val7, this.val8); } public Decade addAt6(final X0 value0) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value0, this.val6, this.val7, this.val8); } public Decade addAt7(final X0 value0) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, value0, this.val7, this.val8); } public Decade addAt8(final X0 value0) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, value0, this.val8); } public Decade addAt9(final X0 value0) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8, value0); } public Decade addAt0(final Unit tuple) { return addAt0(tuple.getValue0()); } public Decade addAt1(final Unit tuple) { return addAt1(tuple.getValue0()); } public Decade addAt2(final Unit tuple) { return addAt2(tuple.getValue0()); } public Decade addAt3(final Unit tuple) { return addAt3(tuple.getValue0()); } public Decade addAt4(final Unit tuple) { return addAt4(tuple.getValue0()); } public Decade addAt5(final Unit tuple) { return addAt5(tuple.getValue0()); } public Decade addAt6(final Unit tuple) { return addAt6(tuple.getValue0()); } public Decade addAt7(final Unit tuple) { return addAt7(tuple.getValue0()); } public Decade addAt8(final Unit tuple) { return addAt8(tuple.getValue0()); } public Decade addAt9(final Unit tuple) { return addAt9(tuple.getValue0()); } public Decade add(final X0 value0) { return addAt9(value0); } public Decade add(final Unit tuple) { return addAt9(tuple); } public Ennead setAt0(final X value) { return new Ennead( value, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8); } public Ennead setAt1(final X value) { return new Ennead( this.val0, value, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8); } public Ennead setAt2(final X value) { return new Ennead( this.val0, this.val1, value, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8); } public Ennead setAt3(final X value) { return new Ennead( this.val0, this.val1, this.val2, value, this.val4, this.val5, this.val6, this.val7, this.val8); } public Ennead setAt4(final X value) { return new Ennead( this.val0, this.val1, this.val2, this.val3, value, this.val5, this.val6, this.val7, this.val8); } public Ennead setAt5(final X value) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, value, this.val6, this.val7, this.val8); } public Ennead setAt6(final X value) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value, this.val7, this.val8); } public Ennead setAt7(final X value) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, value, this.val8); } public Ennead setAt8(final X value) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, value); } public Octet removeFrom0() { return new Octet( this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8); } public Octet removeFrom1() { return new Octet( this.val0, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8); } public Octet removeFrom2() { return new Octet( this.val0, this.val1, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8); } public Octet removeFrom3() { return new Octet( this.val0, this.val1, this.val2, this.val4, this.val5, this.val6, this.val7, this.val8); } public Octet removeFrom4() { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val5, this.val6, this.val7, this.val8); } public Octet removeFrom5() { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val6, this.val7, this.val8); } public Octet removeFrom6() { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val7, this.val8); } public Octet removeFrom7() { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val8); } public Octet removeFrom8() { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7); } } javatuples-javatuples-1.2/src/main/java/org/javatuples/Octet.java0000644000175000017500000004713211646342650024550 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.util.Collection; import java.util.Iterator; import org.javatuples.valueintf.IValue0; import org.javatuples.valueintf.IValue1; import org.javatuples.valueintf.IValue2; import org.javatuples.valueintf.IValue3; import org.javatuples.valueintf.IValue4; import org.javatuples.valueintf.IValue5; import org.javatuples.valueintf.IValue6; import org.javatuples.valueintf.IValue7; /** *

* A tuple of eight elements. *

* * @since 1.0 * * @author Daniel Fernández * */ public final class Octet extends Tuple implements IValue0
, IValue1, IValue2, IValue3, IValue4, IValue5, IValue6, IValue7 { private static final long serialVersionUID = -1187955276020306879L; private static final int SIZE = 8; private final A val0; private final B val1; private final C val2; private final D val3; private final E val4; private final F val5; private final G val6; private final H val7; public static Octet with(final A value0, final B value1, final C value2, final D value3, final E value4, final F value5, final G value6, final H value7) { return new Octet(value0,value1,value2,value3,value4,value5,value6,value7); } /** *

* Create tuple from array. Array has to have exactly eight elements. *

* * @param the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static Octet fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 8) { throw new IllegalArgumentException("Array must have exactly 8 elements in order to create an Octet. Size is " + array.length); } return new Octet( array[0],array[1],array[2],array[3],array[4], array[5],array[6],array[7]); } /** *

* Create tuple from collection. Collection has to have exactly eight elements. *

* * @param the collection component type * @param collection the collection to be converted to a tuple * @return the tuple */ public static Octet fromCollection(final Collection collection) { return fromIterable(collection); } /** *

* Create tuple from iterable. Iterable has to have exactly eight elements. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Octet fromIterable(final Iterable iterable) { return fromIterable(iterable, 0, true); } /** *

* Create tuple from iterable, starting from the specified index. Iterable * can have more (or less) elements than the tuple to be created. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Octet fromIterable(final Iterable iterable, int index) { return fromIterable(iterable, index, false); } private static Octet fromIterable(final Iterable iterable, int index, final boolean exactSize) { if (iterable == null) { throw new IllegalArgumentException("Iterable cannot be null"); } boolean tooFewElements = false; X element0 = null; X element1 = null; X element2 = null; X element3 = null; X element4 = null; X element5 = null; X element6 = null; X element7 = null; final Iterator iter = iterable.iterator(); int i = 0; while (i < index) { if (iter.hasNext()) { iter.next(); } else { tooFewElements = true; } i++; } if (iter.hasNext()) { element0 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element1 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element2 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element3 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element4 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element5 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element6 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element7 = iter.next(); } else { tooFewElements = true; } if (tooFewElements && exactSize) { throw new IllegalArgumentException("Not enough elements for creating an Octet (8 needed)"); } if (iter.hasNext() && exactSize) { throw new IllegalArgumentException("Iterable must have exactly 8 available elements in order to create an Octet."); } return new Octet( element0, element1, element2, element3, element4, element5, element6, element7); } public Octet( final A value0, final B value1, final C value2, final D value3, final E value4, final F value5, final G value6, final H value7) { super(value0, value1, value2, value3, value4, value5, value6, value7); this.val0 = value0; this.val1 = value1; this.val2 = value2; this.val3 = value3; this.val4 = value4; this.val5 = value5; this.val6 = value6; this.val7 = value7; } public A getValue0() { return this.val0; } public B getValue1() { return this.val1; } public C getValue2() { return this.val2; } public D getValue3() { return this.val3; } public E getValue4() { return this.val4; } public F getValue5() { return this.val5; } public G getValue6() { return this.val6; } public H getValue7() { return this.val7; } @Override public int getSize() { return SIZE; } public Ennead addAt0(final X0 value0) { return new Ennead( value0, this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7); } public Ennead addAt1(final X0 value0) { return new Ennead( this.val0, value0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7); } public Ennead addAt2(final X0 value0) { return new Ennead( this.val0, this.val1, value0, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7); } public Ennead addAt3(final X0 value0) { return new Ennead( this.val0, this.val1, this.val2, value0, this.val3, this.val4, this.val5, this.val6, this.val7); } public Ennead addAt4(final X0 value0) { return new Ennead( this.val0, this.val1, this.val2, this.val3, value0, this.val4, this.val5, this.val6, this.val7); } public Ennead addAt5(final X0 value0) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, value0, this.val5, this.val6, this.val7); } public Ennead addAt6(final X0 value0) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value0, this.val6, this.val7); } public Ennead addAt7(final X0 value0) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, value0, this.val7); } public Ennead addAt8(final X0 value0) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, value0); } public Decade addAt0(final X0 value0, final X1 value1) { return new Decade( value0, value1, this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7); } public Decade addAt1(final X0 value0, final X1 value1) { return new Decade( this.val0, value0, value1, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7); } public Decade addAt2(final X0 value0, final X1 value1) { return new Decade( this.val0, this.val1, value0, value1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7); } public Decade addAt3(final X0 value0, final X1 value1) { return new Decade( this.val0, this.val1, this.val2, value0, value1, this.val3, this.val4, this.val5, this.val6, this.val7); } public Decade addAt4(final X0 value0, final X1 value1) { return new Decade( this.val0, this.val1, this.val2, this.val3, value0, value1, this.val4, this.val5, this.val6, this.val7); } public Decade addAt5(final X0 value0, final X1 value1) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1, this.val5, this.val6, this.val7); } public Decade addAt6(final X0 value0, final X1 value1) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value0, value1, this.val6, this.val7); } public Decade addAt7(final X0 value0, final X1 value1) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, value0, value1, this.val7); } public Decade addAt8(final X0 value0, final X1 value1) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, value0, value1); } public Ennead addAt0(final Unit tuple) { return addAt0(tuple.getValue0()); } public Ennead addAt1(final Unit tuple) { return addAt1(tuple.getValue0()); } public Ennead addAt2(final Unit tuple) { return addAt2(tuple.getValue0()); } public Ennead addAt3(final Unit tuple) { return addAt3(tuple.getValue0()); } public Ennead addAt4(final Unit tuple) { return addAt4(tuple.getValue0()); } public Ennead addAt5(final Unit tuple) { return addAt5(tuple.getValue0()); } public Ennead addAt6(final Unit tuple) { return addAt6(tuple.getValue0()); } public Ennead addAt7(final Unit tuple) { return addAt7(tuple.getValue0()); } public Ennead addAt8(final Unit tuple) { return addAt8(tuple.getValue0()); } public Decade addAt0(final Pair tuple) { return addAt0(tuple.getValue0(),tuple.getValue1()); } public Decade addAt1(final Pair tuple) { return addAt1(tuple.getValue0(),tuple.getValue1()); } public Decade addAt2(final Pair tuple) { return addAt2(tuple.getValue0(),tuple.getValue1()); } public Decade addAt3(final Pair tuple) { return addAt3(tuple.getValue0(),tuple.getValue1()); } public Decade addAt4(final Pair tuple) { return addAt4(tuple.getValue0(),tuple.getValue1()); } public Decade addAt5(final Pair tuple) { return addAt5(tuple.getValue0(),tuple.getValue1()); } public Decade addAt6(final Pair tuple) { return addAt6(tuple.getValue0(),tuple.getValue1()); } public Decade addAt7(final Pair tuple) { return addAt7(tuple.getValue0(),tuple.getValue1()); } public Decade addAt8(final Pair tuple) { return addAt8(tuple.getValue0(),tuple.getValue1()); } public Ennead add(final X0 value0) { return addAt8(value0); } public Ennead add(final Unit tuple) { return addAt8(tuple); } public Decade add(final X0 value0, final X1 value1) { return addAt8(value0, value1); } public Decade add(final Pair tuple) { return addAt8(tuple); } public Octet setAt0(final X value) { return new Octet( value, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7); } public Octet setAt1(final X value) { return new Octet( this.val0, value, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7); } public Octet setAt2(final X value) { return new Octet( this.val0, this.val1, value, this.val3, this.val4, this.val5, this.val6, this.val7); } public Octet setAt3(final X value) { return new Octet( this.val0, this.val1, this.val2, value, this.val4, this.val5, this.val6, this.val7); } public Octet setAt4(final X value) { return new Octet( this.val0, this.val1, this.val2, this.val3, value, this.val5, this.val6, this.val7); } public Octet setAt5(final X value) { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val4, value, this.val6, this.val7); } public Octet setAt6(final X value) { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value, this.val7); } public Octet setAt7(final X value) { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, value); } public Septet removeFrom0() { return new Septet( this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7); } public Septet removeFrom1() { return new Septet( this.val0, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7); } public Septet removeFrom2() { return new Septet( this.val0, this.val1, this.val3, this.val4, this.val5, this.val6, this.val7); } public Septet removeFrom3() { return new Septet( this.val0, this.val1, this.val2, this.val4, this.val5, this.val6, this.val7); } public Septet removeFrom4() { return new Septet( this.val0, this.val1, this.val2, this.val3, this.val5, this.val6, this.val7); } public Septet removeFrom5() { return new Septet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val6, this.val7); } public Septet removeFrom6() { return new Septet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val7); } public Septet removeFrom7() { return new Septet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6); } } javatuples-javatuples-1.2/src/main/java/org/javatuples/Sextet.java0000644000175000017500000005540611646342650024751 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.util.Collection; import java.util.Iterator; import org.javatuples.valueintf.IValue0; import org.javatuples.valueintf.IValue1; import org.javatuples.valueintf.IValue2; import org.javatuples.valueintf.IValue3; import org.javatuples.valueintf.IValue4; import org.javatuples.valueintf.IValue5; /** *

* A tuple of six elements. *

* * @since 1.0 * * @author Daniel Fernández * */ public final class Sextet extends Tuple implements IValue0
, IValue1, IValue2, IValue3, IValue4, IValue5 { private static final long serialVersionUID = -367678052827219823L; private static final int SIZE = 6; private final A val0; private final B val1; private final C val2; private final D val3; private final E val4; private final F val5; public static Sextet with(final A value0, final B value1, final C value2, final D value3, final E value4, final F value5) { return new Sextet(value0,value1,value2,value3,value4,value5); } /** *

* Create tuple from array. Array has to have exactly six elements. *

* * @param the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static Sextet fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 6) { throw new IllegalArgumentException("Array must have exactly 6 elements in order to create a Sextet. Size is " + array.length); } return new Sextet( array[0],array[1],array[2],array[3],array[4], array[5]); } /** *

* Create tuple from collection. Collection has to have exactly six elements. *

* * @param the collection component type * @param collection the collection to be converted to a tuple * @return the tuple */ public static Sextet fromCollection(final Collection collection) { return fromIterable(collection); } /** *

* Create tuple from iterable. Iterable has to have exactly six elements. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Sextet fromIterable(final Iterable iterable) { return fromIterable(iterable, 0, true); } /** *

* Create tuple from iterable, starting from the specified index. Iterable * can have more (or less) elements than the tuple to be created. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Sextet fromIterable(final Iterable iterable, int index) { return fromIterable(iterable, index, false); } private static Sextet fromIterable(final Iterable iterable, int index, final boolean exactSize) { if (iterable == null) { throw new IllegalArgumentException("Iterable cannot be null"); } boolean tooFewElements = false; X element0 = null; X element1 = null; X element2 = null; X element3 = null; X element4 = null; X element5 = null; final Iterator iter = iterable.iterator(); int i = 0; while (i < index) { if (iter.hasNext()) { iter.next(); } else { tooFewElements = true; } i++; } if (iter.hasNext()) { element0 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element1 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element2 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element3 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element4 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element5 = iter.next(); } else { tooFewElements = true; } if (tooFewElements && exactSize) { throw new IllegalArgumentException("Not enough elements for creating a Sextet (6 needed)"); } if (iter.hasNext() && exactSize) { throw new IllegalArgumentException("Iterable must have exactly 6 available elements in order to create a Sextet."); } return new Sextet( element0, element1, element2, element3, element4, element5); } public Sextet( final A value0, final B value1, final C value2, final D value3, final E value4, final F value5) { super(value0, value1, value2, value3, value4, value5); this.val0 = value0; this.val1 = value1; this.val2 = value2; this.val3 = value3; this.val4 = value4; this.val5 = value5; } public A getValue0() { return this.val0; } public B getValue1() { return this.val1; } public C getValue2() { return this.val2; } public D getValue3() { return this.val3; } public E getValue4() { return this.val4; } public F getValue5() { return this.val5; } @Override public int getSize() { return SIZE; } public Septet addAt0(final X0 value0) { return new Septet( value0, this.val0, this.val1, this.val2, this.val3, this.val4, this.val5); } public Septet addAt1(final X0 value0) { return new Septet( this.val0, value0, this.val1, this.val2, this.val3, this.val4, this.val5); } public Septet addAt2(final X0 value0) { return new Septet( this.val0, this.val1, value0, this.val2, this.val3, this.val4, this.val5); } public Septet addAt3(final X0 value0) { return new Septet( this.val0, this.val1, this.val2, value0, this.val3, this.val4, this.val5); } public Septet addAt4(final X0 value0) { return new Septet( this.val0, this.val1, this.val2, this.val3, value0, this.val4, this.val5); } public Septet addAt5(final X0 value0) { return new Septet( this.val0, this.val1, this.val2, this.val3, this.val4, value0, this.val5); } public Septet addAt6(final X0 value0) { return new Septet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value0); } public Octet addAt0(final X0 value0, final X1 value1) { return new Octet( value0, value1, this.val0, this.val1, this.val2, this.val3, this.val4, this.val5); } public Octet addAt1(final X0 value0, final X1 value1) { return new Octet( this.val0, value0, value1, this.val1, this.val2, this.val3, this.val4, this.val5); } public Octet addAt2(final X0 value0, final X1 value1) { return new Octet( this.val0, this.val1, value0, value1, this.val2, this.val3, this.val4, this.val5); } public Octet addAt3(final X0 value0, final X1 value1) { return new Octet( this.val0, this.val1, this.val2, value0, value1, this.val3, this.val4, this.val5); } public Octet addAt4(final X0 value0, final X1 value1) { return new Octet( this.val0, this.val1, this.val2, this.val3, value0, value1, this.val4, this.val5); } public Octet addAt5(final X0 value0, final X1 value1) { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1, this.val5); } public Octet addAt6(final X0 value0, final X1 value1) { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value0, value1); } public Ennead addAt0(final X0 value0, final X1 value1, final X2 value2) { return new Ennead( value0, value1, value2, this.val0, this.val1, this.val2, this.val3, this.val4, this.val5); } public Ennead addAt1(final X0 value0, final X1 value1, final X2 value2) { return new Ennead( this.val0, value0, value1, value2, this.val1, this.val2, this.val3, this.val4, this.val5); } public Ennead addAt2(final X0 value0, final X1 value1, final X2 value2) { return new Ennead( this.val0, this.val1, value0, value1, value2, this.val2, this.val3, this.val4, this.val5); } public Ennead addAt3(final X0 value0, final X1 value1, final X2 value2) { return new Ennead( this.val0, this.val1, this.val2, value0, value1, value2, this.val3, this.val4, this.val5); } public Ennead addAt4(final X0 value0, final X1 value1, final X2 value2) { return new Ennead( this.val0, this.val1, this.val2, this.val3, value0, value1, value2, this.val4, this.val5); } public Ennead addAt5(final X0 value0, final X1 value1, final X2 value2) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1, value2, this.val5); } public Ennead addAt6(final X0 value0, final X1 value1, final X2 value2) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value0, value1, value2); } public Decade addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Decade( value0, value1, value2, value3, this.val0, this.val1, this.val2, this.val3, this.val4, this.val5); } public Decade addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Decade( this.val0, value0, value1, value2, value3, this.val1, this.val2, this.val3, this.val4, this.val5); } public Decade addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Decade( this.val0, this.val1, value0, value1, value2, value3, this.val2, this.val3, this.val4, this.val5); } public Decade addAt3(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Decade( this.val0, this.val1, this.val2, value0, value1, value2, value3, this.val3, this.val4, this.val5); } public Decade addAt4(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Decade( this.val0, this.val1, this.val2, this.val3, value0, value1, value2, value3, this.val4, this.val5); } public Decade addAt5(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1, value2, value3, this.val5); } public Decade addAt6(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value0, value1, value2, value3); } public Septet addAt0(final Unit tuple) { return addAt0(tuple.getValue0()); } public Septet addAt1(final Unit tuple) { return addAt1(tuple.getValue0()); } public Septet addAt2(final Unit tuple) { return addAt2(tuple.getValue0()); } public Septet addAt3(final Unit tuple) { return addAt3(tuple.getValue0()); } public Septet addAt4(final Unit tuple) { return addAt4(tuple.getValue0()); } public Septet addAt5(final Unit tuple) { return addAt5(tuple.getValue0()); } public Septet addAt6(final Unit tuple) { return addAt6(tuple.getValue0()); } public Octet addAt0(final Pair tuple) { return addAt0(tuple.getValue0(),tuple.getValue1()); } public Octet addAt1(final Pair tuple) { return addAt1(tuple.getValue0(),tuple.getValue1()); } public Octet addAt2(final Pair tuple) { return addAt2(tuple.getValue0(),tuple.getValue1()); } public Octet addAt3(final Pair tuple) { return addAt3(tuple.getValue0(),tuple.getValue1()); } public Octet addAt4(final Pair tuple) { return addAt4(tuple.getValue0(),tuple.getValue1()); } public Octet addAt5(final Pair tuple) { return addAt5(tuple.getValue0(),tuple.getValue1()); } public Octet addAt6(final Pair tuple) { return addAt6(tuple.getValue0(),tuple.getValue1()); } public Ennead addAt0(final Triplet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Ennead addAt1(final Triplet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Ennead addAt2(final Triplet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Ennead addAt3(final Triplet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Ennead addAt4(final Triplet tuple) { return addAt4(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Ennead addAt5(final Triplet tuple) { return addAt5(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Ennead addAt6(final Triplet tuple) { return addAt6(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Decade addAt0(final Quartet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Decade addAt1(final Quartet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Decade addAt2(final Quartet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Decade addAt3(final Quartet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Decade addAt4(final Quartet tuple) { return addAt4(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Decade addAt5(final Quartet tuple) { return addAt5(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Decade addAt6(final Quartet tuple) { return addAt6(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Septet add(final X0 value0) { return addAt6(value0); } public Septet add(final Unit tuple) { return addAt6(tuple); } public Octet add(final X0 value0, final X1 value1) { return addAt6(value0, value1); } public Octet add(final Pair tuple) { return addAt6(tuple); } public Ennead add(final X0 value0, final X1 value1, final X2 value2) { return addAt6(value0, value1, value2); } public Ennead add(final Triplet tuple) { return addAt6(tuple); } public Decade add(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return addAt6(value0, value1, value2, value3); } public Decade add(final Quartet tuple) { return addAt6(tuple); } public Sextet setAt0(final X value) { return new Sextet( value, this.val1, this.val2, this.val3, this.val4, this.val5); } public Sextet setAt1(final X value) { return new Sextet( this.val0, value, this.val2, this.val3, this.val4, this.val5); } public Sextet setAt2(final X value) { return new Sextet( this.val0, this.val1, value, this.val3, this.val4, this.val5); } public Sextet setAt3(final X value) { return new Sextet( this.val0, this.val1, this.val2, value, this.val4, this.val5); } public Sextet setAt4(final X value) { return new Sextet( this.val0, this.val1, this.val2, this.val3, value, this.val5); } public Sextet setAt5(final X value) { return new Sextet( this.val0, this.val1, this.val2, this.val3, this.val4, value); } public Quintet removeFrom0() { return new Quintet( this.val1, this.val2, this.val3, this.val4, this.val5); } public Quintet removeFrom1() { return new Quintet( this.val0, this.val2, this.val3, this.val4, this.val5); } public Quintet removeFrom2() { return new Quintet( this.val0, this.val1, this.val3, this.val4, this.val5); } public Quintet removeFrom3() { return new Quintet( this.val0, this.val1, this.val2, this.val4, this.val5); } public Quintet removeFrom4() { return new Quintet( this.val0, this.val1, this.val2, this.val3, this.val5); } public Quintet removeFrom5() { return new Quintet( this.val0, this.val1, this.val2, this.val3, this.val4); } } javatuples-javatuples-1.2/src/main/java/org/javatuples/Decade.java0000644000175000017500000003347711646342650024646 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.util.Collection; import java.util.Iterator; import org.javatuples.valueintf.IValue0; import org.javatuples.valueintf.IValue1; import org.javatuples.valueintf.IValue2; import org.javatuples.valueintf.IValue3; import org.javatuples.valueintf.IValue4; import org.javatuples.valueintf.IValue5; import org.javatuples.valueintf.IValue6; import org.javatuples.valueintf.IValue7; import org.javatuples.valueintf.IValue8; import org.javatuples.valueintf.IValue9; /** *

* A tuple of ten elements. *

* * @since 1.0 * * @author Daniel Fernández * */ public final class Decade extends Tuple implements IValue0
, IValue1, IValue2, IValue3, IValue4, IValue5, IValue6, IValue7, IValue8, IValue9 { private static final long serialVersionUID = -1607420937567707033L; private static final int SIZE = 10; private final A val0; private final B val1; private final C val2; private final D val3; private final E val4; private final F val5; private final G val6; private final H val7; private final I val8; private final J val9; public static Decade with(final A value0, final B value1, final C value2, final D value3, final E value4, final F value5, final G value6, final H value7, final I value8, final J value9) { return new Decade(value0,value1,value2,value3,value4,value5,value6,value7,value8,value9); } /** *

* Create tuple from array. Array has to have exactly ten elements. *

* * @param the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static Decade fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 10) { throw new IllegalArgumentException("Array must have exactly 10 elements in order to create a Decade. Size is " + array.length); } return new Decade( array[0],array[1],array[2],array[3],array[4], array[5],array[6],array[7],array[8],array[9]); } /** *

* Create tuple from collection. Collection has to have exactly ten elements. *

* * @param the collection component type * @param collection the collection to be converted to a tuple * @return the tuple */ public static Decade fromCollection(final Collection collection) { return fromIterable(collection); } /** *

* Create tuple from iterable. Iterable has to have exactly ten elements. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Decade fromIterable(final Iterable iterable) { return fromIterable(iterable, 0, true); } /** *

* Create tuple from iterable, starting from the specified index. Iterable * can have more (or less) elements than the tuple to be created. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Decade fromIterable(final Iterable iterable, int index) { return fromIterable(iterable, index, false); } private static Decade fromIterable(final Iterable iterable, int index, final boolean exactSize) { if (iterable == null) { throw new IllegalArgumentException("Iterable cannot be null"); } boolean tooFewElements = false; X element0 = null; X element1 = null; X element2 = null; X element3 = null; X element4 = null; X element5 = null; X element6 = null; X element7 = null; X element8 = null; X element9 = null; final Iterator iter = iterable.iterator(); int i = 0; while (i < index) { if (iter.hasNext()) { iter.next(); } else { tooFewElements = true; } i++; } if (iter.hasNext()) { element0 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element1 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element2 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element3 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element4 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element5 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element6 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element7 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element8 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element9 = iter.next(); } else { tooFewElements = true; } if (tooFewElements && exactSize) { throw new IllegalArgumentException("Not enough elements for creating a Decade (10 needed)"); } if (iter.hasNext() && exactSize) { throw new IllegalArgumentException("Iterable must have exactly 10 available elements in order to create a Decade."); } return new Decade( element0, element1, element2, element3, element4, element5, element6, element7, element8, element9); } public Decade( final A value0, final B value1, final C value2, final D value3, final E value4, final F value5, final G value6, final H value7, final I value8, final J value9) { super(value0, value1, value2, value3, value4, value5, value6, value7, value8, value9); this.val0 = value0; this.val1 = value1; this.val2 = value2; this.val3 = value3; this.val4 = value4; this.val5 = value5; this.val6 = value6; this.val7 = value7; this.val8 = value8; this.val9 = value9; } public A getValue0() { return this.val0; } public B getValue1() { return this.val1; } public C getValue2() { return this.val2; } public D getValue3() { return this.val3; } public E getValue4() { return this.val4; } public F getValue5() { return this.val5; } public G getValue6() { return this.val6; } public H getValue7() { return this.val7; } public I getValue8() { return this.val8; } public J getValue9() { return this.val9; } @Override public int getSize() { return SIZE; } public Decade setAt0(final X value) { return new Decade( value, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8, this.val9); } public Decade setAt1(final X value) { return new Decade( this.val0, value, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8, this.val9); } public Decade setAt2(final X value) { return new Decade( this.val0, this.val1, value, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8, this.val9); } public Decade setAt3(final X value) { return new Decade( this.val0, this.val1, this.val2, value, this.val4, this.val5, this.val6, this.val7, this.val8, this.val9); } public Decade setAt4(final X value) { return new Decade( this.val0, this.val1, this.val2, this.val3, value, this.val5, this.val6, this.val7, this.val8, this.val9); } public Decade setAt5(final X value) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, value, this.val6, this.val7, this.val8, this.val9); } public Decade setAt6(final X value) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value, this.val7, this.val8, this.val9); } public Decade setAt7(final X value) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, value, this.val8, this.val9); } public Decade setAt8(final X value) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, value, this.val9); } public Decade setAt9(final X value) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8, value); } public Ennead removeFrom0() { return new Ennead( this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8, this.val9); } public Ennead removeFrom1() { return new Ennead( this.val0, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8, this.val9); } public Ennead removeFrom2() { return new Ennead( this.val0, this.val1, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8, this.val9); } public Ennead removeFrom3() { return new Ennead( this.val0, this.val1, this.val2, this.val4, this.val5, this.val6, this.val7, this.val8, this.val9); } public Ennead removeFrom4() { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val5, this.val6, this.val7, this.val8, this.val9); } public Ennead removeFrom5() { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val6, this.val7, this.val8, this.val9); } public Ennead removeFrom6() { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val7, this.val8, this.val9); } public Ennead removeFrom7() { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val8, this.val9); } public Ennead removeFrom8() { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val9); } public Ennead removeFrom9() { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, this.val7, this.val8); } } javatuples-javatuples-1.2/src/main/java/org/javatuples/LabelValue.java0000644000175000017500000001154711646342650025507 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.util.Collection; import java.util.Iterator; import org.javatuples.valueintf.IValueLabel; import org.javatuples.valueintf.IValueValue; /** *

* A tuple of two elements, with positions 0 and 1 renamed as "label" and * "value", respectively. *

* * @since 1.0 * * @author Daniel Fernández * */ public final class LabelValue extends Tuple implements IValueLabel
, IValueValue { private static final long serialVersionUID = 5055574980300695706L; private static final int SIZE = 2; private final A label; private final B value; public static LabelValue with(final A label, final B value) { return new LabelValue(label,value); } /** *

* Create tuple from array. Array has to have exactly two elements. *

* * @param the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static LabelValue fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 2) { throw new IllegalArgumentException("Array must have exactly 2 elements in order to create a LabelValue. Size is " + array.length); } return new LabelValue(array[0],array[1]); } public static LabelValue fromCollection(final Collection collection) { return fromIterable(collection); } public static LabelValue fromIterable(final Iterable iterable) { return fromIterable(iterable, 0, true); } public static LabelValue fromIterable(final Iterable iterable, int index) { return fromIterable(iterable, index, false); } private static LabelValue fromIterable(final Iterable iterable, int index, final boolean exactSize) { if (iterable == null) { throw new IllegalArgumentException("Iterable cannot be null"); } boolean tooFewElements = false; X element0 = null; X element1 = null; final Iterator iter = iterable.iterator(); int i = 0; while (i < index) { if (iter.hasNext()) { iter.next(); } else { tooFewElements = true; } i++; } if (iter.hasNext()) { element0 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element1 = iter.next(); } else { tooFewElements = true; } if (tooFewElements && exactSize) { throw new IllegalArgumentException("Not enough elements for creating a LabelValue (2 needed)"); } if (iter.hasNext() && exactSize) { throw new IllegalArgumentException("Iterable must have exactly 2 available elements in order to create a LabelValue."); } return new LabelValue(element0, element1); } public LabelValue( final A label, final B value) { super(label, value); this.label = label; this.value = value; } public A getLabel() { return this.label; } public B getValue() { return this.value; } @Override public int getSize() { return SIZE; } public LabelValue setLabel(final X label) { return new LabelValue(label, this.value); } public LabelValue setValue(final Y value) { return new LabelValue(this.label, value); } } javatuples-javatuples-1.2/src/main/java/org/javatuples/Septet.java0000644000175000017500000005336311646342650024741 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.util.Collection; import java.util.Iterator; import org.javatuples.valueintf.IValue0; import org.javatuples.valueintf.IValue1; import org.javatuples.valueintf.IValue2; import org.javatuples.valueintf.IValue3; import org.javatuples.valueintf.IValue4; import org.javatuples.valueintf.IValue5; import org.javatuples.valueintf.IValue6; /** *

* A tuple of seven elements. *

* * @since 1.0 * * @author Daniel Fernández * */ public final class Septet extends Tuple implements IValue0
, IValue1, IValue2, IValue3, IValue4, IValue5, IValue6 { private static final long serialVersionUID = -2133846648934305169L; private static final int SIZE = 7; private final A val0; private final B val1; private final C val2; private final D val3; private final E val4; private final F val5; private final G val6; public static Septet with(final A value0, final B value1, final C value2, final D value3, final E value4, final F value5, final G value6) { return new Septet(value0,value1,value2,value3,value4,value5,value6); } /** *

* Create tuple from array. Array has to have exactly seven elements. *

* * @param the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static Septet fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 7) { throw new IllegalArgumentException("Array must have exactly 7 elements in order to create a Septet. Size is " + array.length); } return new Septet( array[0],array[1],array[2],array[3],array[4], array[5],array[6]); } /** *

* Create tuple from collection. Collection has to have exactly seven elements. *

* * @param the collection component type * @param collection the collection to be converted to a tuple * @return the tuple */ public static Septet fromCollection(final Collection collection) { return fromIterable(collection); } /** *

* Create tuple from iterable. Iterable has to have exactly seven elements. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Septet fromIterable(final Iterable iterable) { return fromIterable(iterable, 0, true); } /** *

* Create tuple from iterable, starting from the specified index. Iterable * can have more (or less) elements than the tuple to be created. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Septet fromIterable(final Iterable iterable, int index) { return fromIterable(iterable, index, false); } private static Septet fromIterable(final Iterable iterable, int index, final boolean exactSize) { if (iterable == null) { throw new IllegalArgumentException("Iterable cannot be null"); } boolean tooFewElements = false; X element0 = null; X element1 = null; X element2 = null; X element3 = null; X element4 = null; X element5 = null; X element6 = null; final Iterator iter = iterable.iterator(); int i = 0; while (i < index) { if (iter.hasNext()) { iter.next(); } else { tooFewElements = true; } i++; } if (iter.hasNext()) { element0 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element1 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element2 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element3 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element4 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element5 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element6 = iter.next(); } else { tooFewElements = true; } if (tooFewElements && exactSize) { throw new IllegalArgumentException("Not enough elements for creating a Septet (7 needed)"); } if (iter.hasNext() && exactSize) { throw new IllegalArgumentException("Iterable must have exactly 7 available elements in order to create a Septet."); } return new Septet( element0, element1, element2, element3, element4, element5, element6); } public Septet( final A value0, final B value1, final C value2, final D value3, final E value4, final F value5, final G value6) { super(value0, value1, value2, value3, value4, value5, value6); this.val0 = value0; this.val1 = value1; this.val2 = value2; this.val3 = value3; this.val4 = value4; this.val5 = value5; this.val6 = value6; } public A getValue0() { return this.val0; } public B getValue1() { return this.val1; } public C getValue2() { return this.val2; } public D getValue3() { return this.val3; } public E getValue4() { return this.val4; } public F getValue5() { return this.val5; } public G getValue6() { return this.val6; } @Override public int getSize() { return SIZE; } public Octet addAt0(final X0 value0) { return new Octet( value0, this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6); } public Octet addAt1(final X0 value0) { return new Octet( this.val0, value0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6); } public Octet addAt2(final X0 value0) { return new Octet( this.val0, this.val1, value0, this.val2, this.val3, this.val4, this.val5, this.val6); } public Octet addAt3(final X0 value0) { return new Octet( this.val0, this.val1, this.val2, value0, this.val3, this.val4, this.val5, this.val6); } public Octet addAt4(final X0 value0) { return new Octet( this.val0, this.val1, this.val2, this.val3, value0, this.val4, this.val5, this.val6); } public Octet addAt5(final X0 value0) { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val4, value0, this.val5, this.val6); } public Octet addAt6(final X0 value0) { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value0, this.val6); } public Octet addAt7(final X0 value0) { return new Octet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, value0); } public Ennead addAt0(final X0 value0, final X1 value1) { return new Ennead( value0, value1, this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6); } public Ennead addAt1(final X0 value0, final X1 value1) { return new Ennead( this.val0, value0, value1, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6); } public Ennead addAt2(final X0 value0, final X1 value1) { return new Ennead( this.val0, this.val1, value0, value1, this.val2, this.val3, this.val4, this.val5, this.val6); } public Ennead addAt3(final X0 value0, final X1 value1) { return new Ennead( this.val0, this.val1, this.val2, value0, value1, this.val3, this.val4, this.val5, this.val6); } public Ennead addAt4(final X0 value0, final X1 value1) { return new Ennead( this.val0, this.val1, this.val2, this.val3, value0, value1, this.val4, this.val5, this.val6); } public Ennead addAt5(final X0 value0, final X1 value1) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1, this.val5, this.val6); } public Ennead addAt6(final X0 value0, final X1 value1) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value0, value1, this.val6); } public Ennead addAt7(final X0 value0, final X1 value1) { return new Ennead( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, value0, value1); } public Decade addAt0(final X0 value0, final X1 value1, final X2 value2) { return new Decade( value0, value1, value2, this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6); } public Decade addAt1(final X0 value0, final X1 value1, final X2 value2) { return new Decade( this.val0, value0, value1, value2, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6); } public Decade addAt2(final X0 value0, final X1 value1, final X2 value2) { return new Decade( this.val0, this.val1, value0, value1, value2, this.val2, this.val3, this.val4, this.val5, this.val6); } public Decade addAt3(final X0 value0, final X1 value1, final X2 value2) { return new Decade( this.val0, this.val1, this.val2, value0, value1, value2, this.val3, this.val4, this.val5, this.val6); } public Decade addAt4(final X0 value0, final X1 value1, final X2 value2) { return new Decade( this.val0, this.val1, this.val2, this.val3, value0, value1, value2, this.val4, this.val5, this.val6); } public Decade addAt5(final X0 value0, final X1 value1, final X2 value2) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, value0, value1, value2, this.val5, this.val6); } public Decade addAt6(final X0 value0, final X1 value1, final X2 value2) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value0, value1, value2, this.val6); } public Decade addAt7(final X0 value0, final X1 value1, final X2 value2) { return new Decade( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6, value0, value1, value2); } public Octet addAt0(final Unit tuple) { return addAt0(tuple.getValue0()); } public Octet addAt1(final Unit tuple) { return addAt1(tuple.getValue0()); } public Octet addAt2(final Unit tuple) { return addAt2(tuple.getValue0()); } public Octet addAt3(final Unit tuple) { return addAt3(tuple.getValue0()); } public Octet addAt4(final Unit tuple) { return addAt4(tuple.getValue0()); } public Octet addAt5(final Unit tuple) { return addAt5(tuple.getValue0()); } public Octet addAt6(final Unit tuple) { return addAt6(tuple.getValue0()); } public Octet addAt7(final Unit tuple) { return addAt7(tuple.getValue0()); } public Ennead addAt0(final Pair tuple) { return addAt0(tuple.getValue0(),tuple.getValue1()); } public Ennead addAt1(final Pair tuple) { return addAt1(tuple.getValue0(),tuple.getValue1()); } public Ennead addAt2(final Pair tuple) { return addAt2(tuple.getValue0(),tuple.getValue1()); } public Ennead addAt3(final Pair tuple) { return addAt3(tuple.getValue0(),tuple.getValue1()); } public Ennead addAt4(final Pair tuple) { return addAt4(tuple.getValue0(),tuple.getValue1()); } public Ennead addAt5(final Pair tuple) { return addAt5(tuple.getValue0(),tuple.getValue1()); } public Ennead addAt6(final Pair tuple) { return addAt6(tuple.getValue0(),tuple.getValue1()); } public Ennead addAt7(final Pair tuple) { return addAt7(tuple.getValue0(),tuple.getValue1()); } public Decade addAt0(final Triplet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Decade addAt1(final Triplet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Decade addAt2(final Triplet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Decade addAt3(final Triplet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Decade addAt4(final Triplet tuple) { return addAt4(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Decade addAt5(final Triplet tuple) { return addAt5(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Decade addAt6(final Triplet tuple) { return addAt6(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Decade addAt7(final Triplet tuple) { return addAt7(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Octet add(final X0 value0) { return addAt7(value0); } public Octet add(final Unit tuple) { return addAt7(tuple); } public Ennead add(final X0 value0, final X1 value1) { return addAt7(value0, value1); } public Ennead add(final Pair tuple) { return addAt7(tuple); } public Decade add(final X0 value0, final X1 value1, final X2 value2) { return addAt7(value0, value1, value2); } public Decade add(final Triplet tuple) { return addAt7(tuple); } public Septet setAt0(final X value) { return new Septet( value, this.val1, this.val2, this.val3, this.val4, this.val5, this.val6); } public Septet setAt1(final X value) { return new Septet( this.val0, value, this.val2, this.val3, this.val4, this.val5, this.val6); } public Septet setAt2(final X value) { return new Septet( this.val0, this.val1, value, this.val3, this.val4, this.val5, this.val6); } public Septet setAt3(final X value) { return new Septet( this.val0, this.val1, this.val2, value, this.val4, this.val5, this.val6); } public Septet setAt4(final X value) { return new Septet( this.val0, this.val1, this.val2, this.val3, value, this.val5, this.val6); } public Septet setAt5(final X value) { return new Septet( this.val0, this.val1, this.val2, this.val3, this.val4, value, this.val6); } public Septet setAt6(final X value) { return new Septet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5, value); } public Sextet removeFrom0() { return new Sextet( this.val1, this.val2, this.val3, this.val4, this.val5, this.val6); } public Sextet removeFrom1() { return new Sextet( this.val0, this.val2, this.val3, this.val4, this.val5, this.val6); } public Sextet removeFrom2() { return new Sextet( this.val0, this.val1, this.val3, this.val4, this.val5, this.val6); } public Sextet removeFrom3() { return new Sextet( this.val0, this.val1, this.val2, this.val4, this.val5, this.val6); } public Sextet removeFrom4() { return new Sextet( this.val0, this.val1, this.val2, this.val3, this.val5, this.val6); } public Sextet removeFrom5() { return new Sextet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val6); } public Sextet removeFrom6() { return new Sextet( this.val0, this.val1, this.val2, this.val3, this.val4, this.val5); } } javatuples-javatuples-1.2/src/main/java/org/javatuples/Quartet.java0000644000175000017500000005670511646342650025125 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.util.Collection; import java.util.Iterator; import org.javatuples.valueintf.IValue0; import org.javatuples.valueintf.IValue1; import org.javatuples.valueintf.IValue2; import org.javatuples.valueintf.IValue3; /** *

* A tuple of four elements. *

* * @since 1.0 * * @author Daniel Fernández * */ public final class Quartet extends Tuple implements IValue0
, IValue1, IValue2, IValue3 { private static final long serialVersionUID = 2445136048617019549L; private static final int SIZE = 4; private final A val0; private final B val1; private final C val2; private final D val3; public static Quartet with(final A value0, final B value1, final C value2, final D value3) { return new Quartet(value0,value1,value2,value3); } /** *

* Create tuple from array. Array has to have exactly four elements. *

* * @param the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static Quartet fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 4) { throw new IllegalArgumentException("Array must have exactly 4 elements in order to create a Quartet. Size is " + array.length); } return new Quartet(array[0],array[1],array[2],array[3]); } /** *

* Create tuple from collection. Collection has to have exactly four elements. *

* * @param the collection component type * @param collection the collection to be converted to a tuple * @return the tuple */ public static Quartet fromCollection(final Collection collection) { return fromIterable(collection); } /** *

* Create tuple from iterable. Iterable has to have exactly four elements. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Quartet fromIterable(final Iterable iterable) { return fromIterable(iterable, 0, true); } /** *

* Create tuple from iterable, starting from the specified index. Iterable * can have more (or less) elements than the tuple to be created. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Quartet fromIterable(final Iterable iterable, int index) { return fromIterable(iterable, index, false); } private static Quartet fromIterable(final Iterable iterable, int index, final boolean exactSize) { if (iterable == null) { throw new IllegalArgumentException("Iterable cannot be null"); } boolean tooFewElements = false; X element0 = null; X element1 = null; X element2 = null; X element3 = null; final Iterator iter = iterable.iterator(); int i = 0; while (i < index) { if (iter.hasNext()) { iter.next(); } else { tooFewElements = true; } i++; } if (iter.hasNext()) { element0 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element1 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element2 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element3 = iter.next(); } else { tooFewElements = true; } if (tooFewElements && exactSize) { throw new IllegalArgumentException("Not enough elements for creating a Quartet (4 needed)"); } if (iter.hasNext() && exactSize) { throw new IllegalArgumentException("Iterable must have exactly 4 available elements in order to create a Quartet."); } return new Quartet(element0, element1, element2, element3); } public Quartet( final A value0, final B value1, final C value2, final D value3) { super(value0, value1, value2, value3); this.val0 = value0; this.val1 = value1; this.val2 = value2; this.val3 = value3; } public A getValue0() { return this.val0; } public B getValue1() { return this.val1; } public C getValue2() { return this.val2; } public D getValue3() { return this.val3; } @Override public int getSize() { return SIZE; } public Quintet addAt0(final X0 value0) { return new Quintet( value0, this.val0, this.val1, this.val2, this.val3); } public Quintet addAt1(final X0 value0) { return new Quintet( this.val0, value0, this.val1, this.val2, this.val3); } public Quintet addAt2(final X0 value0) { return new Quintet( this.val0, this.val1, value0, this.val2, this.val3); } public Quintet addAt3(final X0 value0) { return new Quintet( this.val0, this.val1, this.val2, value0, this.val3); } public Quintet addAt4(final X0 value0) { return new Quintet( this.val0, this.val1, this.val2, this.val3, value0); } public Sextet addAt0(final X0 value0, final X1 value1) { return new Sextet( value0, value1, this.val0, this.val1, this.val2, this.val3); } public Sextet addAt1(final X0 value0, final X1 value1) { return new Sextet( this.val0, value0, value1, this.val1, this.val2, this.val3); } public Sextet addAt2(final X0 value0, final X1 value1) { return new Sextet( this.val0, this.val1, value0, value1, this.val2, this.val3); } public Sextet addAt3(final X0 value0, final X1 value1) { return new Sextet( this.val0, this.val1, this.val2, value0, value1, this.val3); } public Sextet addAt4(final X0 value0, final X1 value1) { return new Sextet( this.val0, this.val1, this.val2, this.val3, value0, value1); } public Septet addAt0(final X0 value0, final X1 value1, final X2 value2) { return new Septet( value0, value1, value2, this.val0, this.val1, this.val2, this.val3); } public Septet addAt1(final X0 value0, final X1 value1, final X2 value2) { return new Septet( this.val0, value0, value1, value2, this.val1, this.val2, this.val3); } public Septet addAt2(final X0 value0, final X1 value1, final X2 value2) { return new Septet( this.val0, this.val1, value0, value1, value2, this.val2, this.val3); } public Septet addAt3(final X0 value0, final X1 value1, final X2 value2) { return new Septet( this.val0, this.val1, this.val2, value0, value1, value2, this.val3); } public Septet addAt4(final X0 value0, final X1 value1, final X2 value2) { return new Septet( this.val0, this.val1, this.val2, this.val3, value0, value1, value2); } public Octet addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Octet( value0, value1, value2, value3, this.val0, this.val1, this.val2, this.val3); } public Octet addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Octet( this.val0, value0, value1, value2, value3, this.val1, this.val2, this.val3); } public Octet addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Octet( this.val0, this.val1, value0, value1, value2, value3, this.val2, this.val3); } public Octet addAt3(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Octet( this.val0, this.val1, this.val2, value0, value1, value2, value3, this.val3); } public Octet addAt4(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Octet( this.val0, this.val1, this.val2, this.val3, value0, value1, value2, value3); } public Ennead addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Ennead( value0, value1, value2, value3, value4, this.val0, this.val1, this.val2, this.val3); } public Ennead addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Ennead( this.val0, value0, value1, value2, value3, value4, this.val1, this.val2, this.val3); } public Ennead addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Ennead( this.val0, this.val1, value0, value1, value2, value3, value4, this.val2, this.val3); } public Ennead addAt3(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Ennead( this.val0, this.val1, this.val2, value0, value1, value2, value3, value4, this.val3); } public Ennead addAt4(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Ennead( this.val0, this.val1, this.val2, this.val3, value0, value1, value2, value3, value4); } public Decade addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Decade( value0, value1, value2, value3, value4, value5, this.val0, this.val1, this.val2, this.val3); } public Decade addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Decade( this.val0, value0, value1, value2, value3, value4, value5, this.val1, this.val2, this.val3); } public Decade addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Decade( this.val0, this.val1, value0, value1, value2, value3, value4, value5, this.val2, this.val3); } public Decade addAt3(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Decade( this.val0, this.val1, this.val2, value0, value1, value2, value3, value4, value5, this.val3); } public Decade addAt4(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Decade( this.val0, this.val1, this.val2, this.val3, value0, value1, value2, value3, value4, value5); } public Quintet addAt0(final Unit tuple) { return addAt0(tuple.getValue0()); } public Quintet addAt1(final Unit tuple) { return addAt1(tuple.getValue0()); } public Quintet addAt2(final Unit tuple) { return addAt2(tuple.getValue0()); } public Quintet addAt3(final Unit tuple) { return addAt3(tuple.getValue0()); } public Quintet addAt4(final Unit tuple) { return addAt4(tuple.getValue0()); } public Sextet addAt0(final Pair tuple) { return addAt0(tuple.getValue0(),tuple.getValue1()); } public Sextet addAt1(final Pair tuple) { return addAt1(tuple.getValue0(),tuple.getValue1()); } public Sextet addAt2(final Pair tuple) { return addAt2(tuple.getValue0(),tuple.getValue1()); } public Sextet addAt3(final Pair tuple) { return addAt3(tuple.getValue0(),tuple.getValue1()); } public Sextet addAt4(final Pair tuple) { return addAt4(tuple.getValue0(),tuple.getValue1()); } public Septet addAt0(final Triplet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Septet addAt1(final Triplet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Septet addAt2(final Triplet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Septet addAt3(final Triplet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Septet addAt4(final Triplet tuple) { return addAt4(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Octet addAt0(final Quartet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Octet addAt1(final Quartet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Octet addAt2(final Quartet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Octet addAt3(final Quartet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Octet addAt4(final Quartet tuple) { return addAt4(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Ennead addAt0(final Quintet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Ennead addAt1(final Quintet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Ennead addAt2(final Quintet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Ennead addAt3(final Quintet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Ennead addAt4(final Quintet tuple) { return addAt4(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Decade addAt0(final Sextet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Decade addAt1(final Sextet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Decade addAt2(final Sextet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Decade addAt3(final Sextet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Decade addAt4(final Sextet tuple) { return addAt4(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Quintet add(final X0 value0) { return addAt4(value0); } public Quintet add(final Unit tuple) { return addAt4(tuple); } public Sextet add(final X0 value0, final X1 value1) { return addAt4(value0, value1); } public Sextet add(final Pair tuple) { return addAt4(tuple); } public Septet add(final X0 value0, final X1 value1, final X2 value2) { return addAt4(value0, value1, value2); } public Septet add(final Triplet tuple) { return addAt4(tuple); } public Octet add(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return addAt4(value0, value1, value2, value3); } public Octet add(final Quartet tuple) { return addAt4(tuple); } public Ennead add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return addAt4(value0, value1, value2, value3, value4); } public Ennead add(final Quintet tuple) { return addAt4(tuple); } public Decade add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return addAt4(value0, value1, value2, value3, value4, value5); } public Decade add(final Sextet tuple) { return addAt4(tuple); } public Quartet setAt0(final X value) { return new Quartet( value, this.val1, this.val2, this.val3); } public Quartet setAt1(final X value) { return new Quartet( this.val0, value, this.val2, this.val3); } public Quartet setAt2(final X value) { return new Quartet( this.val0, this.val1, value, this.val3); } public Quartet setAt3(final X value) { return new Quartet( this.val0, this.val1, this.val2, value); } public Triplet removeFrom0() { return new Triplet( this.val1, this.val2, this.val3); } public Triplet removeFrom1() { return new Triplet( this.val0, this.val2, this.val3); } public Triplet removeFrom2() { return new Triplet( this.val0, this.val1, this.val3); } public Triplet removeFrom3() { return new Triplet( this.val0, this.val1, this.val2); } } javatuples-javatuples-1.2/src/main/java/org/javatuples/Unit.java0000644000175000017500000004425711646342650024416 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.util.Collection; import java.util.Iterator; import org.javatuples.valueintf.IValue0; /** *

* A tuple of one element. *

* * @since 1.0 * * @author Daniel Fernández * */ public final class Unit
extends Tuple implements IValue0 { private static final long serialVersionUID = -9113114724069537096L; private static final int SIZE = 1; private final A val0; public static Unit with(final A value0) { return new Unit(value0); } /** *

* Create tuple from array. Array has to have exactly one element. *

* * @param the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static Unit fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 1) { throw new IllegalArgumentException("Array must have exactly 1 element in order to create a Unit. Size is " + array.length); } return new Unit(array[0]); } /** *

* Create tuple from collection. Collection has to have exactly one element. *

* * @param the collection component type * @param collection the collection to be converted to a tuple * @return the tuple */ public static Unit fromCollection(final Collection collection) { if (collection == null) { throw new IllegalArgumentException("Collection cannot be null"); } if (collection.size() != 1) { throw new IllegalArgumentException("Collection must have exactly 1 element in order to create a Unit. Size is " + collection.size()); } final Iterator iter = collection.iterator(); return new Unit(iter.next()); } /** *

* Create tuple from iterable. Iterable has to have exactly one element. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Unit fromIterable(final Iterable iterable) { return fromIterable(iterable, 0, true); } /** *

* Create tuple from iterable, starting from the specified index. Iterable * can have more (or less) elements than the tuple to be created. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Unit fromIterable(final Iterable iterable, int index) { return fromIterable(iterable, index, false); } private static Unit fromIterable(final Iterable iterable, int index, final boolean exactSize) { if (iterable == null) { throw new IllegalArgumentException("Iterable cannot be null"); } boolean tooFewElements = false; X element0 = null; final Iterator iter = iterable.iterator(); int i = 0; while (i < index) { if (iter.hasNext()) { iter.next(); } else { tooFewElements = true; } i++; } if (iter.hasNext()) { element0 = iter.next(); } else { tooFewElements = true; } if (tooFewElements && exactSize) { throw new IllegalArgumentException("Not enough elements for creating a Unit (1 needed)"); } if (iter.hasNext() && exactSize) { throw new IllegalArgumentException("Iterable must have exactly 1 available element in order to create a Unit."); } return new Unit(element0); } public Unit(final A value0) { super(value0); this.val0 = value0; } public A getValue0() { return this.val0; } @Override public int getSize() { return SIZE; } public Pair addAt0(final X0 value0) { return new Pair( value0, this.val0); } public Pair addAt1(final X0 value0) { return new Pair( this.val0, value0); } public Triplet addAt0(final X0 value0, final X1 value1) { return new Triplet( value0, value1, this.val0); } public Triplet addAt1(final X0 value0, final X1 value1) { return new Triplet( this.val0, value0, value1); } public Quartet addAt0(final X0 value0, final X1 value1, final X2 value2) { return new Quartet( value0, value1, value2, this.val0); } public Quartet addAt1(final X0 value0, final X1 value1, final X2 value2) { return new Quartet( this.val0, value0, value1, value2); } public Quintet addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Quintet( value0, value1, value2, value3, this.val0); } public Quintet addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Quintet( this.val0, value0, value1, value2, value3); } public Sextet addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Sextet( value0, value1, value2, value3, value4, this.val0); } public Sextet addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Sextet( this.val0, value0, value1, value2, value3, value4); } public Septet addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Septet( value0, value1, value2, value3, value4, value5, this.val0); } public Septet addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Septet( this.val0, value0, value1, value2, value3, value4, value5); } public Octet addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6) { return new Octet( value0, value1, value2, value3, value4, value5, value6, this.val0); } public Octet addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6) { return new Octet( this.val0, value0, value1, value2, value3, value4, value5, value6); } public Ennead addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6, final X7 value7) { return new Ennead( value0, value1, value2, value3, value4, value5, value6, value7, this.val0); } public Ennead addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6, final X7 value7) { return new Ennead( this.val0, value0, value1, value2, value3, value4, value5, value6, value7); } public Decade addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6, final X7 value7, final X8 value8) { return new Decade( value0, value1, value2, value3, value4, value5, value6, value7, value8, this.val0); } public Decade addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6, final X7 value7, final X8 value8) { return new Decade( this.val0, value0, value1, value2, value3, value4, value5, value6, value7, value8); } public Pair addAt0(final Unit tuple) { return addAt0(tuple.getValue0()); } public Pair addAt1(final Unit tuple) { return addAt1(tuple.getValue0()); } public Triplet addAt0(final Pair tuple) { return addAt0(tuple.getValue0(),tuple.getValue1()); } public Triplet addAt1(final Pair tuple) { return addAt1(tuple.getValue0(),tuple.getValue1()); } public Quartet addAt0(final Triplet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Quartet addAt1(final Triplet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Quintet addAt0(final Quartet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Quintet addAt1(final Quartet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Sextet addAt0(final Quintet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Sextet addAt1(final Quintet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Septet addAt0(final Sextet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Septet addAt1(final Sextet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Octet addAt0(final Septet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6()); } public Octet addAt1(final Septet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6()); } public Ennead addAt0(final Octet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6(),tuple.getValue7()); } public Ennead addAt1(final Octet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6(),tuple.getValue7()); } public Decade addAt0(final Ennead tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6(),tuple.getValue7(),tuple.getValue8()); } public Decade addAt1(final Ennead tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6(),tuple.getValue7(),tuple.getValue8()); } public Pair add(final X0 value0) { return addAt1(value0); } public Pair add(final Unit tuple) { return addAt1(tuple); } public Triplet add(final X0 value0, final X1 value1) { return addAt1(value0, value1); } public Triplet add(final Pair tuple) { return addAt1(tuple); } public Quartet add(final X0 value0, final X1 value1, final X2 value2) { return addAt1(value0, value1, value2); } public Quartet add(final Triplet tuple) { return addAt1(tuple); } public Quintet add(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return addAt1(value0, value1, value2, value3); } public Quintet add(final Quartet tuple) { return addAt1(tuple); } public Sextet add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return addAt1(value0, value1, value2, value3, value4); } public Sextet add(final Quintet tuple) { return addAt1(tuple); } public Septet add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return addAt1(value0, value1, value2, value3, value4, value5); } public Septet add(final Sextet tuple) { return addAt1(tuple); } public Octet add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6) { return addAt1(value0, value1, value2, value3, value4, value5, value6); } public Octet add(final Septet tuple) { return addAt1(tuple); } public Ennead add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6, final X7 value7) { return addAt1(value0, value1, value2, value3, value4, value5, value6, value7); } public Ennead add(final Octet tuple) { return addAt1(tuple); } public Decade add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6, final X7 value7, final X8 value8) { return addAt1(value0, value1, value2, value3, value4, value5, value6, value7, value8); } public Decade add(final Ennead tuple) { return addAt1(tuple); } public Unit setAt0(final X value) { return new Unit( value); } } javatuples-javatuples-1.2/src/main/java/org/javatuples/Pair.java0000644000175000017500000005140511646342650024363 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.util.Collection; import java.util.Iterator; import org.javatuples.valueintf.IValue0; import org.javatuples.valueintf.IValue1; /** *

* A tuple of two elements. *

* * @since 1.0 * * @author Daniel Fernández * */ public final class Pair extends Tuple implements IValue0
, IValue1 { private static final long serialVersionUID = 2438099850625502138L; private static final int SIZE = 2; private final A val0; private final B val1; public static Pair with(final A value0, final B value1) { return new Pair(value0,value1); } /** *

* Create tuple from array. Array has to have exactly two elements. *

* * @param the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static Pair fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 2) { throw new IllegalArgumentException("Array must have exactly 2 elements in order to create a Pair. Size is " + array.length); } return new Pair(array[0],array[1]); } /** *

* Create tuple from collection. Collection has to have exactly two elements. *

* * @param the collection component type * @param collection the collection to be converted to a tuple * @return the tuple */ public static Pair fromCollection(final Collection collection) { return fromIterable(collection); } /** *

* Create tuple from iterable. Iterable has to have exactly two elements. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Pair fromIterable(final Iterable iterable) { return fromIterable(iterable, 0, true); } /** *

* Create tuple from iterable, starting from the specified index. Iterable * can have more (or less) elements than the tuple to be created. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Pair fromIterable(final Iterable iterable, int index) { return fromIterable(iterable, index, false); } private static Pair fromIterable(final Iterable iterable, int index, final boolean exactSize) { if (iterable == null) { throw new IllegalArgumentException("Iterable cannot be null"); } boolean tooFewElements = false; X element0 = null; X element1 = null; final Iterator iter = iterable.iterator(); int i = 0; while (i < index) { if (iter.hasNext()) { iter.next(); } else { tooFewElements = true; } i++; } if (iter.hasNext()) { element0 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element1 = iter.next(); } else { tooFewElements = true; } if (tooFewElements && exactSize) { throw new IllegalArgumentException("Not enough elements for creating a Pair (2 needed)"); } if (iter.hasNext() && exactSize) { throw new IllegalArgumentException("Iterable must have exactly 2 available elements in order to create a Pair."); } return new Pair(element0, element1); } public Pair( final A value0, final B value1) { super(value0, value1); this.val0 = value0; this.val1 = value1; } public A getValue0() { return this.val0; } public B getValue1() { return this.val1; } @Override public int getSize() { return SIZE; } public Triplet addAt0(final X0 value0) { return new Triplet( value0, this.val0, this.val1); } public Triplet addAt1(final X0 value0) { return new Triplet( this.val0, value0, this.val1); } public Triplet addAt2(final X0 value0) { return new Triplet( this.val0, this.val1, value0); } public Quartet addAt0(final X0 value0, final X1 value1) { return new Quartet( value0, value1, this.val0, this.val1); } public Quartet addAt1(final X0 value0, final X1 value1) { return new Quartet( this.val0, value0, value1, this.val1); } public Quartet addAt2(final X0 value0, final X1 value1) { return new Quartet( this.val0, this.val1, value0, value1); } public Quintet addAt0(final X0 value0, final X1 value1, final X2 value2) { return new Quintet( value0, value1, value2, this.val0, this.val1); } public Quintet addAt1(final X0 value0, final X1 value1, final X2 value2) { return new Quintet( this.val0, value0, value1, value2, this.val1); } public Quintet addAt2(final X0 value0, final X1 value1, final X2 value2) { return new Quintet( this.val0, this.val1, value0, value1, value2); } public Sextet addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Sextet( value0, value1, value2, value3, this.val0, this.val1); } public Sextet addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Sextet( this.val0, value0, value1, value2, value3, this.val1); } public Sextet addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Sextet( this.val0, this.val1, value0, value1, value2, value3); } public Septet addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Septet( value0, value1, value2, value3, value4, this.val0, this.val1); } public Septet addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Septet( this.val0, value0, value1, value2, value3, value4, this.val1); } public Septet addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Septet( this.val0, this.val1, value0, value1, value2, value3, value4); } public Octet addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Octet( value0, value1, value2, value3, value4, value5, this.val0, this.val1); } public Octet addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Octet( this.val0, value0, value1, value2, value3, value4, value5, this.val1); } public Octet addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Octet( this.val0, this.val1, value0, value1, value2, value3, value4, value5); } public Ennead addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6) { return new Ennead( value0, value1, value2, value3, value4, value5, value6, this.val0, this.val1); } public Ennead addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6) { return new Ennead( this.val0, value0, value1, value2, value3, value4, value5, value6, this.val1); } public Ennead addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6) { return new Ennead( this.val0, this.val1, value0, value1, value2, value3, value4, value5, value6); } public Decade addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6, final X7 value7) { return new Decade( value0, value1, value2, value3, value4, value5, value6, value7, this.val0, this.val1); } public Decade addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6, final X7 value7) { return new Decade( this.val0, value0, value1, value2, value3, value4, value5, value6, value7, this.val1); } public Decade addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6, final X7 value7) { return new Decade( this.val0, this.val1, value0, value1, value2, value3, value4, value5, value6, value7); } public Triplet addAt0(final Unit tuple) { return addAt0(tuple.getValue0()); } public Triplet addAt1(final Unit tuple) { return addAt1(tuple.getValue0()); } public Triplet addAt2(final Unit tuple) { return addAt2(tuple.getValue0()); } public Quartet addAt0(final Pair tuple) { return addAt0(tuple.getValue0(),tuple.getValue1()); } public Quartet addAt1(final Pair tuple) { return addAt1(tuple.getValue0(),tuple.getValue1()); } public Quartet addAt2(final Pair tuple) { return addAt2(tuple.getValue0(),tuple.getValue1()); } public Quintet addAt0(final Triplet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Quintet addAt1(final Triplet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Quintet addAt2(final Triplet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Sextet addAt0(final Quartet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Sextet addAt1(final Quartet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Sextet addAt2(final Quartet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Septet addAt0(final Quintet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Septet addAt1(final Quintet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Septet addAt2(final Quintet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Octet addAt0(final Sextet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Octet addAt1(final Sextet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Octet addAt2(final Sextet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Ennead addAt0(final Septet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6()); } public Ennead addAt1(final Septet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6()); } public Ennead addAt2(final Septet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6()); } public Decade addAt0(final Octet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6(),tuple.getValue7()); } public Decade addAt1(final Octet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6(),tuple.getValue7()); } public Decade addAt2(final Octet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6(),tuple.getValue7()); } public Triplet add(final X0 value0) { return addAt2(value0); } public Triplet add(final Unit tuple) { return addAt2(tuple); } public Quartet add(final X0 value0, final X1 value1) { return addAt2(value0, value1); } public Quartet add(final Pair tuple) { return addAt2(tuple); } public Quintet add(final X0 value0, final X1 value1, final X2 value2) { return addAt2(value0, value1, value2); } public Quintet add(final Triplet tuple) { return addAt2(tuple); } public Sextet add(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return addAt2(value0, value1, value2, value3); } public Sextet add(final Quartet tuple) { return addAt2(tuple); } public Septet add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return addAt2(value0, value1, value2, value3, value4); } public Septet add(final Quintet tuple) { return addAt2(tuple); } public Octet add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return addAt2(value0, value1, value2, value3, value4, value5); } public Octet add(final Sextet tuple) { return addAt2(tuple); } public Ennead add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6) { return addAt2(value0, value1, value2, value3, value4, value5, value6); } public Ennead add(final Septet tuple) { return addAt2(tuple); } public Decade add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6, final X7 value7) { return addAt2(value0, value1, value2, value3, value4, value5, value6, value7); } public Decade add(final Octet tuple) { return addAt2(tuple); } public Pair setAt0(final X value) { return new Pair( value, this.val1); } public Pair setAt1(final X value) { return new Pair( this.val0, value); } public Unit removeFrom0() { return new Unit( this.val1); } public Unit
removeFrom1() { return new Unit( this.val0); } } javatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/0000755000175000017500000000000011646342650024615 5ustar eugeneeugenejavatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/IValue1.java0000644000175000017500000000210711646342650026726 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples.valueintf; /** *

* Marker interface for tuples with a "1" value. *

* @since 1.1 * * @author Daniel Fernández * */ public interface IValue1 { public X getValue1(); } javatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/IValue6.java0000644000175000017500000000210711646342650026733 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples.valueintf; /** *

* Marker interface for tuples with a "6" value. *

* @since 1.1 * * @author Daniel Fernández * */ public interface IValue6 { public X getValue6(); } javatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/IValue4.java0000644000175000017500000000210711646342650026731 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples.valueintf; /** *

* Marker interface for tuples with a "4" value. *

* @since 1.1 * * @author Daniel Fernández * */ public interface IValue4 { public X getValue4(); } javatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/IValueLabel.java0000644000175000017500000000211611646342650027605 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples.valueintf; /** *

* Marker interface for tuples with a "label" value. *

* @since 1.1 * * @author Daniel Fernández * */ public interface IValueLabel { public X getLabel(); } javatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/IValue2.java0000644000175000017500000000210711646342650026727 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples.valueintf; /** *

* Marker interface for tuples with a "2" value. *

* @since 1.1 * * @author Daniel Fernández * */ public interface IValue2 { public X getValue2(); } javatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/IValue9.java0000644000175000017500000000210711646342650026736 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples.valueintf; /** *

* Marker interface for tuples with a "9" value. *

* @since 1.1 * * @author Daniel Fernández * */ public interface IValue9 { public X getValue9(); } javatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/IValue8.java0000644000175000017500000000210711646342650026735 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples.valueintf; /** *

* Marker interface for tuples with a "8" value. *

* @since 1.1 * * @author Daniel Fernández * */ public interface IValue8 { public X getValue8(); } javatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/IValue0.java0000644000175000017500000000211111646342650026720 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples.valueintf; /** *

* Marker interface for tuples with a "0" value. *

* @since 1.1 * * @author Daniel Fernández * */ public interface IValue0 { public X getValue0(); } javatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/IValue5.java0000644000175000017500000000210711646342650026732 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples.valueintf; /** *

* Marker interface for tuples with a "5" value. *

* @since 1.1 * * @author Daniel Fernández * */ public interface IValue5 { public X getValue5(); } javatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/IValue3.java0000644000175000017500000000210711646342650026730 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples.valueintf; /** *

* Marker interface for tuples with a "3" value. *

* @since 1.1 * * @author Daniel Fernández * */ public interface IValue3 { public X getValue3(); } javatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/IValueValue.java0000644000175000017500000000211611646342650027642 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples.valueintf; /** *

* Marker interface for tuples with a "value" value. *

* @since 1.1 * * @author Daniel Fernández * */ public interface IValueValue { public X getValue(); } javatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/IValueKey.java0000644000175000017500000000211011646342650027310 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples.valueintf; /** *

* Marker interface for tuples with a "key" value. *

* @since 1.1 * * @author Daniel Fernández * */ public interface IValueKey { public X getKey(); } javatuples-javatuples-1.2/src/main/java/org/javatuples/valueintf/IValue7.java0000644000175000017500000000210711646342650026734 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples.valueintf; /** *

* Marker interface for tuples with a "7" value. *

* @since 1.1 * * @author Daniel Fernández * */ public interface IValue7 { public X getValue7(); } javatuples-javatuples-1.2/src/main/java/org/javatuples/Triplet.java0000644000175000017500000005506011646342650025114 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.util.Collection; import java.util.Iterator; import org.javatuples.valueintf.IValue0; import org.javatuples.valueintf.IValue1; import org.javatuples.valueintf.IValue2; /** *

* A tuple of three elements. *

* * @since 1.0 * * @author Daniel Fernández * */ public final class Triplet extends Tuple implements IValue0
, IValue1, IValue2 { private static final long serialVersionUID = -1877265551599483740L; private static final int SIZE = 3; private final A val0; private final B val1; private final C val2; public static Triplet with(final A value0, final B value1, final C value2) { return new Triplet(value0,value1,value2); } /** *

* Create tuple from array. Array has to have exactly three elements. *

* * @param the array component type * @param array the array to be converted to a tuple * @return the tuple */ public static Triplet fromArray(final X[] array) { if (array == null) { throw new IllegalArgumentException("Array cannot be null"); } if (array.length != 3) { throw new IllegalArgumentException("Array must have exactly 3 elements in order to create a Triplet. Size is " + array.length); } return new Triplet(array[0],array[1],array[2]); } /** *

* Create tuple from collection. Collection has to have exactly three elements. *

* * @param the collection component type * @param collection the collection to be converted to a tuple * @return the tuple */ public static Triplet fromCollection(final Collection collection) { return fromIterable(collection); } /** *

* Create tuple from iterable. Iterable has to have exactly three elements. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Triplet fromIterable(final Iterable iterable) { return fromIterable(iterable, 0, true); } /** *

* Create tuple from iterable, starting from the specified index. Iterable * can have more (or less) elements than the tuple to be created. *

* * @param the iterable component type * @param iterable the iterable to be converted to a tuple * @return the tuple */ public static Triplet fromIterable(final Iterable iterable, int index) { return fromIterable(iterable, index, false); } private static Triplet fromIterable(final Iterable iterable, int index, final boolean exactSize) { if (iterable == null) { throw new IllegalArgumentException("Iterable cannot be null"); } boolean tooFewElements = false; X element0 = null; X element1 = null; X element2 = null; final Iterator iter = iterable.iterator(); int i = 0; while (i < index) { if (iter.hasNext()) { iter.next(); } else { tooFewElements = true; } i++; } if (iter.hasNext()) { element0 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element1 = iter.next(); } else { tooFewElements = true; } if (iter.hasNext()) { element2 = iter.next(); } else { tooFewElements = true; } if (tooFewElements && exactSize) { throw new IllegalArgumentException("Not enough elements for creating a Triplet (3 needed)"); } if (iter.hasNext() && exactSize) { throw new IllegalArgumentException("Iterable must have exactly 3 available elements in order to create a Triplet."); } return new Triplet(element0, element1, element2); } public Triplet( final A value0, final B value1, final C value2) { super(value0, value1, value2); this.val0 = value0; this.val1 = value1; this.val2 = value2; } public A getValue0() { return this.val0; } public B getValue1() { return this.val1; } public C getValue2() { return this.val2; } @Override public int getSize() { return SIZE; } public Quartet addAt0(final X0 value0) { return new Quartet( value0, this.val0, this.val1, this.val2); } public Quartet addAt1(final X0 value0) { return new Quartet( this.val0, value0, this.val1, this.val2); } public Quartet addAt2(final X0 value0) { return new Quartet( this.val0, this.val1, value0, this.val2); } public Quartet addAt3(final X0 value0) { return new Quartet( this.val0, this.val1, this.val2, value0); } public Quintet addAt0(final X0 value0, final X1 value1) { return new Quintet( value0, value1, this.val0, this.val1, this.val2); } public Quintet addAt1(final X0 value0, final X1 value1) { return new Quintet( this.val0, value0, value1, this.val1, this.val2); } public Quintet addAt2(final X0 value0, final X1 value1) { return new Quintet( this.val0, this.val1, value0, value1, this.val2); } public Quintet addAt3(final X0 value0, final X1 value1) { return new Quintet( this.val0, this.val1, this.val2, value0, value1); } public Sextet addAt0(final X0 value0, final X1 value1, final X2 value2) { return new Sextet( value0, value1, value2, this.val0, this.val1, this.val2); } public Sextet addAt1(final X0 value0, final X1 value1, final X2 value2) { return new Sextet( this.val0, value0, value1, value2, this.val1, this.val2); } public Sextet addAt2(final X0 value0, final X1 value1, final X2 value2) { return new Sextet( this.val0, this.val1, value0, value1, value2, this.val2); } public Sextet addAt3(final X0 value0, final X1 value1, final X2 value2) { return new Sextet( this.val0, this.val1, this.val2, value0, value1, value2); } public Septet addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Septet( value0, value1, value2, value3, this.val0, this.val1, this.val2); } public Septet addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Septet( this.val0, value0, value1, value2, value3, this.val1, this.val2); } public Septet addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Septet( this.val0, this.val1, value0, value1, value2, value3, this.val2); } public Septet addAt3(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return new Septet( this.val0, this.val1, this.val2, value0, value1, value2, value3); } public Octet addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Octet( value0, value1, value2, value3, value4, this.val0, this.val1, this.val2); } public Octet addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Octet( this.val0, value0, value1, value2, value3, value4, this.val1, this.val2); } public Octet addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Octet( this.val0, this.val1, value0, value1, value2, value3, value4, this.val2); } public Octet addAt3(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return new Octet( this.val0, this.val1, this.val2, value0, value1, value2, value3, value4); } public Ennead addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Ennead( value0, value1, value2, value3, value4, value5, this.val0, this.val1, this.val2); } public Ennead addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Ennead( this.val0, value0, value1, value2, value3, value4, value5, this.val1, this.val2); } public Ennead addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Ennead( this.val0, this.val1, value0, value1, value2, value3, value4, value5, this.val2); } public Ennead addAt3(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return new Ennead( this.val0, this.val1, this.val2, value0, value1, value2, value3, value4, value5); } public Decade addAt0(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6) { return new Decade( value0, value1, value2, value3, value4, value5, value6, this.val0, this.val1, this.val2); } public Decade addAt1(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6) { return new Decade( this.val0, value0, value1, value2, value3, value4, value5, value6, this.val1, this.val2); } public Decade addAt2(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6) { return new Decade( this.val0, this.val1, value0, value1, value2, value3, value4, value5, value6, this.val2); } public Decade addAt3(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6) { return new Decade( this.val0, this.val1, this.val2, value0, value1, value2, value3, value4, value5, value6); } public Quartet addAt0(final Unit tuple) { return addAt0(tuple.getValue0()); } public Quartet addAt1(final Unit tuple) { return addAt1(tuple.getValue0()); } public Quartet addAt2(final Unit tuple) { return addAt2(tuple.getValue0()); } public Quartet addAt3(final Unit tuple) { return addAt3(tuple.getValue0()); } public Quintet addAt0(final Pair tuple) { return addAt0(tuple.getValue0(),tuple.getValue1()); } public Quintet addAt1(final Pair tuple) { return addAt1(tuple.getValue0(),tuple.getValue1()); } public Quintet addAt2(final Pair tuple) { return addAt2(tuple.getValue0(),tuple.getValue1()); } public Quintet addAt3(final Pair tuple) { return addAt3(tuple.getValue0(),tuple.getValue1()); } public Sextet addAt0(final Triplet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Sextet addAt1(final Triplet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Sextet addAt2(final Triplet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Sextet addAt3(final Triplet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2()); } public Septet addAt0(final Quartet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Septet addAt1(final Quartet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Septet addAt2(final Quartet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Septet addAt3(final Quartet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3()); } public Octet addAt0(final Quintet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Octet addAt1(final Quintet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Octet addAt2(final Quintet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Octet addAt3(final Quintet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4()); } public Ennead addAt0(final Sextet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Ennead addAt1(final Sextet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Ennead addAt2(final Sextet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Ennead addAt3(final Sextet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5()); } public Decade addAt0(final Septet tuple) { return addAt0(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6()); } public Decade addAt1(final Septet tuple) { return addAt1(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6()); } public Decade addAt2(final Septet tuple) { return addAt2(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6()); } public Decade addAt3(final Septet tuple) { return addAt3(tuple.getValue0(),tuple.getValue1(),tuple.getValue2(),tuple.getValue3(),tuple.getValue4(),tuple.getValue5(),tuple.getValue6()); } public Quartet add(final X0 value0) { return addAt3(value0); } public Quartet add(final Unit tuple) { return addAt3(tuple); } public Quintet add(final X0 value0, final X1 value1) { return addAt3(value0, value1); } public Quintet add(final Pair tuple) { return addAt3(tuple); } public Sextet add(final X0 value0, final X1 value1, final X2 value2) { return addAt3(value0, value1, value2); } public Sextet add(final Triplet tuple) { return addAt3(tuple); } public Septet add(final X0 value0, final X1 value1, final X2 value2, final X3 value3) { return addAt3(value0, value1, value2, value3); } public Septet add(final Quartet tuple) { return addAt3(tuple); } public Octet add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4) { return addAt3(value0, value1, value2, value3, value4); } public Octet add(final Quintet tuple) { return addAt3(tuple); } public Ennead add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5) { return addAt3(value0, value1, value2, value3, value4, value5); } public Ennead add(final Sextet tuple) { return addAt3(tuple); } public Decade add(final X0 value0, final X1 value1, final X2 value2, final X3 value3, final X4 value4, final X5 value5, final X6 value6) { return addAt3(value0, value1, value2, value3, value4, value5, value6); } public Decade add(final Septet tuple) { return addAt3(tuple); } public Triplet setAt0(final X value) { return new Triplet( value, this.val1, this.val2); } public Triplet setAt1(final X value) { return new Triplet( this.val0, value, this.val2); } public Triplet setAt2(final X value) { return new Triplet( this.val0, this.val1, value); } public Pair removeFrom0() { return new Pair( this.val1, this.val2); } public Pair removeFrom1() { return new Pair( this.val0, this.val2); } public Pair removeFrom2() { return new Pair( this.val0, this.val1); } } javatuples-javatuples-1.2/src/test/0000755000175000017500000000000011646342650016765 5ustar eugeneeugenejavatuples-javatuples-1.2/src/test/java/0000755000175000017500000000000011646342650017706 5ustar eugeneeugenejavatuples-javatuples-1.2/src/test/java/org/0000755000175000017500000000000011646342650020475 5ustar eugeneeugenejavatuples-javatuples-1.2/src/test/java/org/javatuples/0000755000175000017500000000000011646342650022653 5ustar eugeneeugenejavatuples-javatuples-1.2/src/test/java/org/javatuples/Test.java0000644000175000017500000001602711646342650024443 0ustar eugeneeugene/* * ============================================================================= * * Copyright (c) 2010, The JAVATUPLES team (http://www.javatuples.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ============================================================================= */ package org.javatuples; import java.net.Socket; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import junit.framework.TestCase; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.SerializationUtils; public class Test extends TestCase { public void testMain() throws Exception { final Decade decade = Decade.with(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5), Integer.valueOf(6), Integer.valueOf(7), Integer.valueOf(8), Integer.valueOf(9), Integer.valueOf(10)); List decadeList = new ArrayList(); for (final Object value : decade) { decadeList.add((Integer)value); System.out.println(value); } final Decade decade2 = Decade.fromCollection(decadeList); assertEquals(decade, decade2); final Decade decade3 = Decade.fromIterable(decadeList); assertEquals(decade, decade3); final Decade decade4 = Decade.fromIterable(decadeList, 0); assertEquals(decade, decade4); decadeList.add(Integer.valueOf(100)); final Decade decade5 = Decade.fromIterable(decadeList, 0); assertEquals(decade, decade5); final Decade decade100 = Decade.with(Integer.valueOf(2), Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5), Integer.valueOf(6), Integer.valueOf(7), Integer.valueOf(8), Integer.valueOf(9), Integer.valueOf(10), Integer.valueOf(100)); final Decade decade6 = Decade.fromIterable(decadeList, 1); assertEquals(decade100, decade6); final Ennead ennead = Ennead.with(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5), Integer.valueOf(6), Integer.valueOf(7), Integer.valueOf(8), Integer.valueOf(9)); System.out.println(ennead.addAt1("Pepito")); System.out.println(ennead.add(new Socket())); final Sextet sextet = Sextet.with("1.0",Integer.valueOf(2),"3.0","4.0","5.0","6.0"); System.out.println(sextet); System.out.println(sextet.addAt3("Perico")); Pair pair = Pair.with("a", null); final Object o = null; assertTrue(pair.contains("a")); assertTrue(pair.contains(null)); assertTrue(pair.containsAll(o)); assertTrue(pair.containsAll(null,"a")); assertTrue(!pair.containsAll(null,"b")); final byte[] serSextet = SerializationUtils.serialize(sextet); System.out.println(Arrays.asList(ArrayUtils.toObject(serSextet))); final Sextet sextetUnSer = (Sextet) SerializationUtils.deserialize(serSextet); System.out.println(sextetUnSer); String str = null; Integer integ = null; Double[] doubleArray = null; Triplet triplet = Triplet.with(str, integ, doubleArray); System.out.println(triplet); Pair pair1 = Pair.with("hello", Integer.valueOf(23)); Quintet quintet = Quintet.with("a", Integer.valueOf(3), Double.valueOf(34.2), "b", "c"); Pair pair2 = new Pair("hello", Integer.valueOf(23)); Quintet quintet2 = new Quintet("a", Integer.valueOf(3), Double.valueOf(34.2), "b", "c"); System.out.println(pair1); System.out.println(pair2); System.out.println(quintet); System.out.println(quintet2); try { quintet2.getValue(8); assertTrue(false); } catch (IllegalArgumentException e) { // OK } catch (Exception e) { throw e; } final List tuples = new ArrayList(); tuples.add(Quintet.with(0, 87, 21, 2, 2)); tuples.add(Quintet.with(0, 1, 1, 4, 1)); tuples.add(Quintet.with(0, 1, 1, 4, 0)); tuples.add(Quintet.with(0, 1, 1, 4, 2)); tuples.add(Quintet.with(24, 12, 99, 0, 14)); tuples.add(Quintet.with(24, 12, 84, 4, 2)); tuples.add(Quartet.with(24, 12, 84, 4)); tuples.add(Quartet.with(24, 12, 84, 3)); tuples.add(Quartet.with(24, 12, 84, 0)); tuples.add(Quartet.with(25, 2, 84, 0)); tuples.add(Quartet.with(22, 12, 84, 9)); tuples.add(Sextet.with(0, 0, 0, 0, 0, 0)); tuples.add(Sextet.with(0, 0, 0, 2, 0, 0)); tuples.add(Sextet.with(0, 87, 21, 2, 1, 0)); System.out.println("-"); for (final Tuple tuple : tuples) { System.out.println(tuple); } Collections.sort(tuples); System.out.println("-"); for (final Tuple tuple : tuples) { System.out.println(tuple); } System.out.println("-"); } } javatuples-javatuples-1.2/src/assembly/0000755000175000017500000000000011646342650017625 5ustar eugeneeugenejavatuples-javatuples-1.2/src/assembly/dist.xml0000644000175000017500000000230511646342650021312 0ustar eugeneeugene dist zip ${basedir}/../javatuples/target/apidocs/ /apidocs **/* ${basedir}/../javatuples/target/ /dist javatuples-${version}.jar javatuples-${version}-javadoc.jar javatuples-${version}-sources.jar ${basedir}/ / LICENSE.txt README.txt NOTICE.txt /lib false runtime javatuples-javatuples-1.2/BUILD.txt0000644000175000017500000000144011646342650016616 0ustar eugeneeugene Building javatuples ------------------- To build javatuples you will need Maven 2. You can get it at: http://maven.apache.org Build and install the project executing, from the javatuples project root folder: mvn clean:clean install And you will get a fresh target/javatuples-{version}.jar file. You will also get it installed in your local repository at: $M2_REPO/org/javatuples/javatuples/{version}/javatuples-{version}.jar Generating Javadoc for javatuples --------------------------------- If you wish to generate the javadoc for javatuples, execute this from the javatuples root folder: mvn javadoc:javadoc This will generate the javadoc documentation in HTML format in: target/site/apidocs javatuples-javatuples-1.2/ChangeLog.txt0000644000175000017500000000033511646342650017610 0ustar eugeneeugene Changes from 1.0 to 1.1 ======================= - Added the org.javatuples.valueintf.* interfaces useful for using the library in some specific environments. 1.0 ======= - First release of javatuples javatuples-javatuples-1.2/RELEASING.txt0000644000175000017500000000235011646342650017271 0ustar eugeneeugeneIn order to prepare a release, this steps have to be taken: 1. In settings.xml, these entries must exist: releases [KEYNAME (EMAIL)] [GPG PASSPHRASE] sonatype-nexus-snapshots [USER IN SONATYPE NEXUS] [PASSWORD IN SONATYPE NEXUS] 2. Ensure all SVN URLs in pom.xml are using "https". A "502 Bad Gateway" error will be received if not. 3. Deploy SNAPSHOT artifact to Sonatype NEXUS with "mvn deploy", and check in Nexus web interface. 4. Execute a test "no modification" run of the release:prepare goal: "mvn -Preleases release:prepare -DdryRun=true -Dusername=[SVNUSER] -Dpassword=[SVNPASS]" 5. Execute a real run of the release:prepare goal: "mvn -Preleases release:prepare -Dusername=[SVNUSER] -Dpassword=[SVNPASS]" 6. Upload the release: "mvn -Preleases release:perform -Dusername=[SVNUSER] -Dpassword=[SVNPASS]" 7. Follow instructions for Nexus at: http://nexus.sonatype.org/oss-repository-hosting.html javatuples-javatuples-1.2/README.txt0000644000175000017500000000017011646342650016713 0ustar eugeneeugene javatuples ---------- To learn more and download latest version: http://www.javatuples.org