Example usage for java.util Objects requireNonNull

List of usage examples for java.util Objects requireNonNull

Introduction

In this page you can find the example usage for java.util Objects requireNonNull.

Prototype

public static <T> T requireNonNull(T obj, Supplier<String> messageSupplier) 

Source Link

Document

Checks that the specified object reference is not null and throws a customized NullPointerException if it is.

Usage

From source file:kishida.cnn.layers.NeuralLayer.java

public float[] forward() {
    Objects.requireNonNull(preLayer, "preLayer is null on " + name);
    return forward(preLayer.result);
}

From source file:com.yahoo.elide.core.exceptions.CustomErrorException.java

/**
 * constructor.//  ww  w .j  a v a2  s  .c o m
 * @param status http status
 * @param message exception message
 * @param cause the cause
 * @param errorObjects custom error objects, not {@code null}
 */
public CustomErrorException(int status, String message, Throwable cause, ErrorObjects errorObjects) {
    super(status, message, cause, null);
    this.errorObjects = Objects.requireNonNull(errorObjects, "errorObjects must not be null");
}

From source file:com.navercorp.pinpoint.web.vo.stat.chart.agent.DataSourceChart.java

@VisibleForTesting
static DataSourceChartGroup newDataSourceChartGroup(TimeWindow timeWindow,
        List<SampledDataSource> sampledDataSources, ServiceTypeRegistryService serviceTypeRegistryService) {
    Objects.requireNonNull(timeWindow, "timeWindow must not be null");

    Map<StatChartGroup.ChartType, Chart<? extends Point>> chartTypeChartMap = newDatasourceChart(timeWindow,
            sampledDataSources);/*from w  ww. java  2 s.  c  o  m*/
    if (CollectionUtils.isNotEmpty(sampledDataSources)) {
        SampledDataSource latestSampledDataSource = ListUtils.getLast(sampledDataSources);

        int id = latestSampledDataSource.getId();
        String serviceTypeName = serviceTypeRegistryService
                .findServiceType(latestSampledDataSource.getServiceTypeCode()).getName();
        String databaseName = latestSampledDataSource.getDatabaseName();
        String jdbcUrl = latestSampledDataSource.getJdbcUrl();
        return new DataSourceChartGroup(timeWindow, chartTypeChartMap, id, serviceTypeName, databaseName,
                jdbcUrl);
    } else {
        final Integer uncollectedValue = SampledDataSource.UNCOLLECTED_VALUE;
        // TODO avoid null
        final String uncollectedString = SampledDataSource.UNCOLLECTED_STRING;

        return new DataSourceChartGroup(timeWindow, chartTypeChartMap, uncollectedValue, uncollectedString,
                uncollectedString, uncollectedString);
    }
}

From source file:com.facebook.presto.kinesis.KinesisTableLayoutHandle.java

@JsonCreator
public KinesisTableLayoutHandle(@JsonProperty("connectorId") String connectorId,
        @JsonProperty("table") KinesisTableHandle table) {
    this.connectorId = Objects.requireNonNull(connectorId, "connectorId is null");
    this.tableHandle = table;
}

From source file:lite.log.intercept.Modifier.java

public Modifier(Class<T> modifiedClazz) {
    super();/* ww w. jav a2 s .  c o m*/
    Objects.requireNonNull(modifiedClazz, "modifiedClazz should not be null");
    this.modifiedClazz = modifiedClazz;
}

From source file:edu.usu.sdl.openstorefront.report.generator.HtmlGenerator.java

@Override
public void init() {
    Objects.requireNonNull(report, "The generator requires the report to exist.");
    Objects.requireNonNull(report.getReportId(), "The report id is required.");
    try {//from   ww w.j  ava  2 s .  co  m
        writer = new BufferedWriter(
                new OutputStreamWriter(new FileOutputStream(report.pathToReport().toFile())));
        writer.append("<html><body style='padding: 20px'>");
    } catch (IOException ex) {
        throw new OpenStorefrontRuntimeException("Unable to open file to write report.",
                "Check file system permissions", ex);
    }
}

From source file:edu.usu.sdl.openstorefront.util.ReflectionUtil.java

/**
 * This check for Value Model Objects/*from   w  w w.  ja va  2s  .c  om*/
 *
 * @param fieldClass
 * @return
 */
public static boolean isComplexClass(Class fieldClass) {
    Objects.requireNonNull(fieldClass, "Class is required");

    boolean complex = false;
    if (!fieldClass.isPrimitive() && !fieldClass.isArray()
            && !fieldClass.getSimpleName().equalsIgnoreCase(String.class.getSimpleName())
            && !fieldClass.getSimpleName().equalsIgnoreCase(Long.class.getSimpleName())
            && !fieldClass.getSimpleName().equalsIgnoreCase(Integer.class.getSimpleName())
            && !fieldClass.getSimpleName().equalsIgnoreCase(Boolean.class.getSimpleName())
            && !fieldClass.getSimpleName().equalsIgnoreCase(Double.class.getSimpleName())
            && !fieldClass.getSimpleName().equalsIgnoreCase(Float.class.getSimpleName())
            && !fieldClass.getSimpleName().equalsIgnoreCase(BigDecimal.class.getSimpleName())
            && !fieldClass.getSimpleName().equalsIgnoreCase(Date.class.getSimpleName())
            && !fieldClass.getSimpleName().equalsIgnoreCase(List.class.getSimpleName())
            && !fieldClass.getSimpleName().equalsIgnoreCase(Map.class.getSimpleName())
            && !fieldClass.getSimpleName().equalsIgnoreCase(Collection.class.getSimpleName())
            && !fieldClass.getSimpleName().equalsIgnoreCase(Queue.class.getSimpleName())
            && !fieldClass.getSimpleName().equalsIgnoreCase(Set.class.getSimpleName())
            && !fieldClass.getSimpleName().equalsIgnoreCase(BigInteger.class.getSimpleName())) {
        complex = true;
    }
    return complex;
}

From source file:org.eclipse.vorto.remoterepository.service.converter.DefaultConverterService.java

@Override
public ModelView convert(ModelContent modelContent) {

    Objects.requireNonNull(modelContent.getContent(), "model content must not be null");

    IModelParser modelConverter = new ModelParserFactory().getModelParser(modelContent.getModelType());

    return modelConverter.parse(modelContent);
}

From source file:org.trustedanalytics.uploader.rest.Transfer.java

public Transfer(UploadMetadata metadata) {
    this.source = Objects.requireNonNull(metadata.getSource(), "source is required");
    this.orgUUID = Objects.requireNonNull(metadata.getOrgUUID(), "orgUUID is required");
    this.title = Objects.requireNonNull(metadata.getTitle(), "title is required");
    this.category = Objects.requireNonNull(metadata.getCategory(), "category is required");
    this.publicAccess = Objects.requireNonNull(metadata.getPublicAccess(), "publicAccess is required");
}

From source file:org.trustedanalytics.uploader.rest.UploadMetadata.java

private UploadMetadata(UploadMetadataBuilder builder) {
    this.source = Objects.requireNonNull(builder.source, "source is required");
    this.orgUUID = Objects.requireNonNull(builder.orgUUID, "organization guid is required");
    this.title = Objects.requireNonNull(builder.title, "title is required");
    this.category = Objects.requireNonNull(builder.category, "category is required");
    this.publicAccess = builder.publicAccess;
}