Example usage for com.google.common.base Optional absent

List of usage examples for com.google.common.base Optional absent

Introduction

In this page you can find the example usage for com.google.common.base Optional absent.

Prototype

public static <T> Optional<T> absent() 

Source Link

Document

Returns an Optional instance with no contained reference.

Usage

From source file:springfox.documentation.swagger.schema.ApiModelPropertyPropertyBuilder.java

@Override
public void apply(ModelPropertyContext context) {
    Optional<ApiModelProperty> annotation = Optional.absent();

    if (context.getAnnotatedElement().isPresent()) {
        annotation = annotation.or(findApiModePropertyAnnotation(context.getAnnotatedElement().get()));
    }//  ww  w .  j a v  a 2s . c om
    if (context.getBeanPropertyDefinition().isPresent()) {
        annotation = annotation
                .or(findPropertyAnnotation(context.getBeanPropertyDefinition().get(), ApiModelProperty.class));
    }
    if (annotation.isPresent()) {
        context.getBuilder().allowableValues(annotation.transform(toAllowableValues()).orNull())
                .required(annotation.transform(toIsRequired()).or(false))
                .readOnly(annotation.transform(toIsReadOnly()).or(false))
                .description(annotation.transform(toDescription()).orNull())
                .isHidden(annotation.transform(toHidden()).or(false))
                .type(annotation.transform(toType(context.getResolver())).orNull())
                .position(annotation.transform(toPosition()).or(0))
                .example(annotation.transform(toExample()).orNull());
    }
}

From source file:org.mayocat.shop.payment.AbstractGatewayFactory.java

/**
 * @return this gateway global (server-level) configuration file
 *
 * @param fileName the name of the file to retrieve
 *//*w w w.  jav  a2 s . c  o m*/
protected Optional<File> getTenantConfigurationFile(String fileName) {
    if (this.context.getTenant() == null) {
        return Optional.absent();
    }
    return Optional.of(filesSettings.getPermanentDirectory().resolve(TENANTS_DIRECTORY)
            .resolve(this.context.getTenant().getSlug()).resolve(PAYMENTS_DIRECTORY).resolve(this.getId())
            .resolve(fileName).toFile());
}

From source file:org.vincibean.salestaxes.jaxb.JaxbFactory.java

/**
 * Factory method, creates a {@link Marshaller} from the context given in the constructor; moreover, ensure that
 * the marshalled XML data is formatted with linefeeds and indentation.  
 * @return an {@link Optional} object which may or may not contain a {@link Marshaller}
 *///from w  w w.j  a  va 2 s  . c om
public static Optional<Marshaller> createMarshaller(final Class<?> context) {
    try {
        Marshaller marshaller = JAXBContext.newInstance(context).createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.setSchema(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
                .newSchema(new ClassPathResource("receipt/Poiuyt.xsd").getFile()));
        marshaller.setEventHandler(new FoobarValidationEventHandler());
        return Optional.fromNullable(marshaller);
    } catch (JAXBException | SAXException | IOException e) {
        logger.warn("Exception on jaxb factory creation: ", e);
        return Optional.absent();
    }
}

From source file:org.apache.druid.server.router.TimeBoundaryTieredBrokerSelectorStrategy.java

@Override
public Optional<String> getBrokerServiceName(TieredBrokerConfig tierConfig, Query query) {
    // Somewhat janky way of always selecting highest priority broker for this type of query
    if (query instanceof TimeBoundaryQuery) {
        return Optional.of(Iterables.getFirst(tierConfig.getTierToBrokerMap().values(),
                tierConfig.getDefaultBrokerServiceName()));
    }/*from   w  w  w .  j ava 2 s.com*/

    return Optional.absent();
}

From source file:org.eclipse.mylyn.internal.wikitext.commonmark.inlines.InlineParser.java

static List<Inline> secondPass(List<Inline> inlines) {
    List<Inline> processedInlines = ImmutableList.copyOf(inlines);
    Optional<InlinesSubstitution> substitution = Optional.absent();
    do {/*from  ww  w  .jav  a2s  .c  om*/
        for (Inline inline : processedInlines) {
            substitution = inline.secondPass(processedInlines);
            if (substitution.isPresent()) {
                processedInlines = substitution.get().apply(processedInlines);
                break;
            }
        }
    } while (substitution.isPresent());
    return processedInlines;
}

From source file:org.zanata.email.AbstractEmailStrategy.java

/**
 * Returns the From address to be used for this email.
 * If absent, use the default From address configured by the server
 *//*from w ww.  j ava  2s. co  m*/
public Optional<InternetAddress> getFromAddress() {
    return Optional.absent();
}

From source file:org.apache.aurora.scheduler.quota.QuotaCheckResult.java

@VisibleForTesting
public QuotaCheckResult(Result result) {
    this(result, Optional.absent());
}

From source file:org.brooklyncentral.catalog.scrape.CatalogItemScraper.java

private static CatalogItem parseCatalogItem(String repoUrl) {
    //TODO Properly handle required vs. optional failures

    String[] urlTokens = repoUrl.split("/");

    String repoName = urlTokens[urlTokens.length - 1];
    String author = urlTokens[urlTokens.length - 2];

    Optional<String> description = getGithubRawText(repoUrl, "README.md");
    Optional<String> documentation = getGithubRawText(repoUrl, "items.js");

    Optional<String> catalogBomString = getGithubRawText(repoUrl, "catalog.bom");
    @SuppressWarnings("unchecked")
    Map<String, Object> catalogBomYaml = (Map<String, Object>) Yamls.parseAll(catalogBomString.get()).iterator()
            .next();//from  w w  w  . ja  va  2  s  .  c  o  m

    Optional<String> masterCommitHash = Optional.absent();

    Optional<String> license;
    String licenseUrl = generateRawGithubUrl(repoUrl, "LICENSE.txt");

    if (urlExists(licenseUrl)) {
        license = Optional.of(getGithubRawText(repoUrl, "LICENSE.txt").get());
    } else {
        license = Optional.absent();
    }

    Optional<String> changelog;
    String changelogUrl = generateRawGithubUrl(repoUrl, "CHANGELOG.md");

    if (urlExists(changelogUrl)) {
        changelog = Optional.of(getGithubRawText(repoUrl, "CHANGELOG.md").get());
    } else {
        changelog = Optional.absent();
    }

    //TODO Actually create CatalogItem
    return null;
}

From source file:org.apache.gobblin.metrics.kafka.LoggingPusher.java

public LoggingPusher() {
    this(NO_BROKERS, NO_TOPIC, Optional.absent());
}

From source file:info.rynkowski.hamsterclient.data.repository.datasources.db.entities.mapper.DbFactMapper.java

public @Nonnull Fact transform(@Nonnull DbFact dbFact) {
    Calendar startTime = dbFact.getStartTime().getCalendar();

    Optional<Calendar> endTime = Optional.absent();
    if (dbFact.getEndTime().isPresent()) {
        endTime = Optional.of(dbFact.getEndTime().get().getCalendar());
    }/*from   w w w .  j  a v a2s.c o  m*/

    return new Fact.Builder() //
            .id(dbFact.getId()).activity(dbFact.getActivity()).category(dbFact.getCategory())
            .startTime(startTime).endTime(endTime).description(dbFact.getDescription()).tags(dbFact.getTags())
            .build();
}