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:org.everit.json.schema.internal.EmailFormatValidator.java

@Override
public Optional<String> validate(final String subject) {
    if (EmailValidator.getInstance(false, true).isValid(subject)) {
        return Optional.absent();
    }// w  ww .  j  ava 2 s  .  c o  m
    return Optional.of(String.format("[%s] is not a valid email address", subject));
}

From source file:org.sonar.server.computation.scm.DbScmInfo.java

static Optional<ScmInfo> create(Component component, Iterable<DbFileSources.Line> lines) {
    LineToChangeset lineToChangeset = new LineToChangeset();
    List<Changeset> lineChangesets = from(lines).transform(lineToChangeset).filter(notNull()).toList();
    if (lineChangesets.isEmpty()) {
        return Optional.absent();
    }//from  w ww.j  a  va 2s .c o m
    checkState(!lineToChangeset.isEncounteredLineWithoutScmInfo(), format(
            "Partial scm information stored in DB for component '%s'. Not all lines have SCM info. Can not proceed",
            component));
    return Optional.<ScmInfo>of(new DbScmInfo(new ScmInfoImpl(lineChangesets)));
}

From source file:dagger2.internal.codegen.ValidationType.java

Optional<Diagnostic.Kind> diagnosticKind() {
    switch (this) {
    case ERROR:/*w ww. ja v a2s  .c om*/
        return Optional.of(Diagnostic.Kind.ERROR);
    case WARNING:
        return Optional.of(Diagnostic.Kind.WARNING);
    default:
        return Optional.absent();
    }
}

From source file:org.opendaylight.controller.config.util.capability.BasicCapability.java

@Override
public Optional<String> getRevision() {
    return Optional.absent();
}

From source file:org.stilavia.service.zalando.RequestChain.java

public RequestChain(RequestContext context, String path) {
    Preconditions.checkNotNull(context);
    this.context = context;
    this.path = path;
    this.parent = Optional.absent();
}

From source file:extrabiomes.module.amica.thermalexpansion.ThermalExpansionAPI.java

ThermalExpansionAPI() {
    try {//  w ww  . j a  va2  s .  c om
        final Class cls = Class.forName("thermalexpansion.api.crafting.CraftingHelpers");
        addSawmillLogToPlankRecipe = Optional
                .fromNullable(cls.getMethod("addSawmillLogToPlankRecipe", ItemStack.class, ItemStack.class));
        craftingHelpers = Optional.of(cls.newInstance());
    } catch (final Exception e) {
        e.printStackTrace();
        craftingHelpers = Optional.absent();
        addSawmillLogToPlankRecipe = Optional.absent();
    }
}

From source file:dagger.internal.codegen.writer.FieldWriter.java

FieldWriter(TypeName type, String name) {
    super(type, name);
    this.initializer = Optional.absent();
}

From source file:com.stepstone.sonar.plugin.coldfusion.cflint.xml.TagAttribute.java

protected Optional<String> getAttributeValue(String name, XMLStreamReader stream) {

    for (int i = 0; i < stream.getAttributeCount(); i++) {

        if (name.equalsIgnoreCase(stream.getAttributeLocalName(i))) {
            return Optional.of(StringUtils.trimToEmpty(stream.getAttributeValue(i)));
        }/*from w  w  w .ja  v a  2 s .  c  o m*/
    }

    return Optional.absent();
}

From source file:io.mesosphere.mesos.frameworks.cassandra.ZooKeeperSeedProviderConfig.java

private static Optional<Integer> optionalInteger(String key, Map<String, String> parameters) {
    Optional<String> stringOption = optionalString(key, parameters);

    if (stringOption.isPresent()) {

        try {/*from   www  .  j  a va 2s.c om*/

            return Optional.fromNullable(Integer.parseInt(stringOption.get()));

        } catch (NumberFormatException nfe) {

            LOGGER.error(String.format("failed to parse %s", key), nfe);

            return Optional.absent();
        }

    } else {
        return Optional.absent();
    }

}

From source file:com.facebook.buck.apple.simulator.AppleSimulatorProfileParsing.java

public static Optional<AppleSimulatorProfile> parseProfilePlistStream(InputStream inputStream)
        throws IOException {
    NSDictionary profile;/*from www.  ja  va2 s  .  co m*/
    try (BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)) {
        try {
            profile = (NSDictionary) PropertyListParser.parse(bufferedInputStream);
        } catch (Exception e) {
            throw new IOException(e);
        }
    }

    NSObject supportedProductFamilyIDsObject = profile.objectForKey("supportedProductFamilyIDs");
    if (!(supportedProductFamilyIDsObject instanceof NSArray)) {
        LOG.warn("Invalid simulator profile.plist (supportedProductFamilyIDs missing or not an array)");
        return Optional.absent();
    }
    NSArray supportedProductFamilyIDs = (NSArray) supportedProductFamilyIDsObject;

    AppleSimulatorProfile.Builder profileBuilder = AppleSimulatorProfile.builder();
    for (NSObject supportedProductFamilyID : supportedProductFamilyIDs.getArray()) {
        if (supportedProductFamilyID instanceof NSNumber) {
            profileBuilder.addSupportedProductFamilyIDs(((NSNumber) supportedProductFamilyID).intValue());
        } else {
            LOG.warn("Invalid simulator profile.plist (supportedProductFamilyIDs contains non-number %s)",
                    supportedProductFamilyID);
            return Optional.absent();
        }
    }

    NSObject supportedArchsObject = profile.objectForKey("supportedArchs");
    if (!(supportedArchsObject instanceof NSArray)) {
        LOG.warn("Invalid simulator profile.plist (supportedArchs missing or not an array)");
        return Optional.absent();
    }
    NSArray supportedArchs = (NSArray) supportedArchsObject;
    for (NSObject supportedArch : supportedArchs.getArray()) {
        profileBuilder.addSupportedArchitectures(supportedArch.toString());
    }

    return Optional.of(profileBuilder.build());
}