Example usage for com.google.common.base Preconditions checkNotNull

List of usage examples for com.google.common.base Preconditions checkNotNull

Introduction

In this page you can find the example usage for com.google.common.base Preconditions checkNotNull.

Prototype

public static <T> T checkNotNull(T reference) 

Source Link

Document

Ensures that an object reference passed as a parameter to the calling method is not null.

Usage

From source file:org.opendaylight.bgpcep.programming.topology.TopologyProgrammingUtil.java

@SuppressWarnings("unchecked")
public static InstanceIdentifier<Topology> topologyForInput(final TopologyInstructionInput input) {
    Preconditions.checkNotNull(input.getNetworkTopologyRef());
    return (InstanceIdentifier<Topology>) input.getNetworkTopologyRef().getValue();
}

From source file:accumulo.input.AccumuloCsvInputFactory.java

public static AccumuloCsvInput getInput(File f) {
    Preconditions.checkNotNull(f);

    if (f.isDirectory()) {
        return new AccumuloCsvDirectoryInput(f);
    } else if (f.isFile()) {
        return new AccumuloCsvFileInput(f);
    } else {//  ww w .j a  va2 s.  com
        throw new UnsupportedOperationException("Input was not a file nor directory");
    }
}

From source file:org.ros.message.MessageIdentifier.java

public static MessageIdentifier of(String pkg, String name) {
    Preconditions.checkNotNull(pkg);
    Preconditions.checkNotNull(name);//from   w w  w.jav a 2  s.c  o m
    return new MessageIdentifier(pkg, name);
}

From source file:org.trancecode.base.TcPreconditions.java

public static void checkNotEmpty(final String string) {
    Preconditions.checkArgument(!Preconditions.checkNotNull(string).isEmpty());
}

From source file:io.appform.nautilus.funnel.utils.RegexUtils.java

public static String convertToRegex(final List<String> stages) {
    Preconditions.checkNotNull(stages);
    Preconditions.checkArgument(!stages.isEmpty());
    String regex = "";
    int i = 0;/* w  w w.  j a v a2s. com*/
    for (String stage : stages) {
        if (0 == i) {
            regex = String.format("(%s.*)", PathUtils.transformName(stage));
        } else {
            regex = String.format("%s|(\\%d%s.*)", regex, i, PathUtils.transformName(stage));
        }
        i++;
    }
    return String.format(".*(%s)", regex);
}

From source file:com.amitinside.java8.practice.StaticMethodExample.java

public static Optional<IParent> isNull(final IParent parent) {
    return Optional.of(Preconditions.checkNotNull(parent));
}

From source file:com.atoito.please.core.util.Store.java

public static File toFile(Object configured) {
    Object value = Preconditions.checkNotNull(configured);
    return new File(simplifyPath(value.toString()));
}

From source file:org.eclipse.xtext.serializer.impl.FeatureFinderUtil.java

/**
 * @since 2.0//from w  w  w .j  a  v  a 2s .  com
 */
public static EStructuralFeature getFeature(AbstractElement grammarElement, EClass owner) {
    Preconditions.checkNotNull(owner);
    if (grammarElement == null)
        return null;
    String featureName = null;
    if (grammarElement instanceof Action)
        featureName = ((Action) grammarElement).getFeature();
    else {
        Assignment ass = GrammarUtil.containingAssignment(grammarElement);
        if (ass != null)
            featureName = ass.getFeature();
    }
    if (featureName != null)
        return owner.getEStructuralFeature(featureName);
    return null;
}

From source file:org.haiku.haikudepotserver.support.cayenne.ExpressionHelper.java

/**
 * <p>This method will produce an expression that can be used in a Cayenne query.</p>
 *//*from  w w  w  . j a  v a 2 s  .  c om*/

public static Expression toExpression(VersionCoordinates coordinates, String prefix) {
    Preconditions.checkNotNull(coordinates);
    Expression majorE = ExpressionFactory.matchExp(prefixKey(prefix, PkgVersion.MAJOR.getName()),
            coordinates.getMajor());
    Expression minorE = ExpressionFactory.matchExp(prefixKey(prefix, PkgVersion.MINOR.getName()),
            coordinates.getMinor());
    Expression microE = ExpressionFactory.matchExp(prefixKey(prefix, PkgVersion.MICRO.getName()),
            coordinates.getMicro());
    Expression preReleaseE = ExpressionFactory.matchExp(prefixKey(prefix, PkgVersion.PRE_RELEASE.getName()),
            coordinates.getPreRelease());
    Expression revisionE = ExpressionFactory.matchExp(prefixKey(prefix, PkgVersion.REVISION.getName()),
            coordinates.getRevision());
    return andAll(ImmutableList.of(majorE, minorE, microE, preReleaseE, revisionE));
}

From source file:io.pravega.controller.store.stream.StreamProperty.java

public static <T> StreamProperty<T> update(final T update) {
    Preconditions.checkNotNull(update);

    return new StreamProperty<>(update, true);
}