Skip to content

Commit

Permalink
suggestions applied
Browse files Browse the repository at this point in the history
  • Loading branch information
ilicmarkodb committed Sep 9, 2024
1 parent 5e0e43e commit 20a1081
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
*/
package io.delta.kernel.expressions;

import io.delta.kernel.annotation.Evolving;

import java.util.Objects;
import java.util.Optional;

import static io.delta.kernel.internal.util.Preconditions.checkArgument;

@Evolving
public class CollationIdentifier {
public static final String PROVIDER_SPARK = "SPARK";
public static final String PROVIDER_ICU = "ICU";
Expand All @@ -39,6 +45,10 @@ public CollationIdentifier(String provider, String collationName) {
}

public CollationIdentifier(String provider, String collationName, Optional<String> version) {
Objects.requireNonNull(provider, "Collation provider cannot be null.");
Objects.requireNonNull(collationName, "Collation name cannot be null.");
Objects.requireNonNull(version, "Provider version cannot be null.");

this.provider = provider.toUpperCase();
this.name = collationName.toUpperCase();
if (version.isPresent()) {
Expand Down Expand Up @@ -67,10 +77,8 @@ public Optional<String> getVersion() {

public static CollationIdentifier fromString(String identifier) {
long numDots = identifier.chars().filter(ch -> ch == '.').count();
if (numDots == 0) {
throw new IllegalArgumentException(
String.format("Invalid collation identifier: %s", identifier));
} else if (numDots == 1) {
checkArgument(numDots > 0, String.format("Invalid collation identifier: %s", identifier));
if (numDots == 1) {
String[] parts = identifier.split("\\.");
return new CollationIdentifier(parts[0], parts[1]);
} else {
Expand Down

0 comments on commit 20a1081

Please sign in to comment.