Package com.google.common.base

Examples of com.google.common.base.Optional$Present

A common alternative to using this class is to find or create a suitable null object for the type in question.

This class is not intended as a direct analogue of any existing "option" or "maybe" construct from other programming environments, though it may bear some similarities. @param < T> the type of instance that can be contained. {@code Optional} is naturallycovariant on this type, so it is safe to cast an {@code Optional} to {@code Optional} for any supertype {@code S} of {@code T}. @author Kurt Alfred Kluever @author Kevin Bourrillion @since Guava release 10


      }
    };
  }

  public static void selectComboBoxItem(JComboBox jComboBox, String name) {
    Optional itemToSelect = Optional.absent();
    for (int i = 0; i < jComboBox.getItemCount(); i++) {
      final Object item = jComboBox.getItemAt(i);
      if (name.equals(item.toString())) {
        itemToSelect = Optional.of(item);
      }
    }
    if (itemToSelect.isPresent()) jComboBox.setSelectedItem(itemToSelect.get());
  }
View Full Code Here


      final NovaApi api = createMock(NovaApi.class);
      KeyPairApi keyApi = createMock(KeyPairApi.class);

      KeyPair pair = createMock(KeyPair.class);

      Optional optKeyApi = Optional.of(keyApi);
     
      expect(api.getKeyPairExtensionForZone("zone")).andReturn(optKeyApi).atLeastOnce();

      expect(keyApi.create("group-1")).andReturn(pair);
View Full Code Here

      final NovaApi api = createMock(NovaApi.class);
      KeyPairApi keyApi = createMock(KeyPairApi.class);

      KeyPair pair = createMock(KeyPair.class);

      Optional optKeyApi = Optional.of(keyApi);
     
      expect(api.getKeyPairExtensionForZone("zone")).andReturn(optKeyApi).atLeastOnce();

      expect(keyApi.create("group-1")).andReturn(pair);
View Full Code Here

        if (batchResponse.size() < collapsedRequests.size()) {
            throw new RuntimeException(createMessage(collapsedRequests, batchResponse));
        }
        int count = 0;
        for (CollapsedRequest<Object, Object> request : collapsedRequests) {
            Optional response = batchResponse.get(count++);
            if (response.isPresent()) { // allows prevent IllegalStateException
                request.setResponse(response.get());
            }
        }
    }
View Full Code Here

      final NovaApi api = createMock(NovaApi.class);
      KeyPairApi keyApi = createMock(KeyPairApi.class);

      KeyPair pair = createMock(KeyPair.class);

      Optional optKeyApi = Optional.of(keyApi);
     
      expect(api.getKeyPairExtensionForZone("zone")).andReturn(optKeyApi).atLeastOnce();

      expect(keyApi.create("group-1")).andReturn(pair);
View Full Code Here

      final NovaApi api = createMock(NovaApi.class);
      KeyPairApi keyApi = createMock(KeyPairApi.class);

      KeyPair pair = createMock(KeyPair.class);

      Optional optKeyApi = Optional.of(keyApi);

      expect(api.getKeyPairApi("region")).andReturn(optKeyApi).atLeastOnce();

      expect(keyApi.create("group-1")).andReturn(pair);
View Full Code Here

TOP

Related Classes of com.google.common.base.Optional$Present

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.