mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-13 20:29:39 +02:00
Added @Nonnull annotation to Passphrase.fromPassword()
This commit is contained in:
parent
e77e97bc08
commit
462c9f032f
2 changed files with 4 additions and 10 deletions
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.util;
|
package org.pgpainless.util;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
@ -37,11 +38,11 @@ public class Passphrase {
|
||||||
/**
|
/**
|
||||||
* Create a {@link Passphrase} from a {@link String}.
|
* Create a {@link Passphrase} from a {@link String}.
|
||||||
*
|
*
|
||||||
* @param password password that may be null
|
* @param password password
|
||||||
* @return passphrase
|
* @return passphrase
|
||||||
*/
|
*/
|
||||||
public static Passphrase fromPassword(@Nullable String password) {
|
public static Passphrase fromPassword(@Nonnull String password) {
|
||||||
return new Passphrase(password == null ? null : password.toCharArray());
|
return new Passphrase(password.toCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,11 +37,4 @@ public class PassphraseTest {
|
||||||
assertFalse(passphrase.isValid());
|
assertFalse(passphrase.isValid());
|
||||||
assertThrows(IllegalStateException.class, passphrase::getChars);
|
assertThrows(IllegalStateException.class, passphrase::getChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFromPasswordNull() {
|
|
||||||
Passphrase passphrase = Passphrase.fromPassword(null);
|
|
||||||
assertArrayEquals(null, passphrase.getChars());
|
|
||||||
assertTrue(passphrase.isValid());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue