mirror of
https://github.com/google/nomulus.git
synced 2025-07-22 02:36:03 +02:00
Allow allocation token discounts on premiums and for multiple years (#744)
* Allow allocation token discounts on premiums and for multiple years * Add domain check flow tests * Address code review comments * Update schema file
This commit is contained in:
parent
6f56451412
commit
b89af91bda
25 changed files with 606 additions and 111 deletions
|
@ -75,38 +75,39 @@ public class CollectionUtils {
|
|||
}
|
||||
|
||||
/** Defensive copy helper for {@link Set}. */
|
||||
public static <V> ImmutableSet<V> nullSafeImmutableCopy(Set<V> data) {
|
||||
public static <V> ImmutableSet<V> nullSafeImmutableCopy(@Nullable Set<V> data) {
|
||||
return data == null ? null : ImmutableSet.copyOf(data);
|
||||
}
|
||||
|
||||
/** Defensive copy helper for {@link List}. */
|
||||
public static <V> ImmutableList<V> nullSafeImmutableCopy(List<V> data) {
|
||||
public static <V> ImmutableList<V> nullSafeImmutableCopy(@Nullable List<V> data) {
|
||||
return data == null ? null : ImmutableList.copyOf(data);
|
||||
}
|
||||
|
||||
/** Defensive copy helper for {@link Set}. */
|
||||
public static <V> ImmutableSet<V> nullToEmptyImmutableCopy(Set<V> data) {
|
||||
public static <V> ImmutableSet<V> nullToEmptyImmutableCopy(@Nullable Set<V> data) {
|
||||
return data == null ? ImmutableSet.of() : ImmutableSet.copyOf(data);
|
||||
}
|
||||
|
||||
/** Defensive copy helper for {@link Set}. */
|
||||
public static <V extends Comparable<V>>
|
||||
ImmutableSortedSet<V> nullToEmptyImmutableSortedCopy(Set<V> data) {
|
||||
public static <V extends Comparable<V>> ImmutableSortedSet<V> nullToEmptyImmutableSortedCopy(
|
||||
@Nullable Set<V> data) {
|
||||
return data == null ? ImmutableSortedSet.of() : ImmutableSortedSet.copyOf(data);
|
||||
}
|
||||
|
||||
/** Defensive copy helper for {@link SortedMap}. */
|
||||
public static <K, V> ImmutableSortedMap<K, V> nullToEmptyImmutableCopy(SortedMap<K, V> data) {
|
||||
public static <K, V> ImmutableSortedMap<K, V> nullToEmptyImmutableCopy(
|
||||
@Nullable SortedMap<K, V> data) {
|
||||
return data == null ? ImmutableSortedMap.of() : ImmutableSortedMap.copyOfSorted(data);
|
||||
}
|
||||
|
||||
/** Defensive copy helper for {@link List}. */
|
||||
public static <V> ImmutableList<V> nullToEmptyImmutableCopy(List<V> data) {
|
||||
public static <V> ImmutableList<V> nullToEmptyImmutableCopy(@Nullable List<V> data) {
|
||||
return data == null ? ImmutableList.of() : ImmutableList.copyOf(data);
|
||||
}
|
||||
|
||||
/** Defensive copy helper for {@link Map}. */
|
||||
public static <K, V> ImmutableMap<K, V> nullToEmptyImmutableCopy(Map<K, V> data) {
|
||||
public static <K, V> ImmutableMap<K, V> nullToEmptyImmutableCopy(@Nullable Map<K, V> data) {
|
||||
return data == null ? ImmutableMap.of() : ImmutableMap.copyOf(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,33 +29,36 @@ public class PreconditionsUtils {
|
|||
* preferable to throw an IAE instead of an NPE, such as where we want an IAE to indicate that
|
||||
* it's just a bad argument/parameter and reserve NPEs for bugs and unexpected null values.
|
||||
*/
|
||||
public static <T> T checkArgumentNotNull(T reference) {
|
||||
public static <T> T checkArgumentNotNull(@Nullable T reference) {
|
||||
checkArgument(reference != null);
|
||||
return reference;
|
||||
}
|
||||
|
||||
/** Checks whether the provided reference is null, throws IAE if it is, and returns it if not. */
|
||||
public static <T> T checkArgumentNotNull(T reference, @Nullable Object errorMessage) {
|
||||
public static <T> T checkArgumentNotNull(@Nullable T reference, @Nullable Object errorMessage) {
|
||||
checkArgument(reference != null, errorMessage);
|
||||
return reference;
|
||||
}
|
||||
|
||||
/** Checks whether the provided reference is null, throws IAE if it is, and returns it if not. */
|
||||
public static <T> T checkArgumentNotNull(
|
||||
T reference, @Nullable String errorMessageTemplate, @Nullable Object... errorMessageArgs) {
|
||||
@Nullable T reference,
|
||||
@Nullable String errorMessageTemplate,
|
||||
@Nullable Object... errorMessageArgs) {
|
||||
checkArgument(reference != null, errorMessageTemplate, errorMessageArgs);
|
||||
return reference;
|
||||
}
|
||||
|
||||
/** Checks if the provided Optional is present, returns its value if so, and throws IAE if not. */
|
||||
public static <T> T checkArgumentPresent(Optional<T> reference) {
|
||||
public static <T> T checkArgumentPresent(@Nullable Optional<T> reference) {
|
||||
checkArgumentNotNull(reference);
|
||||
checkArgument(reference.isPresent());
|
||||
return reference.get();
|
||||
}
|
||||
|
||||
/** Checks if the provided Optional is present, returns its value if so, and throws IAE if not. */
|
||||
public static <T> T checkArgumentPresent(Optional<T> reference, @Nullable Object errorMessage) {
|
||||
public static <T> T checkArgumentPresent(
|
||||
@Nullable Optional<T> reference, @Nullable Object errorMessage) {
|
||||
checkArgumentNotNull(reference, errorMessage);
|
||||
checkArgument(reference.isPresent(), errorMessage);
|
||||
return reference.get();
|
||||
|
@ -63,7 +66,7 @@ public class PreconditionsUtils {
|
|||
|
||||
/** Checks if the provided Optional is present, returns its value if so, and throws IAE if not. */
|
||||
public static <T> T checkArgumentPresent(
|
||||
Optional<T> reference,
|
||||
@Nullable Optional<T> reference,
|
||||
@Nullable String errorMessageTemplate,
|
||||
@Nullable Object... errorMessageArgs) {
|
||||
checkArgumentNotNull(reference, errorMessageTemplate, errorMessageArgs);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue