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.fusesource.fabric.service.jclouds.functions.ToAdminAccess.java

public static Optional<AdminAccess> apply(CreateJCloudsContainerOptions input) {
    AdminAccess.Builder builder = AdminAccess.builder();
    //There are images that have issues with copying of public keys, creation of admin user accounts,etc
    //To allow//from   w  w w. java  2  s . c  o  m
    if (input.isAdminAccess()) {
        if (!Strings.isNullOrEmpty(input.getPublicKeyFile())) {
            File publicKey = new File(input.getPublicKeyFile());
            if (publicKey.exists()) {
                builder.adminPublicKey(publicKey);
            } else {
                LOGGER.warn("Public key has been specified file: {} files cannot be found. Ignoring.",
                        publicKey.getAbsolutePath());
                return Optional.of(AdminAccess.standard());
            }
        }

        if (!Strings.isNullOrEmpty(input.getUser())) {
            builder.adminUsername(input.getUser());
        }

        return Optional.of(builder.build());
    }
    return Optional.absent();
}

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

static Optional<ScmInfo> create(Component component, Iterable<DbFileSources.Line> lines) {
    LineToChangeset lineToChangeset = new LineToChangeset();
    List<Changeset> lineChangesets = StreamSupport.stream(lines.spliterator(), false).map(lineToChangeset)
            .filter(Objects::nonNull).collect(MoreCollectors.toList());
    if (lineChangesets.isEmpty()) {
        return Optional.absent();
    }/*from  ww w. ja  v  a 2  s . com*/
    checkState(!lineToChangeset.isEncounteredLineWithoutScmInfo(),
            "Partial scm information stored in DB for component '%s'. Not all lines have SCM info. Can not proceed",
            component);
    return Optional.of(new DbScmInfo(new ScmInfoImpl(lineChangesets)));
}

From source file:si.klepra.dropwizardbookmarks.auth.HelloAuthenticator.java

@Override
public Optional<User> authenticate(BasicCredentials c) throws AuthenticationException {

    //call db or auth service here!
    if (configuration.getPassword().equals(c.getPassword())) {
        return Optional.of(new User());
    }/*  w  w  w  .j  av  a 2 s .  c  om*/
    return Optional.absent();
}

From source file:com.jivesoftware.os.hwal.permit.ExpirablePermit.java

public Optional<Integer> getPermit() {
    Permit permit = expirableDelegatePermit.get();
    if (permit == null) {
        return Optional.absent();
    } else {//from   w  ww  .  j  a  v a 2 s .  co  m
        return Optional.of(permit.id);
    }
}

From source file:com.spotify.helios.cli.command.TargetAndClient.java

public TargetAndClient(final HeliosClient client) {
    this.target = Optional.absent();
    this.client = client;
}

From source file:ec.nbdemetra.ui.tsproviders.ProvidersUtil.java

public static Optional<Node> findNode(DataSource dataSource, Node node) {
    if (node instanceof ProvidersNode) {
        return find(dataSource, (ProvidersNode) node);
    }/* w  w w.  j a v  a  2  s  . c om*/
    if (node instanceof ProviderNode) {
        return find(dataSource, (ProviderNode) node);
    }
    return Optional.absent();
}

From source file:org.spongepowered.api.util.rotation.Rotations.java

public static Optional<Rotation> getRotationForDegree(int degrees) {
    return Optional.absent();
}

From source file:com.google.template.soy.shared.RangeArgs.java

/**
 * Returns a optional {@link RangeArgs} object if the for loop expression is a {@code range(...)}
 * expression./*from  w w w  .  j  a  v a  2s .  c  o  m*/
 */
public static final Optional<RangeArgs> createFromNode(ForNode node) {
    if (node.getExpr().getRoot() instanceof FunctionNode) {
        FunctionNode fn = (FunctionNode) node.getExpr().getRoot();
        if (fn.getSoyFunction() instanceof RangeFunction) {
            return Optional.of(create(fn.getChildren()));
        }
    }
    return Optional.absent();
}

From source file:org.excalibur.core.ssh.SshClientFactory.java

public static SshClient.Factory defaultSshClientFactory() {
    return new SshClient.Factory() {
        int timeout = SystemUtils2.getIntegerProperty("org.excalibur.ssh.default.connection.timeout.ms", 60000);

        Optional<Connector> agentConnector = getAgentConnector();

        @Override//from   www  .j a va 2  s  .c  o m
        public boolean isAgentAvailable() {
            return agentConnector.isPresent();
        }

        @Override
        public SshClient create(HostAndPort socket, LoginCredentials credentials) {
            return new JschSshClient(socket, credentials, timeout, agentConnector,
                    new BackoffLimitedRetryHandler());
        }

        Optional<Connector> getAgentConnector() {
            try {
                return Optional.of(ConnectorFactory.getDefault().createConnector());
            } catch (final AgentProxyException e) {
                return Optional.absent();
            }
        }
    };
}

From source file:info.gehrels.voting.singleTransferableVote.VoteState.java

public static <CANDIDATE_TYPE extends Candidate> Optional<VoteState<CANDIDATE_TYPE>> forBallotAndElection(
        Ballot<CANDIDATE_TYPE> ballot, Election<CANDIDATE_TYPE> election) {
    validateThat(ballot, is(notNullValue()));
    validateThat(election, is(notNullValue()));

    Optional<Vote<CANDIDATE_TYPE>> vote = ballot.getVote(election);
    if (!vote.isPresent()) {
        return Optional.absent();
    }//from   ww  w  .  j a v  a 2s.com

    return Optional.of(new VoteState<>(ballot.id, vote.get()));
}