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, @Nullable Object errorMessage) 

Source Link

Document

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

Usage

From source file:com.github.jcustenborder.kafka.connect.cdc.VersionUtil.java

public static String getVersion() {
    try {/*from ww w . jav  a2  s .c om*/
        String version = VersionUtil.class.getPackage().getImplementationVersion();
        Preconditions.checkNotNull(version, "version should not be null.");
        return version;
    } catch (Exception ex) {
        return "0.0.0.0";
    }
}

From source file:fr.norad.visuwall.plugin.sonar.QualityMeasures.java

static SonarQualityMeasure asQualityMeasure(Measure measure, String measureKey) {
    Preconditions.checkNotNull(measure, "measure is mandatory");
    Preconditions.checkArgument(!measureKey.isEmpty(), "measureKey is mandatory");
    Preconditions.checkNotNull(measure.getValue(), "measure must have a value");
    Double value = measure.getValue();
    SonarQualityMeasure qualityMeasure = new SonarQualityMeasure();
    qualityMeasure.setKey(measureKey);//from w  w w .j  a  v  a 2  s.  co m
    qualityMeasure.setValue(value);
    qualityMeasure.setFormattedValue(measure.getFormattedValue());
    return qualityMeasure;
}

From source file:org.basepom.mojo.propertyhelper.beans.IgnoreWarnFail.java

public static IgnoreWarnFail forString(final String value) {
    Preconditions.checkNotNull(value, "the value can not be null");
    return Enum.valueOf(IgnoreWarnFail.class, value.toUpperCase(Locale.ENGLISH));
}

From source file:org.impressivecode.depress.common.TransformationUtils.java

public static boolean isJavaFile(final String fileName) {
    Preconditions.checkNotNull(fileName, "FileName has to be set");
    return fileName.endsWith(".java");
}

From source file:com.facebook.presto.operator.AggregationFunctionDefinition.java

public static AggregationFunctionDefinition aggregation(AggregationFunction function, List<Input> inputs) {
    Preconditions.checkNotNull(function, "function is null");
    Preconditions.checkNotNull(inputs, "inputs is null");

    return new AggregationFunctionDefinition(function, inputs);
}

From source file:com.nesscomputing.mojo.numbers.beans.IWFEnum.java

public static IWFEnum forString(final String value) {
    Preconditions.checkNotNull(value, "the value can not be null");
    return valueOf(IWFEnum.class, value.toUpperCase(Locale.ENGLISH));
}

From source file:eu.thebluemountain.customers.dctm.brownbag.badcontentslister.DecoratedContent.java

public static DecoratedContent create(Content content, Parent parent) {
    return new DecoratedContent(Preconditions.checkNotNull(content, "null content supplied"),
            Preconditions.checkNotNull(parent, "null parent supplied"));
}

From source file:com.spotify.folsom.GetResult.java

public static <V> GetResult<V> success(final V value, final long cas) {
    Preconditions.checkNotNull(value, "value");
    return new GetResult<>(value, cas);
}

From source file:com.salesforce.jprotoc.ProtocPlugin.java

/**
 * Apply a single generator to the parsed proto descriptor.
 * @param generator The generator to run.
 *///from w  w  w .  j  a  v a  2 s  .  c  om
public static void generate(@Nonnull Generator generator) {
    Preconditions.checkNotNull(generator, "generator");
    generate(Collections.singletonList(generator));
}

From source file:org.eclipse.lsp4j.util.Ranges.java

/**
 * {@code true} if the {@code smaller} {@link Range range} is inside or equal to
 * the {@code bigger} range. Otherwise, {@code false}.
 *///from   w  w  w  .j  av  a  2 s  . c  om
public static boolean containsRange(Range bigger, Range smaller) {
    Preconditions.checkNotNull(bigger, "bigger");
    Preconditions.checkNotNull(smaller, "smaller");
    return containsPosition(bigger, smaller.getStart()) && containsPosition(bigger, smaller.getEnd());
}