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.google.devtools.build.lib.rules.apple.XcodeConfigProvider.java

private XcodeConfigProvider() {
    this.xcodeVersion = Optional.absent();
}

From source file:pl.setblack.airomem.core.builders.PrevaylerBuilder.java

PrevaylerBuilder() {
    initialSystem = Optional.absent();
    forceOverwrite = false;/*from  w w  w .  j a v a2  s.  c o  m*/
    allowCreate = false;
    folder = "";
    journalDiskSync = false;
    useFastJournalSerialization = true;
    useFastSnapshotSerialization = false;
}

From source file:AntColonyPDP.CentralizedAnt.java

public CentralizedAnt(Point startPosition, int capacity) {
    super(startPosition, capacity);
    curr = Optional.absent();
}

From source file:org.eclipse.buildship.core.util.gradle.GradleDistributionValidator.java

/**
 * Creates a new {@code Validator} instance.
 *
 * @return the new instance/*  ww w . ja  v a 2 s. com*/
 */
public static Validator<GradleDistributionWrapper> gradleDistributionValidator() {
    return new Validator<GradleDistributionWrapper>() {

        @Override
        public Optional<String> validate(GradleDistributionWrapper gradleDistribution) {
            GradleDistributionWrapper.DistributionType type = gradleDistribution.getType();
            String configuration = gradleDistribution.getConfiguration();

            if (GradleDistributionWrapper.DistributionType.LOCAL_INSTALLATION == type) {
                if (Strings.isNullOrEmpty(configuration)) {
                    return Optional.of(NLS.bind(CoreMessages.ErrorMessage_0_MustBeSpecified,
                            CoreMessages.GradleDistribution_Label_LocalInstallationDirectory));
                } else if (!new File(configuration).exists()) {
                    return Optional.of(NLS.bind(CoreMessages.ErrorMessage_0_DoesNotExist,
                            CoreMessages.GradleDistribution_Label_LocalInstallationDirectory));
                } else {
                    return Optional.absent();
                }
            } else if (GradleDistributionWrapper.DistributionType.REMOTE_DISTRIBUTION == type) {
                if (Strings.isNullOrEmpty(configuration)) {
                    return Optional.of(NLS.bind(CoreMessages.ErrorMessage_0_MustBeSpecified,
                            CoreMessages.GradleDistribution_Label_RemoteDistributionUri));
                } else if (!isValidURI(configuration)) {
                    return Optional.of(NLS.bind(CoreMessages.ErrorMessage_0_IsNotValid,
                            CoreMessages.GradleDistribution_Label_RemoteDistributionUri));
                } else {
                    return Optional.absent();
                }
            } else if (GradleDistributionWrapper.DistributionType.VERSION == type) {
                if (Strings.isNullOrEmpty(configuration)) {
                    return Optional.of(NLS.bind(CoreMessages.ErrorMessage_0_MustBeSpecified,
                            CoreMessages.GradleDistribution_Label_SpecificGradleVersion));
                } else {
                    return Optional.absent();
                }
            } else {
                return Optional.absent();
            }
        }

        private boolean isValidURI(String configuration) {
            try {
                new URI(configuration);
                return true;
            } catch (URISyntaxException e) {
                return false;
            }
        }
    };
}

From source file:org.osiam.resources.helper.SCIMHelper.java

/**
 * try to extract an email from the User.
 * If the User has a primary email address this email will be returned.
 * If not the first email address found will be returned.
 * If no Email has been found email.isPresent() == false
 *
 * @param user a {@link User} with a possible email
 * @return an email if found/*from   w  ww  .  j  a v a2  s  . c o  m*/
 * @deprecated Please use the method {@link User#getPrimaryOrFirstEmail()}
 */
@Deprecated
public static Optional<Email> getPrimaryOrFirstEmail(User user) {
    for (Email email : user.getEmails()) {
        if (email.isPrimary()) {
            return Optional.of(email);
        }
    }

    if (user.getEmails().size() > 0) {
        return Optional.of(user.getEmails().get(0));
    }
    return Optional.absent();
}

From source file:org.onos.yangtools.yang.data.impl.schema.tree.RecursiveDeleteCandidateNode.java

@Override
public Optional<NormalizedNode<?, ?>> getDataAfter() {
    return Optional.absent();
}

From source file:org.gerryai.planning.model.domain.Effect.java

/**
 * Private constructor to create an empty effect.
 */
private Effect() {
    effect = Optional.absent();
}

From source file:com.google.errorprone.matchers.method.StaticMethodMatcherImpl.java

@Override
protected Optional<MatchState> matchResult(ExpressionTree item, MatchState method, VisitorState state) {
    if (!method.sym().isStatic()) {
        return Optional.absent();
    }//from   ww w .j av  a 2s .c om
    return Optional.of(method);
}

From source file:com.dangdang.ddframe.rdb.sharding.parser.result.merger.OrderByColumn.java

public OrderByColumn(final Optional<String> owner, final String name, final Optional<String> alias,
        final OrderByType orderByType) {
    super(owner, Optional.of(name), alias, orderByType);
    index = Optional.absent();
}

From source file:com.shufudong.GuavaExample.collect.OptionalExample.java

/**
 * @return//  ww w .j av a  2s  .  c  om
 * @category <p>??</p>
 * <ol>
 * <li>Optional.of(T)Optional??nullT?T=null</li>
 * <li>Optional.absent()Optional?</li>
 * <li>Optional.fromNullable(T)T?OptionalT???[Optional.fromNullable(null)Optional.absent()</li>
 * </ol>
 * @throw
 */
public static void testOptional2() throws Exception {
    Optional<Integer> possible = Optional.of(6);
    Optional<Integer> absentOpt = Optional.absent();
    Optional<Integer> NullableOpt = Optional.fromNullable(null);
    Optional<Integer> NoNullableOpt = Optional.fromNullable(10);
    if (possible.isPresent()) {
        System.out.println("possible isPresent:" + possible.isPresent());
        System.out.println("possible value:" + possible.get());
    }
    if (absentOpt.isPresent()) {
        System.out.println("absentOpt isPresent:" + absentOpt.isPresent());
    }
    if (NullableOpt.isPresent()) {
        System.out.println("fromNullableOpt isPresent:" + NullableOpt.isPresent());
    }
    if (NoNullableOpt.isPresent()) {
        System.out.println("NoNullableOpt isPresent:" + NoNullableOpt.isPresent());
    }
}