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:com.dangdang.ddframe.rdb.sharding.parsing.parser.dialect.oracle.OracleParser.java

@Override
public Optional<String> parseAlias() {
    if (equalAny(OracleKeyword.CONNECT)) {
        return Optional.absent();
    }//  ww  w .  j  a  v a  2s.co m
    return super.parseAlias();
}

From source file:org.opendaylight.faas.fabric.general.FabricInstanceCache.java

Optional<UnderlayerNetworkType> getFabricType(FabricId fabricId) {
    Optional<FabricInstance> instance = Optional.fromNullable(cache.get(fabricId));
    if (instance.isPresent()) {
        return Optional.of(instance.get().getType());
    } else {/*from ww  w. jav  a2s . co m*/
        return Optional.absent();
    }
}

From source file:se.sics.ktoolbox.util.Either.java

public Optional<L> getOptionalLeft() {
    if (this.isRight()) {
        return Optional.fromNullable(this.getLeft());
    } else {//from   w  w  w .  j  av a 2  s. c  o  m
        return Optional.absent();
    }
}

From source file:be.nbb.demetra.dfm.output.FactorView.java

public FactorView() {
    setLayout(new BorderLayout());
    dfmResults = Optional.absent();
    factorChart = new FactorChart();

    comboBox = new JComboBox();

    comboBox.addItemListener((ItemEvent e) -> {
        updateChart();/*from   www .ja  v  a 2  s .  co  m*/
    });

    addPropertyChangeListener((PropertyChangeEvent evt) -> {
        switch (evt.getPropertyName()) {
        case DFM_RESULTS_PROPERTY:
            updateComboBox();
            updateChart();
            break;
        }
    });

    updateComboBox();
    updateChart();

    add(comboBox, BorderLayout.NORTH);
    add(factorChart, BorderLayout.CENTER);
}

From source file:appeng.core.features.ItemDefinition.java

public ItemDefinition(final Item item, final ActivityState state) {
    Preconditions.checkNotNull(item);//from   w w  w  .  ja  va 2 s .  c  o  m
    Preconditions.checkNotNull(state);

    if (state == ActivityState.Enabled) {
        this.item = Optional.of(item);
    } else {
        this.item = Optional.absent();
    }
}

From source file:qa.qcri.nadeef.core.datamodel.NadeefConfiguration.java

private static void initialize() throws Exception {
    dbConfig = new DBConfig.Builder().url(properties.getProperty("database.url"))
            .username(properties.getProperty("database.username"))
            .password(properties.getProperty("database.password"))
            .dialect(SQLDialectTools.getSQLDialect(properties.getProperty("database.type", "database.derby")))
            .build();/*from  w  w  w. jav  a  2 s.c  om*/

    if (properties.containsKey("general.fixdecisionmaker")) {
        String className = properties.getProperty("general.fixdecisionmaker");
        Class customizedClass = CommonTools.loadClass(className);
        decisionMakerClass = Optional.of(customizedClass);
    } else
        decisionMakerClass = Optional.absent();

    if (properties.containsKey("general.outputPath")) {
        String outputPathString = properties.getProperty("general.outputPath");
        File tmpPath = new File(outputPathString);
        if (tmpPath.exists() && tmpPath.isDirectory())
            outputPath = tmpPath.toPath();
        else {
            String userDir = System.getProperty("user.dir");
            tracer.info(String.format("Cannot find directory %s, we use %s as default.", outputPathString,
                    userDir));
            outputPath = new File(outputPathString).toPath();
        }
    }

    Enumeration<?> enumeration = properties.propertyNames();
    while (enumeration.hasMoreElements()) {
        String property = (String) enumeration.nextElement();
        if (property.startsWith("ruleext.")) {
            String key = property.substring("ruleext.".length());
            String builderClassName = properties.getProperty(property);
            Class builderClass = CommonTools.loadClass(builderClassName);
            @SuppressWarnings("unchecked")
            RuleBuilder writer = (RuleBuilder) (builderClass.getConstructor().newInstance());
            ruleExtension.put(key, writer);
        }
    }
}

From source file:se.sics.dozy.DozyResult.java

public DozyResult(V val) {
    this.status = Status.OK;
    this.details = Optional.absent();
    this.value = Optional.of(val);
}

From source file:gobblin.data.management.copy.watermark.CopyableFileWatermarkHelper.java

/**
 * Return Optional {@link WatermarkInterval} for {@link CopyableFile} using {@link CopyableFileWatermarkGenerator}.
 *///from www.j  ava2 s. c om
public static Optional<WatermarkInterval> getCopyableFileWatermark(CopyableFile copyableFile,
        Optional<CopyableFileWatermarkGenerator> watermarkGenerator) throws IOException {
    if (!watermarkGenerator.isPresent()) {
        return Optional.absent();
    }
    return watermarkGenerator.get().generateWatermarkIntervalForCopyableFile(copyableFile);
}

From source file:springfox.documentation.schema.Annotations.java

@SuppressWarnings("PMD")
private static <A extends Annotation> Optional<A> tryGetGetterAnnotation(
        BeanPropertyDefinition beanPropertyDefinition, Class<A> annotationClass) {

    if (beanPropertyDefinition.hasGetter()) {
        return Optional.fromNullable(beanPropertyDefinition.getGetter().getAnnotation(annotationClass));
    }//from   w  w  w .  ja  v a 2 s  . co m
    return Optional.absent();
}

From source file:com.github.ykrasik.jerminal.internal.CommandLineHistory.java

/**
 * @return Previous command line from history.
 */// w w w .  ja v a  2  s .co  m
public Optional<String> getPrevCommandLine() {
    if (history.isEmpty()) {
        return Optional.absent();
    }

    // Don't let currentIndex go below 0.
    if (currentIndex > 0) {
        currentIndex--;
    }

    return getElementAtCurrentIndex();
}