Example usage for java.util Optional get

List of usage examples for java.util Optional get

Introduction

In this page you can find the example usage for java.util Optional get.

Prototype

public T get() 

Source Link

Document

If a value is present, returns the value, otherwise throws NoSuchElementException .

Usage

From source file:org.trustedanalytics.serviceinfo.MqttServiceInfoCreator.java

@Override
public boolean accept(Map<String, Object> serviceData) {
    Optional<String> label = Optional.ofNullable((String) serviceData.get("label"));
    if (label.isPresent()) {
        return label.get().equals(MQTT_ID);
    }/*from  w ww  . ja v a2 s . c  om*/
    return false;
}

From source file:it.polimi.diceH2020.launcher.service.Validator.java

public boolean validateJobProfile(Path pathToFile) {
    Optional<JobProfilesMap> sol = objectFromPath(pathToFile, JobProfilesMap.class);
    return (sol.isPresent() && sol.get().validate());
}

From source file:cz.muni.fi.editor.database.dao.CmisObjectDAOImpl.java

@Override
public void deleteByCmisID(String objectID) {
    Optional<CmisObjectDB> result = getByCmisID(objectID);
    if (result.isPresent()) {
        getEntityManager().remove(result.get());
    }/*  w  w  w . j av a  2 s.  c  o  m*/
}

From source file:io.helixservice.feature.configuration.locator.AbstractResourceLocator.java

/**
 * {@inheritDoc}//  www  .  jav  a2s.c o  m
 */
@Override
public Optional<JsonObject> getJsonObject(String resourcePath) {
    Optional<String> string = getString(resourcePath);

    if (string.isPresent()) {
        return Optional.of(new JsonObject(string.get()));
    } else {
        return Optional.empty();
    }
}

From source file:com.rcs.shoe.shop.fx.controller.ui.Controller.java

protected boolean showConfirmPopup(String title, String header, String contentText) {
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle(title);//  w  ww . ja  v  a 2  s  . c o m
    alert.setHeaderText(header);
    alert.setContentText(contentText);

    ButtonType okButton = new ButtonType("Da", ButtonBar.ButtonData.OK_DONE);
    ButtonType cancelButton = new ButtonType("Ne", ButtonBar.ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(okButton, cancelButton);

    Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
    stage.getIcons().add(uIConfig.getIcon());

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get().getButtonData() == ButtonBar.ButtonData.OK_DONE) {
        return true;
    }
    return false;
}

From source file:it.polimi.diceH2020.launcher.service.Validator.java

public boolean validateClassParameters(Path pathToFile) {
    Optional<ClassParametersMap> sol = objectFromPath(pathToFile, ClassParametersMap.class);
    return (sol.isPresent() && sol.get().validate());
}

From source file:com.amazonaws.service.apigateway.importer.config.AwsConfig.java

public void load() {
    Optional<String> region = loadRegion();

    if (region.isPresent()) {
        this.region = region.get();
    } else {//from w  w  w.j a v a 2  s  .  c om
        this.region = DEFAULT_REGION;
        LOG.warn("Could not load region configuration. Please ensure AWS CLI is "
                + "configured via 'aws configure'. Will use default region of " + this.region);
    }
}

From source file:it.polimi.diceH2020.launcher.service.Validator.java

public boolean validateVMConfigurations(Path pathToFile) {
    Optional<VMConfigurationsMap> sol = objectFromPath(pathToFile, VMConfigurationsMap.class);
    return (sol.isPresent() && sol.get().validate());
}

From source file:example.springdata.jpa.multipleds.customer.CustomerRepositoryTests.java

@Test
public void findsCustomerByLastname() {

    Optional<Customer> result = repository.findByLastname("Matthews");

    assertThat(result, is(not(Optional.empty())));
    assertThat(result.get().getFirstname(), is("Dave"));
}

From source file:cloudfoundry.norouter.f5.dropsonde.LoggingPoolPopulator.java

private boolean containsSelf(Optional<Collection<PoolMember>> poolMembers, InetSocketAddress poolMember) {
    return poolMembers.isPresent() && poolMembers.get().stream()
            .filter(member -> member.getName().equalsIgnoreCase(poolMember.toString())).findFirst().isPresent();
}