[
  {
    "path": ".classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<classpath>\r\n\t<classpathentry kind=\"src\" path=\"src/main/java\"/>\r\n\t<classpathentry kind=\"src\" path=\"src/test/java\"/>\r\n\t<classpathentry kind=\"lib\" path=\"lib/junit-4.10.jar\" sourcepath=\"lib/source/junit-4.10-sources.jar\"/>\r\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\r\n\t<classpathentry kind=\"lib\" path=\"lib/collections-1.2.0.jar\" sourcepath=\"lib/source/collections-1.2.0-sources.jar\"/>\r\n\t<classpathentry kind=\"lib\" path=\"lib/collections-api-1.2.0.jar\" sourcepath=\"lib/source/collections-api-1.2.0-sources.jar\"/>\r\n\t<classpathentry kind=\"lib\" path=\"lib/collections-testutils-1.2.0.jar\" sourcepath=\"lib/source/collections-testutils-1.2.0-sources.jar\"/>\r\n\t<classpathentry kind=\"output\" path=\"target\"/>\r\n</classpath>\r\n"
  },
  {
    "path": ".idea/copyright/Apache.xml",
    "content": "<component name=\"CopyrightManager\">\n  <copyright>\n    <option name=\"notice\" value=\"Copyright &amp;#36;today.year Goldman Sachs.&#10;&#10;Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&#10;you may not use this file except in compliance with the License.&#10;You may obtain a copy of the License at&#10;&#10;    http://www.apache.org/licenses/LICENSE-2.0&#10;&#10;Unless required by applicable law or agreed to in writing, software&#10;distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&#10;WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#10;See the License for the specific language governing permissions and&#10;limitations under the License.\" />\n    <option name=\"keyword\" value=\"Copyright\" />\n    <option name=\"allowReplaceKeyword\" value=\"\" />\n    <option name=\"myName\" value=\"Apache\" />\n    <option name=\"myLocal\" value=\"true\" />\n  </copyright>\n</component>"
  },
  {
    "path": ".idea/copyright/profiles_settings.xml",
    "content": "<component name=\"CopyrightManager\">\n  <settings default=\"Apache\">\n    <module2copyright />\n    <LanguageOptions name=\"XML\">\n      <option name=\"fileLocation\" value=\"2\" />\n    </LanguageOptions>\n  </settings>\n</component>"
  },
  {
    "path": ".idea/libraries/lib.xml",
    "content": "<component name=\"libraryTable\">\n  <library name=\"lib\">\n    <CLASSES>\n      <root url=\"file://$PROJECT_DIR$/lib\" />\n    </CLASSES>\n    <JAVADOC />\n    <SOURCES>\n      <root url=\"file://$PROJECT_DIR$/lib/source\" />\n    </SOURCES>\n    <jarDirectory url=\"file://$PROJECT_DIR$/lib\" recursive=\"false\" />\n    <jarDirectory url=\"file://$PROJECT_DIR$/lib/source\" recursive=\"false\" type=\"SOURCES\" />\n  </library>\n</component>"
  },
  {
    "path": ".idea/misc.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"EntryPointsManager\">\n    <entry_points version=\"2.0\" />\n  </component>\n  <component name=\"ProjectRootManager\" version=\"2\" languageLevel=\"JDK_1_8\" assert-keyword=\"true\" jdk-15=\"true\" project-jdk-name=\"1.8\" project-jdk-type=\"JavaSDK\" />\n</project>\n\n"
  },
  {
    "path": ".idea/modules.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"ProjectModuleManager\">\n    <modules>\n      <module fileurl=\"file://$PROJECT_DIR$/GSCollectionsKata.iml\" filepath=\"$PROJECT_DIR$/GSCollectionsKata.iml\" />\n    </modules>\n  </component>\n</project>\n\n"
  },
  {
    "path": ".idea/runConfigurations/All_in_GSCollectionsKata.xml",
    "content": "<component name=\"ProjectRunConfigurationManager\">\r\n  <configuration default=\"false\" name=\"All in GSCollectionsKata\" type=\"JUnit\" factoryName=\"JUnit\">\r\n    <extension name=\"coverage\" enabled=\"false\" merge=\"false\" sample_coverage=\"true\" runner=\"idea\" />\r\n    <module name=\"GSCollectionsKata\" />\r\n    <option name=\"ALTERNATIVE_JRE_PATH_ENABLED\" value=\"false\" />\r\n    <option name=\"ALTERNATIVE_JRE_PATH\" value=\"\" />\r\n    <option name=\"PACKAGE_NAME\" value=\"\" />\r\n    <option name=\"MAIN_CLASS_NAME\" value=\"\" />\r\n    <option name=\"METHOD_NAME\" value=\"\" />\r\n    <option name=\"TEST_OBJECT\" value=\"package\" />\r\n    <option name=\"VM_PARAMETERS\" value=\"\" />\r\n    <option name=\"PARAMETERS\" value=\"\" />\r\n    <option name=\"WORKING_DIRECTORY\" value=\"file://$PROJECT_DIR$\" />\r\n    <option name=\"ENV_VARIABLES\" />\r\n    <option name=\"PASS_PARENT_ENVS\" value=\"true\" />\r\n    <option name=\"TEST_SEARCH_SCOPE\">\r\n      <value defaultName=\"moduleWithDependencies\" />\r\n    </option>\r\n    <envs />\r\n    <patterns />\r\n    <RunnerSettings RunnerId=\"Run\" />\r\n    <ConfigurationWrapper RunnerId=\"Run\" />\r\n    <method />\r\n  </configuration>\r\n</component>"
  },
  {
    "path": ".project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<projectDescription>\r\n\t<name>GS Collections Kata</name>\r\n\t<comment></comment>\r\n\t<projects>\r\n\t</projects>\r\n\t<buildSpec>\r\n\t\t<buildCommand>\r\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\r\n\t\t\t<arguments>\r\n\t\t\t</arguments>\r\n\t\t</buildCommand>\r\n\t</buildSpec>\r\n\t<natures>\r\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\r\n\t</natures>\r\n</projectDescription>\r\n"
  },
  {
    "path": ".settings/org.eclipse.jdt.core.prefs",
    "content": "#Fri Dec 23 13:01:22 EST 2011\r\neclipse.preferences.version=1\r\norg.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r\norg.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r\norg.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\r\norg.eclipse.jdt.core.compiler.compliance=1.6\r\norg.eclipse.jdt.core.compiler.debug.lineNumber=generate\r\norg.eclipse.jdt.core.compiler.debug.localVariable=generate\r\norg.eclipse.jdt.core.compiler.debug.sourceFile=generate\r\norg.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r\norg.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r\norg.eclipse.jdt.core.compiler.source=1.6\r\n"
  },
  {
    "path": "GSCollectionsKata.iml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module type=\"JAVA_MODULE\" version=\"4\">\n  <component name=\"NewModuleRootManager\" inherit-compiler-output=\"false\">\n    <output url=\"file://$MODULE_DIR$/target\" />\n    <output-test url=\"file://$MODULE_DIR$/target\" />\n    <exclude-output />\n    <content url=\"file://$MODULE_DIR$\">\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/java\" isTestSource=\"true\" />\n    </content>\n    <orderEntry type=\"inheritedJdk\" />\n    <orderEntry type=\"sourceFolder\" forTests=\"false\" />\n    <orderEntry type=\"library\" name=\"lib\" level=\"project\" />\n  </component>\n</module>\n\n"
  },
  {
    "path": "LICENSE-2.0.txt",
    "content": "\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "NOTICE",
    "content": "GS Collections Kata\nCopyright 2011 Goldman Sachs\n\nThis product includes software (JUnit) developed by\nJUnit.org (http://www.junit.org/).\n"
  },
  {
    "path": "README.md",
    "content": "# GS Collections Kata\r\n\r\n## What is a Code Kata?\r\nA _kata_ is an exercise in martial arts. A code kata is an exercise in programming which helps hone your skills through practice and repetition. You can find out more about code Katas in general [here](http://codekata.pragprog.com).\r\n\r\n## What is the GS Collections Code Kata?\r\nThe GS Collections Kata is a fun way to help you learn idiomatic GS Collections usage. This particular kata is set up as a series of unit tests which fail. Your task is to make them pass, using GS Collections. The Kata is meant to take approximately one eight-hour day.\r\n\r\nNew concepts are introduced in the [slides](http://www.goldmansachs.com/gs-collections/documents/GS Collections Training Session and Kata 5.0.0.pdf), with coding exercises at the end of each section. As you complete each exercise, you can check your answers against the [solutions branch](https://github.com/goldmansachs/gs-collections-kata/tree/solutions).\r\n\r\nMake sure you read the instructor notes in the slides. In addition, you can refer to the [GS Collections Reference Guide](http://www.goldmansachs.com/gs-collections/documents/GS Collections Reference Guide 5.0.0.pdf) for further detail and examples of the API.\r\n"
  },
  {
    "path": "src/main/java/com/gs/collections/kata/Company.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport com.gs.collections.api.block.predicate.Predicate;\nimport com.gs.collections.api.list.MutableList;\nimport com.gs.collections.impl.list.mutable.FastList;\nimport org.junit.Assert;\n\n/**\n * A company has a {@link MutableList} of {@link Customer}s.  It has an array of {@link Supplier}s, and a name.\n */\npublic class Company\n{\n    private final String name;\n    private final MutableList<Customer> customers = FastList.newList();\n\n    // suppliers are array based.\n    private Supplier[] suppliers = new Supplier[0];\n\n    public Company(String name)\n    {\n        this.name = name;\n    }\n\n    public String getName()\n    {\n        return this.name;\n    }\n\n    public void addCustomer(Customer aCustomer)\n    {\n        this.customers.add(aCustomer);\n    }\n\n    public MutableList<Customer> getCustomers()\n    {\n        return this.customers;\n    }\n\n    public MutableList<Order> getOrders()\n    {\n        Assert.fail(\"Refactor this code to use GS Collections as part of Exercise 3\");\n        MutableList<Order> orders = FastList.newList();\n        for (Customer customer : this.customers)\n        {\n            orders.addAll(customer.getOrders());\n        }\n        return orders;\n    }\n\n    public Customer getMostRecentCustomer()\n    {\n        return this.customers.getLast();\n    }\n\n    public void addSupplier(Supplier supplier)\n    {\n        // need to replace the current array of suppliers with another, larger array\n        // Of course, normally one would not use an array.\n\n        final Supplier[] currentSuppliers = this.suppliers;\n        this.suppliers = new Supplier[currentSuppliers.length + 1];\n        System.arraycopy(currentSuppliers, 0, this.suppliers, 0, currentSuppliers.length);\n        this.suppliers[this.suppliers.length - 1] = supplier;\n    }\n\n    public Supplier[] getSuppliers()\n    {\n        return this.suppliers;\n    }\n\n    public Customer getCustomerNamed(String name)\n    {\n        /**\n         * Use a {@link Predicate} to find a {@link Customer} with the name given.\n         */\n        Assert.fail(\"Implement this method as part of Exercise 2\");\n        return null;\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/gs/collections/kata/Customer.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.gs.collections.api.block.function.Function;\nimport com.gs.collections.api.list.MutableList;\nimport com.gs.collections.impl.block.function.AddFunction;\nimport com.gs.collections.impl.utility.ListIterate;\nimport org.junit.Assert;\n\n/**\n * Customers have a name, city and a list of {@link Order}s\n */\npublic class Customer\n{\n    public static final Function<Customer, String> TO_NAME = customer -> {\n        Assert.fail(\"Replace with the implementation of the Function.\");\n        return null;\n    };\n\n    public static final Function<Customer, String> TO_CITY = null;\n\n    public static final Function<Customer, Double> TO_TOTAL_ORDER_VALUE = Customer::getTotalOrderValue;\n\n    private final String name;\n    private final String city;\n\n    private final List<Order> orders = new ArrayList<>();\n\n    public Customer(String name, String city)\n    {\n        this.name = name;\n        this.city = city;\n    }\n\n    public String getCity()\n    {\n        return this.city;\n    }\n\n    public String getName()\n    {\n        return this.name;\n    }\n\n    public List<Order> getOrders()\n    {\n        return this.orders;\n    }\n\n    public void addOrder(Order anOrder)\n    {\n        this.orders.add(anOrder);\n    }\n\n    public double getTotalOrderValue()\n    {\n        MutableList<Double> orderValues = ListIterate.collect(this.orders, Order::getValue);\n        return orderValues.injectInto(0.0, AddFunction.DOUBLE_TO_DOUBLE);\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/gs/collections/kata/LineItem.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport com.gs.collections.api.block.function.Function;\n\n/**\n * An Item has a name and a value.\n */\npublic class LineItem\n{\n    public static final Function<LineItem, String> TO_NAME = LineItem::getName;\n\n    private String name;\n    private final double value;\n\n    public String getName()\n    {\n        return this.name;\n    }\n\n    public void setName(String name)\n    {\n        this.name = name;\n    }\n\n    public double getValue()\n    {\n        return this.value;\n    }\n\n    public LineItem(String name, double value)\n    {\n        this.name = name;\n        this.value = value;\n    }\n\n    @Override\n    public String toString()\n    {\n        return this.name + \" $ \" + this.getValue();\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/gs/collections/kata/Order.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.List;\n\nimport com.gs.collections.api.block.function.Function;\nimport com.gs.collections.impl.block.function.AddFunction;\nimport com.gs.collections.impl.collection.mutable.CollectionAdapter;\nimport com.gs.collections.impl.utility.Iterate;\n\n/**\n * Has a number, a {@link Customer}, a {@link List} of {@link LineItem}s, and a boolean that states whether or not the order\n * has been delivered. There is a class variable that contains the next order number.\n */\npublic class Order\n{\n    public static final Function<Order, Double> TO_VALUE = Order::getValue;\n\n    public static final Function<Order, Iterable<LineItem>> TO_LINE_ITEMS = Order::getLineItems;\n\n    private static int nextOrderNumber = 1;\n\n    private final int orderNumber;\n    private final List<LineItem> lineItems = new ArrayList<>();\n    private boolean isDelivered;\n\n    public Order()\n    {\n        this.orderNumber = nextOrderNumber;\n        nextOrderNumber += 1;\n    }\n\n    public static void resetNextOrderNumber()\n    {\n        nextOrderNumber = 1;\n    }\n\n    public void deliver()\n    {\n        this.isDelivered = true;\n    }\n\n    public boolean isDelivered()\n    {\n        return this.isDelivered;\n    }\n\n    public void addLineItem(LineItem aLineItem)\n    {\n        this.lineItems.add(aLineItem);\n    }\n\n    public List<LineItem> getLineItems()\n    {\n        return this.lineItems;\n    }\n\n    @Override\n    public String toString()\n    {\n        return \"order \" + this.orderNumber + \" items: \" + this.lineItems.size();\n    }\n\n    public double getValue()\n    {\n        Collection<Double> itemValues = Iterate.collect(this.lineItems, LineItem::getValue);\n\n        return CollectionAdapter.adapt(itemValues).injectInto(0.0, AddFunction.DOUBLE_TO_DOUBLE);\n    }\n}\n"
  },
  {
    "path": "src/main/java/com/gs/collections/kata/Supplier.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport com.gs.collections.api.block.function.Function;\n\n/**\n * Suppliers have a name and an array of itemNames. Suppliers don't like lists - they prefer arrays....\n */\npublic class Supplier\n{\n    public static final Function<Supplier, String> TO_NAME = Supplier::getName;\n\n    public static final Function<Supplier, Integer> TO_NUMBER_OF_ITEMS = supplier -> supplier.getItemNames().length;\n\n    private final String name;\n    private final String[] itemNames;\n\n    public Supplier(String name, String[] itemNames)\n    {\n        this.name = name;\n        this.itemNames = itemNames;\n    }\n\n    public String getName()\n    {\n        return this.name;\n    }\n\n    public String[] getItemNames()\n    {\n        return this.itemNames;\n    }\n}\n"
  },
  {
    "path": "src/test/java/com/gs/collections/kata/CompanyDomainForKata.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport org.junit.Before;\n\npublic abstract class CompanyDomainForKata\n{\n    protected final Company company = new Company(\"Bloggs Shed Supplies\");\n\n    @Before\n    public void setUp()\n    {\n        Order.resetNextOrderNumber();\n        this.setUpCustomersAndOrders();\n        this.setUpSuppliers();\n    }\n\n    private void setUpSuppliers()\n    {\n        this.company.addSupplier(new Supplier(\"Shedtastic\", new String[]{\"shed\", \"big shed\", \"huge shed\"}));\n        this.company.addSupplier(new Supplier(\"Splendid Crocks\", new String[]{\"cup\", \"saucer\", \"bowl\"}));\n        this.company.addSupplier(new Supplier(\"Annoying Pets\", new String[]{\"dog\", \"cat\", \"goldfish\"}));\n        this.company.addSupplier(new Supplier(\"Gnomes 'R' Us\", new String[]{\"gnome\"}));\n        this.company.addSupplier(new Supplier(\"Furniture Hamlet\", new String[]{\"table\", \"sofa\", \"chair\"}));\n        this.company.addSupplier(new Supplier(\"SFD\", new String[]{\"sofa\", \"chair\"}));\n        this.company.addSupplier(new Supplier(\"Doxins\", new String[]{\"kettle\", \"plasma screen\", \"sandwich toaster\"}));\n    }\n\n    private void setUpCustomersAndOrders()\n    {\n        Order fredOrder = new Order();\n        fredOrder.addLineItem(new LineItem(\"shed\", 50.0));\n\n        /**\n         * TODO 7: Refactor Order and its API so this repetition is not necessary.\n         */\n        // TODO 7: Add 3 cups at 1.5 each to the order\n        fredOrder.addLineItem(new LineItem(\"cup\", 1.5));\n        fredOrder.addLineItem(new LineItem(\"cup\", 1.5));\n        fredOrder.addLineItem(new LineItem(\"cup\", 1.5));\n\n        // TODO 7: Add 3 saucers at 1.0 each to the order\n        fredOrder.addLineItem(new LineItem(\"saucer\", 1.0));\n        fredOrder.addLineItem(new LineItem(\"saucer\", 1.0));\n        fredOrder.addLineItem(new LineItem(\"saucer\", 1.0));\n\n        fredOrder.addLineItem(new LineItem(\"chair\", 12.50));\n        fredOrder.addLineItem(new LineItem(\"table\", 1.0));\n\n        Customer fred = new Customer(\"Fred\", \"London\");\n        fred.addOrder(fredOrder);\n        this.company.addCustomer(fred);\n\n        Order maryOrder = new Order();\n        maryOrder.addLineItem(new LineItem(\"cat\", 150.0));\n        maryOrder.addLineItem(new LineItem(\"big shed\", 500.0));\n\n        // TODO 7: Add 4 cups at 1.50 each to the order\n        maryOrder.addLineItem(new LineItem(\"cup\", 1.5));\n        maryOrder.addLineItem(new LineItem(\"cup\", 1.5));\n        maryOrder.addLineItem(new LineItem(\"cup\", 1.5));\n        maryOrder.addLineItem(new LineItem(\"cup\", 1.5));\n\n        // TODO 7: Add 4 saucers at 1.50 each to the order\n        maryOrder.addLineItem(new LineItem(\"saucer\", 1.5));\n        maryOrder.addLineItem(new LineItem(\"saucer\", 1.5));\n        maryOrder.addLineItem(new LineItem(\"saucer\", 1.5));\n        maryOrder.addLineItem(new LineItem(\"saucer\", 1.5));\n\n        maryOrder.addLineItem(new LineItem(\"sofa\", 120.0));\n        maryOrder.addLineItem(new LineItem(\"dog\", 75.0));\n\n        Customer mary = new Customer(\"Mary\", \"Liphook\");\n        mary.addOrder(maryOrder);\n        this.company.addCustomer(mary);\n\n        Order billOrder1 = new Order();\n        billOrder1.addLineItem(new LineItem(\"shed\", 50.0));\n\n        // TODO 7: Add 43 gnomes at 7.50 each to the order\n        for (int i = 0; i < 43; i++)\n        {\n            billOrder1.addLineItem(new LineItem(\"gnome\", 7.50));\n        }\n\n        Order billOrder2 = new Order();\n        billOrder2.addLineItem(new LineItem(\"bowl\", 1.25));\n        billOrder2.addLineItem(new LineItem(\"goldfish\", 0.50));\n\n        Order billOrder3 = new Order();\n        billOrder3.addLineItem(new LineItem(\"table\", 1.0));\n\n        Customer bill = new Customer(\"Bill\", \"London\");\n        bill.addOrder(billOrder1);\n        bill.addOrder(billOrder2);\n        bill.addOrder(billOrder3);\n\n        this.company.addCustomer(bill);\n    }\n}\n"
  },
  {
    "path": "src/test/java/com/gs/collections/kata/Exercise1Test.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport com.gs.collections.api.block.function.Function;\nimport com.gs.collections.api.list.MutableList;\nimport com.gs.collections.impl.list.mutable.FastList;\nimport com.gs.collections.impl.test.Verify;\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class Exercise1Test extends CompanyDomainForKata\n{\n    @Test\n    public void getCustomerNames()\n    {\n        Function<Customer, String> nameFunction = Customer::getName;\n\n        /**\n         * Get the name of each of the company's customers.\n         */\n        MutableList<Customer> customers = this.company.getCustomers();\n        MutableList<String> customerNames = null;\n\n        MutableList<String> expectedNames = FastList.newListWith(\"Fred\", \"Mary\", \"Bill\");\n        Assert.assertEquals(expectedNames, customerNames);\n    }\n\n    @Test\n    public void getCustomerCities()\n    {\n        /**\n         * Get the city for each of the company's customers.\n         */\n        MutableList<Customer> customers = this.company.getCustomers();\n        MutableList<String> customerCities = null;\n\n        MutableList<String> expectedCities = FastList.newListWith(\"London\", \"Liphook\", \"London\");\n        Assert.assertEquals(expectedCities, customerCities);\n    }\n\n    @Test\n    public void getLondonCustomers()\n    {\n        /**\n         * Which customers come from London? Get a collection of those which do.\n         */\n        MutableList<Customer> customers = this.company.getCustomers();\n        MutableList<Customer> customersFromLondon = null;\n        Verify.assertSize(\"Should be 2 London customers\", 2, customersFromLondon);\n    }\n}\n"
  },
  {
    "path": "src/test/java/com/gs/collections/kata/Exercise2Test.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport com.gs.collections.api.block.predicate.Predicate;\nimport com.gs.collections.api.list.MutableList;\nimport com.gs.collections.impl.test.Verify;\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class Exercise2Test extends CompanyDomainForKata\n{\n    /**\n     * Set up a {@link Predicate} that tests to see if a {@link Customer}'s city is \"London\"\n     */\n    private static final Predicate<Customer> CUSTOMER_FROM_LONDON = null;\n\n    @Test\n    public void customerFromLondonPredicate()\n    {\n        String predicateClass = CUSTOMER_FROM_LONDON.getClass().getSimpleName();\n        Assert.assertTrue(\n                \"Solution should use Predicates.attributeEquals() or a lambda but used \" + predicateClass,\n                \"AttributePredicate\".equals(predicateClass) || predicateClass.startsWith(\"Exercise2Test$$Lambda\"));\n\n        Customer customerFromLondon = new Customer(\"test customer\", \"London\");\n\n        Assert.assertEquals(\n                \"Implement Customer.TO_CITY\",\n                \"London\",\n                Customer.TO_CITY.valueOf(customerFromLondon));\n\n        Assert.assertTrue(\n                \"CUSTOMER_FROM_LONDON should accept Customers where city is London\",\n                CUSTOMER_FROM_LONDON.accept(customerFromLondon));\n    }\n\n    /**\n     * Do any customers come from London? Use the Predicate {@link #CUSTOMER_FROM_LONDON}.\n     */\n    @Test\n    public void doAnyCustomersLiveInLondon()\n    {\n        boolean anyCustomersFromLondon = false;\n        Assert.assertTrue(anyCustomersFromLondon);\n    }\n\n    /**\n     * Do all customers come from London? Use the Predicate {@link #CUSTOMER_FROM_LONDON}.\n     */\n    @Test\n    public void doAllCustomersLiveInLondon()\n    {\n        boolean allCustomersFromLondon = true;\n        Assert.assertFalse(allCustomersFromLondon);\n    }\n\n    /**\n     * How many customers come from London? Use the Predicate {@link #CUSTOMER_FROM_LONDON}.\n     */\n    @Test\n    public void howManyCustomersLiveInLondon()\n    {\n        int numberOfCustomerFromLondon = 0;\n        Assert.assertEquals(\"Should be 2 London customers\", 2, numberOfCustomerFromLondon);\n    }\n\n    /**\n     * Which customers come from London? Get a collection of those which do. Use the Predicate {@link\n     * #CUSTOMER_FROM_LONDON}.\n     */\n    @Test\n    public void getLondonCustomers()\n    {\n        MutableList<Customer> customersFromLondon = null;\n        Verify.assertSize(\"Should be 2 London customers\", 2, customersFromLondon);\n    }\n\n    /**\n     * Which customers do not come from London? Get a collection of those which don't. Use the Predicate {@link\n     * #CUSTOMER_FROM_LONDON}.\n     */\n    @Test\n    public void getCustomersWhoDontLiveInLondon()\n    {\n        MutableList<Customer> customersNotFromLondon = null;\n        Verify.assertSize(\"customers not from London\", 1, customersNotFromLondon);\n    }\n\n    /**\n     * Which customers come from London? Which customers do not come from London? Get a collection of each in a single pass.\n     * Use the Predicate {@link #CUSTOMER_FROM_LONDON}.\n     */\n    @Test\n    public void getCustomersWhoDoAndDoNotLiveInLondon()\n    {\n        MutableList<Customer> customersFromLondon = null;\n        MutableList<Customer> customersNotFromLondon = null;\n        Verify.assertSize(\"Should be 2 London customers\", 2, customersFromLondon);\n        Verify.assertSize(\"customers not from London\", 1, customersNotFromLondon);\n    }\n\n    /**\n     * Implement {@link Company#getCustomerNamed(String)} and get this test to pass.\n     */\n    @Test\n    public void findMary()\n    {\n        Customer mary = this.company.getCustomerNamed(\"Mary\");\n        Assert.assertEquals(\"customer's name should be Mary\", \"Mary\", mary.getName());\n    }\n\n    /**\n     * Implement {@link Company#getCustomerNamed(String)} and get this test to pass.\n     */\n    @Test\n    public void findPete()\n    {\n        Customer pete = this.company.getCustomerNamed(\"Pete\");\n        Assert.assertNull(\n                \"Should be null as there is no customer called Pete\",\n                pete);\n    }\n}\n"
  },
  {
    "path": "src/test/java/com/gs/collections/kata/Exercise3Test.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport com.gs.collections.api.list.MutableList;\nimport com.gs.collections.api.set.MutableSet;\nimport com.gs.collections.impl.list.mutable.FastList;\nimport com.gs.collections.impl.set.mutable.UnifiedSet;\nimport com.gs.collections.impl.test.Verify;\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class Exercise3Test extends CompanyDomainForKata\n{\n    /**\n     * Improve {@link Company#getOrders()} without breaking this test.\n     */\n    @Test\n    public void improveGetOrders()\n    {\n        // Delete this line - it's a reminder\n        Assert.fail(\"Improve getOrders() without breaking this test\");\n        Verify.assertSize(5, this.company.getOrders());\n    }\n\n    /**\n     * Get all items that have been ordered by anybody.\n     */\n    @Test\n    public void findItemNames()\n    {\n        MutableList<LineItem> allOrderedLineItems = null;\n        MutableSet<String> actualItemNames = null;\n\n        Verify.assertInstanceOf(MutableSet.class, actualItemNames);\n        Verify.assertInstanceOf(String.class, actualItemNames.getFirst());\n\n        MutableSet<String> expectedItemNames = UnifiedSet.newSetWith(\n                \"shed\", \"big shed\", \"bowl\", \"cat\", \"cup\", \"chair\", \"dog\",\n                \"goldfish\", \"gnome\", \"saucer\", \"sofa\", \"table\");\n        Assert.assertEquals(expectedItemNames, actualItemNames);\n    }\n\n    @Test\n    public void findCustomerNames()\n    {\n        MutableList<String> names = null;\n\n        MutableList<String> expectedNames = FastList.newListWith(\"Fred\", \"Mary\", \"Bill\");\n        Assert.assertEquals(expectedNames, names);\n    }\n}\n"
  },
  {
    "path": "src/test/java/com/gs/collections/kata/Exercise4Test.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport java.util.List;\n\nimport com.gs.collections.api.block.predicate.Predicate;\nimport com.gs.collections.api.list.MutableList;\nimport com.gs.collections.impl.list.mutable.FastList;\nimport com.gs.collections.impl.utility.ArrayIterate;\nimport com.gs.collections.impl.utility.Iterate;\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class Exercise4Test extends CompanyDomainForKata\n{\n    /**\n     * Solve this without changing the return type of {@link Company#getSuppliers()}. Find the appropriate method on\n     * {@link ArrayIterate}.\n     */\n    @Test\n    public void findSupplierNames()\n    {\n        MutableList<String> supplierNames = null;\n\n        MutableList<String> expectedSupplierNames = FastList.newListWith(\n                \"Shedtastic\",\n                \"Splendid Crocks\",\n                \"Annoying Pets\",\n                \"Gnomes 'R' Us\",\n                \"Furniture Hamlet\",\n                \"SFD\",\n                \"Doxins\");\n        Assert.assertEquals(expectedSupplierNames, supplierNames);\n    }\n\n    /**\n     * Create a {@link Predicate} for Suppliers that supply more than 2 items. Find the number of suppliers that\n     * satisfy that Predicate.\n     */\n    @Test\n    public void countSuppliersWithMoreThanTwoItems()\n    {\n        Predicate<Supplier> moreThanTwoItems = null;\n        int suppliersWithMoreThanTwoItems = 0;\n        Assert.assertEquals(\"suppliers with more than 2 items\", 5, suppliersWithMoreThanTwoItems);\n    }\n\n    /**\n     * Try to solve this without changing the return type of {@link Supplier#getItemNames()}.\n     */\n    @Test\n    public void whoSuppliesSandwichToaster()\n    {\n        // Create a Predicate that will check to see if a Supplier supplies a \"sandwich toaster\".\n        Predicate<Supplier> suppliesToaster = null;\n\n        // Find one supplier that supplies toasters.\n        Supplier toasterSupplier = null;\n        Assert.assertNotNull(\"toaster supplier\", toasterSupplier);\n        Assert.assertEquals(\"Doxins\", toasterSupplier.getName());\n    }\n\n    @Test\n    public void filterOrderValues()\n    {\n        List<Order> orders = this.company.getMostRecentCustomer().getOrders();\n        /**\n         * Get the order values that are greater than 1.5.\n         */\n        MutableList<Double> orderValues = null;\n        MutableList<Double> filtered = null;\n        Assert.assertEquals(FastList.newListWith(372.5, 1.75), filtered);\n    }\n\n    @Test\n    public void filterOrders()\n    {\n        List<Order> orders = this.company.getMostRecentCustomer().getOrders();\n        /**\n         * Get the actual orders (not their double values) where those orders have a value greater than 2.0.\n         */\n        MutableList<Order> filtered = null;\n        Assert.assertEquals(FastList.newListWith(Iterate.getFirst(this.company.getMostRecentCustomer().getOrders())), filtered);\n    }\n}\n"
  },
  {
    "path": "src/test/java/com/gs/collections/kata/Exercise5Test.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport java.util.List;\n\nimport com.gs.collections.api.list.MutableList;\nimport com.gs.collections.impl.block.factory.Predicates;\nimport com.gs.collections.impl.list.mutable.FastList;\nimport com.gs.collections.impl.test.Verify;\nimport com.gs.collections.impl.utility.Iterate;\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class Exercise5Test extends CompanyDomainForKata\n{\n    @Test\n    public void filterOrderValues()\n    {\n        List<Order> orders = this.company.getMostRecentCustomer().getOrders();\n        /**\n         * Same exercise but don't use static utility - refactor the type of orders and {@link Customer#getOrders()}\n         * instead.\n         * Get the order values that are greater than 1.5.\n         */\n        MutableList<Double> orderValues = null;\n        MutableList<Double> filtered = orderValues.select(Predicates.greaterThan(1.5));\n        Assert.assertEquals(FastList.newListWith(372.5, 1.75), filtered);\n        Verify.assertInstanceOf(MutableList.class, this.company.getMostRecentCustomer().getOrders());\n        this.company.getMostRecentCustomer().getOrders().add(null);\n        Verify.assertContains(\"Don't return a copy from Customer.getOrders(). The field should be a MutableList.\", null, this.company.getMostRecentCustomer().getOrders());\n    }\n\n    @Test\n    public void filterOrders()\n    {\n        List<Order> orders = this.company.getMostRecentCustomer().getOrders();\n        /**\n         * Same exercise but don't use static utility - refactor the type of orders and {@link Customer#getOrders()}\n         * instead.\n         * Get the actual orders (not their double values) where those orders have a value greater than 2.0.\n         */\n        MutableList<Order> filtered = null;\n        Assert.assertEquals(FastList.newListWith(Iterate.getFirst(this.company.getMostRecentCustomer().getOrders())), filtered);\n        Verify.assertInstanceOf(MutableList.class, this.company.getMostRecentCustomer().getOrders());\n        this.company.getMostRecentCustomer().getOrders().add(null);\n        Verify.assertContains(\"Don't return a copy from Customer.getOrders(). The field should be a MutableList.\", null, this.company.getMostRecentCustomer().getOrders());\n    }\n}\n"
  },
  {
    "path": "src/test/java/com/gs/collections/kata/Exercise6Test.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport com.gs.collections.api.RichIterable;\nimport com.gs.collections.api.block.procedure.Procedure;\nimport com.gs.collections.api.list.MutableList;\nimport com.gs.collections.impl.block.factory.Procedures;\nimport com.gs.collections.impl.test.Verify;\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class Exercise6Test extends CompanyDomainForKata\n{\n    /**\n     * Get a list of the customers' total order values, sorted. Check out the implementation of {@link\n     * Customer#getTotalOrderValue()} and {@link Order#getValue()} .\n     */\n    @Test\n    public void sortedTotalOrderValue()\n    {\n        MutableList<Double> sortedTotalValues = null;\n\n        // Don't forget the handy utility methods getFirst() and getLast()...\n        Assert.assertEquals(\"Highest total order value\", Double.valueOf(857.0), sortedTotalValues.getLast());\n        Assert.assertEquals(\"Lowest total order value\", Double.valueOf(71.0), sortedTotalValues.getFirst());\n    }\n\n    /**\n     * Find the max total order value across all customers.\n     */\n    @Test\n    public void maximumTotalOrderValue()\n    {\n        Double maximumTotalOrderValue = null;\n        Assert.assertEquals(\"max value\", Double.valueOf(857.0), maximumTotalOrderValue);\n    }\n\n    /**\n     * Find the customer with the highest total order value.\n     */\n    @Test\n    public void customerWithMaxTotalOrderValue()\n    {\n        Customer customerWithMaxTotalOrderValue = null;\n        Assert.assertEquals(this.company.getCustomerNamed(\"Mary\"), customerWithMaxTotalOrderValue);\n    }\n\n    /**\n     * Create some code to get the company's supplier names as a tilde delimited string.\n     */\n    @Test\n    public void supplierNamesAsTildeDelimitedString()\n    {\n        String tildeSeparatedNames = null;\n        Assert.assertEquals(\n                \"tilde separated names\",\n                \"Shedtastic~Splendid Crocks~Annoying Pets~Gnomes 'R' Us~Furniture Hamlet~SFD~Doxins\",\n                tildeSeparatedNames);\n    }\n\n    /**\n     * Deliver all orders going to customers from London.\n     * <p>\n     * Hint: Use {@link RichIterable#forEach(Procedure)}. To solve the ambiguity error, use {@link Procedures#cast(Procedure)}}.\n     *\n     * @see Order#deliver()\n     */\n    @Test\n    public void deliverOrdersToLondon()\n    {\n        Verify.assertAllSatisfy(this.company.getCustomerNamed(\"Fred\").getOrders(), Order::isDelivered);\n        Verify.assertNoneSatisfy(this.company.getCustomerNamed(\"Mary\").getOrders(), Order::isDelivered);\n        Verify.assertAllSatisfy(this.company.getCustomerNamed(\"Bill\").getOrders(), Order::isDelivered);\n    }\n}\n"
  },
  {
    "path": "src/test/java/com/gs/collections/kata/Exercise7Test.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport java.util.List;\n\nimport com.gs.collections.api.map.MutableMap;\nimport com.gs.collections.api.multimap.list.MutableListMultimap;\nimport com.gs.collections.impl.list.mutable.FastList;\nimport com.gs.collections.impl.map.mutable.UnifiedMap;\nimport com.gs.collections.impl.test.Verify;\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class Exercise7Test extends CompanyDomainForKata\n{\n    /**\n     * Create a multimap where the keys are the names of cities and the values are the customers from those cities.\n     */\n    @Test\n    public void customersByCity()\n    {\n        // Notice that the second generic type is Customer, not List<Customer>\n        MutableListMultimap<String, Customer> multimap = null;\n\n        Assert.assertEquals(FastList.newListWith(this.company.getCustomerNamed(\"Mary\")), multimap.get(\"Liphook\"));\n        Assert.assertEquals(\n                FastList.newListWith(\n                        this.company.getCustomerNamed(\"Fred\"),\n                        this.company.getCustomerNamed(\"Bill\")),\n                multimap.get(\"London\"));\n    }\n\n    @Test\n    public void mapOfItemsToSuppliers()\n    {\n        Assert.fail(\"Refactor this as part of Exercise 7\");\n        /**\n         * Change itemsToSuppliers to a MutableMultimap<String, Supplier>\n         */\n        final MutableMap<String, List<Supplier>> itemsToSuppliers = UnifiedMap.newMap();\n\n        for (Supplier supplier : this.company.getSuppliers())\n        {\n            for (String itemName : supplier.getItemNames())\n            {\n                List<Supplier> suppliersForItem;\n                if (itemsToSuppliers.containsKey(itemName))\n                {\n                    suppliersForItem = itemsToSuppliers.get(itemName);\n                }\n                else\n                {\n                    suppliersForItem = FastList.newList();\n                    itemsToSuppliers.put(itemName, suppliersForItem);\n                }\n\n                suppliersForItem.add(supplier);\n            }\n        }\n        Verify.assertIterableSize(\"should be 2 suppliers for sofa\", 2, itemsToSuppliers.get(\"sofa\"));\n    }\n\n    @Test\n    public void reminder()\n    {\n        Assert.fail(\"Refactor setUpCustomersAndOrders() in the super class to not have so much repetition.\");\n        // Delete this whole method when you're done. It's just a reminder.\n    }\n}\n"
  },
  {
    "path": "src/test/java/com/gs/collections/kata/Exercise8Test.java",
    "content": "/*\n * Copyright 2015 Goldman Sachs.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.gs.collections.kata;\n\nimport java.util.Collections;\n\nimport com.gs.collections.api.RichIterable;\nimport com.gs.collections.api.bag.sorted.MutableSortedBag;\nimport com.gs.collections.api.block.function.Function;\nimport com.gs.collections.api.block.function.Function0;\nimport com.gs.collections.api.block.function.Function2;\nimport com.gs.collections.api.list.MutableList;\nimport com.gs.collections.api.map.MutableMap;\nimport com.gs.collections.api.multimap.list.MutableListMultimap;\nimport com.gs.collections.impl.bag.sorted.mutable.TreeBag;\nimport com.gs.collections.impl.list.mutable.FastList;\nimport com.gs.collections.impl.test.Verify;\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class Exercise8Test extends CompanyDomainForKata\n{\n    /**\n     * Extra credit. Aggregate the total order values by city.\n     *\n     * @see RichIterable#aggregateBy(Function, Function0, Function2)\n     */\n    @Test\n    public void totalOrderValuesByCity()\n    {\n        Function0<Double> zeroValueFactory = () -> 0.0;\n        Function2<Double, Customer, Double> aggregator = (result, customer) -> result + customer.getTotalOrderValue();\n\n        MutableMap<String, Double> map = null;\n        Assert.assertEquals(2, map.size());\n        Assert.assertEquals(446.25, map.get(\"London\"), 0.0);\n        Assert.assertEquals(857.0, map.get(\"Liphook\"), 0.0);\n    }\n\n    /**\n     * Extra credit. Aggregate the total order values by item.\n     * Hint: Look at {@link RichIterable#aggregateBy(Function, Function0, Function2)} and remember\n     * how to use {@link RichIterable#flatCollect(Function)} to get an iterable of all items.\n     */\n    @Test\n    public void totalOrderValuesByItem()\n    {\n        Function0<Double> zeroValueFactory = () -> 0.0;\n        Function2<Double, LineItem, Double> aggregator = (result, lineItem) -> result + lineItem.getValue();\n\n        MutableMap<String, Double> map = null;\n        Verify.assertSize(12, map);\n        Assert.assertEquals(100.0, map.get(\"shed\"), 0.0);\n        Assert.assertEquals(10.5, map.get(\"cup\"), 0.0);\n    }\n\n    /**\n     * Extra credit. Find all customers' line item values greater than 7.5 and sort them by highest to lowest price.\n     */\n    @Test\n    public void sortedOrders()\n    {\n        MutableSortedBag<Double> orderedPrices = null;\n\n        MutableSortedBag<Double> expectedPrices = TreeBag.newBagWith(\n                Collections.reverseOrder(), 500.0, 150.0, 120.0, 75.0, 50.0, 50.0, 12.5);\n        Verify.assertSortedBagsEqual(expectedPrices, orderedPrices);\n    }\n\n    /**\n     * Extra credit. Figure out which customers ordered saucers (in any of their orders).\n     */\n    @Test\n    public void whoOrderedSaucers()\n    {\n        MutableList<Customer> customersWithSaucers = null;\n        Verify.assertSize(\"customers with saucers\", 2, customersWithSaucers);\n    }\n\n    /**\n     * Extra credit. Look into the {@link MutableList#toMap(Function, Function)} method.\n     */\n    @Test\n    public void ordersByCustomerUsingAsMap()\n    {\n        MutableMap<String, MutableList<Order>> customerNameToOrders =\n                this.company.getCustomers().toMap(null, null);\n\n        Assert.assertNotNull(\"customer name to orders\", customerNameToOrders);\n        Verify.assertSize(\"customer names\", 3, customerNameToOrders);\n        MutableList<Order> ordersForBill = customerNameToOrders.get(\"Bill\");\n        Verify.assertSize(\"Bill orders\", 3, ordersForBill);\n    }\n\n    /**\n     * Extra credit. Create a multimap where the values are customers and the key is the price of\n     * the most expensive item that the customer ordered.\n     */\n    @Test\n    public void mostExpensiveItem()\n    {\n        MutableListMultimap<Double, Customer> multimap = null;\n        Assert.assertEquals(3, multimap.size());\n        Assert.assertEquals(2, multimap.keysView().size());\n        Assert.assertEquals(\n                FastList.newListWith(\n                        this.company.getCustomerNamed(\"Fred\"),\n                        this.company.getCustomerNamed(\"Bill\")),\n                multimap.get(50.0));\n    }\n}\n"
  }
]