/*
 * Copyright (c) 2011-2017 Nexmo Inc
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package com.nexmo.quickstart.numbers;

import com.nexmo.client.NexmoClient;
import com.nexmo.client.numbers.ListNumbersResponse;
import com.nexmo.client.numbers.OwnedNumber;

import static com.nexmo.quickstart.Util.configureLogging;
import static com.nexmo.quickstart.Util.envVar;

public class ListNumbers {
    public static void main(String[] args) throws Exception {
        configureLogging();

        String NEXMO_API_KEY = envVar("NEXMO_API_KEY");
        String NEXMO_API_SECRET = envVar("NEXMO_API_SECRET");


        NexmoClient client = NexmoClient.builder().apiKey(NEXMO_API_KEY).apiSecret(NEXMO_API_SECRET).build();
        ListNumbersResponse response = client.getNumbersClient().listNumbers();
        for (OwnedNumber ownedNumber : response.getNumbers()) {
            System.out.println("Tel: " + ownedNumber.getMsisdn());
            System.out.println("Country: " + ownedNumber.getCountry());
            System.out.println("------------");
        }
    }
}

@@ -1224,72 +1224,9 @@
 ers.
-ListNumbersResponse;%0Aimport com.nexmo.client.numbers.OwnedNumber
+*
 ;%0A%0Ai
@@ -1367,21 +1367,22 @@
    p
-ublic
+rivate
  static 
 void
@@ -1381,88 +1381,86 @@
 tic 
-void main(String%5B%5D args) throws Exception %7B%0A        configureLogging(
+final String NEXMO_API_KEY = envVar(%22NEXMO_API_KEY%22
 );%0A
-%0A
     
-   
+private static final
  Str
@@ -1465,35 +1465,38 @@
 tring NEXMO_API_
-KEY
+SECRET
  = envVar(%22NEXMO
@@ -1500,27 +1500,30 @@
 XMO_API_
-KEY
+SECRET
 %22);%0A    
     Stri
@@ -1518,66 +1518,287 @@
     
-    String NEXMO_API_SECRET = envVar(%22NEXMO_API_SECRET%22);%0A
+private static final String NUMBER_SEARCH_CRITERIA = envVar(%22NUMBER_SEARCH_CRITERIA%22);%0A    private static final SearchPattern NUMBER_SEARCH_PATTERN = SearchPattern.valueOf(envVar(%22NUMBER_SEARCH_PATTERN%22));%0A%0A    public static void main(String%5B%5D args) %7B%0A        configureLogging();
 %0A%0A  
@@ -1845,16 +1845,33 @@
 uilder()
+%0A                
 .apiKey(
@@ -1884,16 +1884,33 @@
 API_KEY)
+%0A                
 .apiSecr
@@ -1933,17 +1933,101 @@
 RET)
-.build();
+%0A                .build();%0A%0A        NumbersClient numbersClient = client.getNumbersClient();%0A
 %0A   
@@ -2062,27 +2062,17 @@
 ponse = 
-client.getN
+n
 umbersCl
@@ -2075,18 +2075,16 @@
 rsClient
-()
 .listNum
@@ -2088,19 +2088,121 @@
 Numbers(
+%0A                new ListNumbersFilter(1, 10, NUMBER_SEARCH_CRITERIA, NUMBER_SEARCH_PATTERN)%0A        
 );%0A
+%0A
         
@@ -2218,22 +2218,17 @@
 dNumber 
-ownedN
+n
 umber : 
@@ -2289,30 +2289,25 @@
 n(%22Tel: %22 + 
-ownedN
+n
 umber.getMsi
@@ -2350,27 +2350,19 @@
 ln(%22
-Country: %22 + ownedN
+Type: %22 + n
 umbe
@@ -2370,15 +2370,12 @@
 .get
-Country
+Type
 ());
@@ -2411,21 +2411,40 @@
 ln(%22
-------------%22
+Country: %22 + number.getCountry()
 );%0A 

Update list example to show criteria and pattern.