Skip to content

Commit

Permalink
Consistent declarations and assertions in MockMultipartFile
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Dec 16, 2020
1 parent b3a47c7 commit fbd2ffd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.InputStream;

import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.FileCopyUtils;
Expand All @@ -42,10 +43,10 @@ public class MockMultipartFile implements MultipartFile {

private final String name;

private String originalFilename;
private final String originalFilename;

@Nullable
private String contentType;
private final String contentType;

private final byte[] content;

Expand Down Expand Up @@ -79,7 +80,7 @@ public MockMultipartFile(String name, InputStream contentStream) throws IOExcept
public MockMultipartFile(
String name, @Nullable String originalFilename, @Nullable String contentType, @Nullable byte[] content) {

Assert.hasLength(name, "Name must not be null");
Assert.hasLength(name, "Name must not be empty");
this.name = name;
this.originalFilename = (originalFilename != null ? originalFilename : "");
this.contentType = contentType;
Expand Down Expand Up @@ -108,6 +109,7 @@ public String getName() {
}

@Override
@NonNull
public String getOriginalFilename() {
return this.originalFilename;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.InputStream;

import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.FileCopyUtils;
Expand All @@ -42,10 +43,10 @@ public class MockMultipartFile implements MultipartFile {

private final String name;

private String originalFilename;
private final String originalFilename;

@Nullable
private String contentType;
private final String contentType;

private final byte[] content;

Expand Down Expand Up @@ -79,7 +80,7 @@ public MockMultipartFile(String name, InputStream contentStream) throws IOExcept
public MockMultipartFile(
String name, @Nullable String originalFilename, @Nullable String contentType, @Nullable byte[] content) {

Assert.hasLength(name, "Name must not be null");
Assert.hasLength(name, "Name must not be empty");
this.name = name;
this.originalFilename = (originalFilename != null ? originalFilename : "");
this.contentType = contentType;
Expand Down Expand Up @@ -108,6 +109,7 @@ public String getName() {
}

@Override
@NonNull
public String getOriginalFilename() {
return this.originalFilename;
}
Expand Down

0 comments on commit fbd2ffd

Please sign in to comment.