Skip to content

Commit 30a79f3

Browse files
committed
Minimize and refactor API surface
1 parent 1887890 commit 30a79f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+62
-144
lines changed

conformance/src/main/java/build/buf/protovalidate/conformance/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
package build.buf.protovalidate.conformance;
1616

17+
import build.buf.protovalidate.CompilationException;
1718
import build.buf.protovalidate.Config;
19+
import build.buf.protovalidate.ExecutionException;
1820
import build.buf.protovalidate.ValidationResult;
1921
import build.buf.protovalidate.Validator;
20-
import build.buf.protovalidate.exceptions.CompilationException;
21-
import build.buf.protovalidate.exceptions.ExecutionException;
2222
import build.buf.validate.ValidateProto;
2323
import build.buf.validate.Violations;
2424
import build.buf.validate.conformance.harness.TestConformanceRequest;

conformance/src/test/java/build/buf/protovalidate/ValidatorTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import static org.assertj.core.api.Assertions.assertThat;
1818
import static org.assertj.core.api.Assertions.assertThatThrownBy;
1919

20-
import build.buf.protovalidate.exceptions.ExecutionException;
21-
import build.buf.protovalidate.exceptions.ValidationException;
2220
import build.buf.validate.conformance.cases.AnEnum;
2321
import build.buf.validate.conformance.cases.BoolConstTrue;
2422
import build.buf.validate.conformance.cases.BytesContains;

src/main/java/build/buf/protovalidate/internal/evaluator/AnyEvaluator.java renamed to src/main/java/build/buf/protovalidate/AnyEvaluator.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.evaluator;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.exceptions.ExecutionException;
18-
import build.buf.protovalidate.internal.errors.ConstraintViolation;
19-
import build.buf.protovalidate.internal.errors.FieldPathUtils;
2017
import build.buf.validate.AnyRules;
2118
import build.buf.validate.FieldConstraints;
2219
import build.buf.validate.FieldPath;

src/main/java/build/buf/protovalidate/internal/expression/AstExpression.java renamed to src/main/java/build/buf/protovalidate/AstExpression.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.expression;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.exceptions.CompilationException;
1817
import com.google.api.expr.v1alpha1.Type;
1918
import org.projectnessie.cel.Ast;
2019
import org.projectnessie.cel.Env;
2120

2221
/** {@link AstExpression} is a compiled CEL {@link Ast}. */
23-
public class AstExpression {
22+
class AstExpression {
2423
/** The compiled CEL AST. */
2524
public final Ast ast;
2625

src/main/java/build/buf/protovalidate/internal/evaluator/CelPrograms.java renamed to src/main/java/build/buf/protovalidate/CelPrograms.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.evaluator;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.exceptions.ExecutionException;
18-
import build.buf.protovalidate.internal.errors.ConstraintViolation;
19-
import build.buf.protovalidate.internal.errors.FieldPathUtils;
20-
import build.buf.protovalidate.internal.expression.CompiledProgram;
21-
import build.buf.protovalidate.internal.expression.Variable;
2217
import java.util.ArrayList;
2318
import java.util.List;
2419
import javax.annotation.Nullable;

src/main/java/build/buf/protovalidate/exceptions/CompilationException.java renamed to src/main/java/build/buf/protovalidate/CompilationException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.exceptions;
15+
package build.buf.protovalidate;
1616

1717
/** CompilationException is returned when a constraint fails to compile. This is a fatal error. */
1818
public class CompilationException extends ValidationException {

src/main/java/build/buf/protovalidate/internal/expression/CompiledProgram.java renamed to src/main/java/build/buf/protovalidate/CompiledProgram.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.expression;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.exceptions.ExecutionException;
18-
import build.buf.protovalidate.internal.errors.ConstraintViolation;
19-
import build.buf.protovalidate.internal.evaluator.Value;
2017
import build.buf.validate.FieldPath;
2118
import javax.annotation.Nullable;
2219
import org.projectnessie.cel.Program;
@@ -27,7 +24,7 @@
2724
* {@link CompiledProgram} is a parsed and type-checked {@link Program} along with the source {@link
2825
* Expression}.
2926
*/
30-
public class CompiledProgram {
27+
class CompiledProgram {
3128
/** A compiled CEL program that can be evaluated against a set of variable bindings. */
3229
private final Program program;
3330

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.constraints;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.Config;
18-
import build.buf.protovalidate.exceptions.CompilationException;
19-
import build.buf.protovalidate.internal.errors.FieldPathUtils;
20-
import build.buf.protovalidate.internal.evaluator.ObjectValue;
21-
import build.buf.protovalidate.internal.evaluator.Value;
22-
import build.buf.protovalidate.internal.expression.AstExpression;
23-
import build.buf.protovalidate.internal.expression.CompiledProgram;
24-
import build.buf.protovalidate.internal.expression.Expression;
25-
import build.buf.protovalidate.internal.expression.Variable;
2617
import build.buf.validate.FieldConstraints;
2718
import build.buf.validate.FieldPath;
2819
import build.buf.validate.ValidateProto;
@@ -52,7 +43,7 @@
5243
import org.projectnessie.cel.interpreter.Activation;
5344

5445
/** A build-through cache for computed standard constraints. */
55-
public class ConstraintCache {
46+
class ConstraintCache {
5647
private static class CelRule {
5748
public final AstExpression astExpression;
5849
public final FieldDescriptor field;

src/main/java/build/buf/protovalidate/internal/evaluator/ConstraintResolver.java renamed to src/main/java/build/buf/protovalidate/ConstraintResolver.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.evaluator;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.exceptions.CompilationException;
1817
import build.buf.validate.FieldConstraints;
1918
import build.buf.validate.MessageConstraints;
2019
import build.buf.validate.OneofConstraints;

src/main/java/build/buf/protovalidate/internal/errors/ConstraintViolation.java renamed to src/main/java/build/buf/protovalidate/ConstraintViolation.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.errors;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.Violation;
18-
import build.buf.protovalidate.internal.evaluator.Value;
1917
import build.buf.validate.FieldPath;
2018
import build.buf.validate.FieldPathElement;
2119
import com.google.protobuf.Descriptors;
@@ -31,7 +29,7 @@
3129
* {@link ConstraintViolation} contains all of the collected information about an individual
3230
* constraint violation.
3331
*/
34-
public class ConstraintViolation implements Violation {
32+
class ConstraintViolation implements Violation {
3533
/** Static value to return when there are no violations. */
3634
public static final List<Builder> NO_VIOLATIONS = new ArrayList<>();
3735

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.evaluator;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.internal.errors.FieldPathUtils;
1817
import build.buf.validate.FieldPath;
1918
import build.buf.validate.FieldPathElement;
2019
import java.util.ArrayList;

src/main/java/build/buf/protovalidate/internal/celext/CustomDeclarations.java renamed to src/main/java/build/buf/protovalidate/CustomDeclarations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.celext;
15+
package build.buf.protovalidate;
1616

1717
import com.google.api.expr.v1alpha1.Decl;
1818
import java.util.ArrayList;

src/main/java/build/buf/protovalidate/internal/celext/CustomOverload.java renamed to src/main/java/build/buf/protovalidate/CustomOverload.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.celext;
15+
package build.buf.protovalidate;
1616

1717
import com.google.common.base.Ascii;
1818
import com.google.common.base.Splitter;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.constraints;
15+
package build.buf.protovalidate;
1616

1717
import build.buf.validate.FieldConstraints;
1818
import com.google.api.expr.v1alpha1.Type;
@@ -27,7 +27,7 @@
2727
/**
2828
* DescriptorMappings provides mappings between protocol buffer descriptors and CEL declarations.
2929
*/
30-
public final class DescriptorMappings {
30+
final class DescriptorMappings {
3131
/** Provides a {@link Descriptor} for {@link FieldConstraints}. */
3232
static final Descriptor FIELD_CONSTRAINTS_DESC = FieldConstraints.getDescriptor();
3333

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.evaluator;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.exceptions.ExecutionException;
18-
import build.buf.protovalidate.internal.errors.ConstraintViolation;
19-
import build.buf.protovalidate.internal.errors.FieldPathUtils;
2017
import java.util.Collections;
2118
import java.util.List;
2219

src/main/java/build/buf/protovalidate/internal/evaluator/EnumEvaluator.java renamed to src/main/java/build/buf/protovalidate/EnumEvaluator.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.evaluator;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.ValidationResult;
18-
import build.buf.protovalidate.exceptions.ExecutionException;
19-
import build.buf.protovalidate.internal.errors.ConstraintViolation;
20-
import build.buf.protovalidate.internal.errors.FieldPathUtils;
2117
import build.buf.validate.EnumRules;
2218
import build.buf.validate.FieldConstraints;
2319
import build.buf.validate.FieldPath;

src/main/java/build/buf/protovalidate/internal/evaluator/Evaluator.java renamed to src/main/java/build/buf/protovalidate/Evaluator.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.evaluator;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.exceptions.ExecutionException;
18-
import build.buf.protovalidate.internal.errors.ConstraintViolation;
1917
import java.util.List;
2018

2119
/**
2220
* {@link Evaluator} defines a validation evaluator. evaluator implementations may elide type
2321
* checking of the passed in value, as the types have been guaranteed during the build phase.
2422
*/
25-
public interface Evaluator {
23+
interface Evaluator {
2624
/**
2725
* Tautology returns true if the evaluator always succeeds.
2826
*

src/main/java/build/buf/protovalidate/internal/evaluator/EvaluatorBuilder.java renamed to src/main/java/build/buf/protovalidate/EvaluatorBuilder.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.evaluator;
16-
17-
import build.buf.protovalidate.Config;
18-
import build.buf.protovalidate.exceptions.CompilationException;
19-
import build.buf.protovalidate.internal.constraints.ConstraintCache;
20-
import build.buf.protovalidate.internal.constraints.DescriptorMappings;
21-
import build.buf.protovalidate.internal.errors.FieldPathUtils;
22-
import build.buf.protovalidate.internal.expression.AstExpression;
23-
import build.buf.protovalidate.internal.expression.CompiledProgram;
24-
import build.buf.protovalidate.internal.expression.Expression;
25-
import build.buf.protovalidate.internal.expression.Variable;
15+
package build.buf.protovalidate;
16+
2617
import build.buf.validate.Constraint;
2718
import build.buf.validate.FieldConstraints;
2819
import build.buf.validate.FieldPath;
@@ -50,7 +41,7 @@
5041
import org.projectnessie.cel.checker.Decls;
5142

5243
/** A build-through cache of message evaluators keyed off the provided descriptor. */
53-
public class EvaluatorBuilder {
44+
class EvaluatorBuilder {
5445
private static final FieldPathElement CEL_FIELD_PATH_ELEMENT =
5546
FieldPathUtils.fieldPathElement(
5647
FieldConstraints.getDescriptor().findFieldByNumber(FieldConstraints.CEL_FIELD_NUMBER));

src/main/java/build/buf/protovalidate/exceptions/ExecutionException.java renamed to src/main/java/build/buf/protovalidate/ExecutionException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.exceptions;
15+
package build.buf.protovalidate;
1616

1717
/** ExecutionException is returned when a constraint fails to execute. This is a fatal error. */
1818
public class ExecutionException extends ValidationException {

src/main/java/build/buf/protovalidate/internal/expression/Expression.java renamed to src/main/java/build/buf/protovalidate/Expression.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.expression;
15+
package build.buf.protovalidate;
1616

1717
import build.buf.validate.Constraint;
1818
import java.util.ArrayList;
1919
import java.util.List;
2020

2121
/** Expression represents a single CEL expression. */
22-
public class Expression {
22+
class Expression {
2323
/** The id of the constraint. */
2424
public final String id;
2525

src/main/java/build/buf/protovalidate/internal/evaluator/FieldEvaluator.java renamed to src/main/java/build/buf/protovalidate/FieldEvaluator.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.evaluator;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.exceptions.ExecutionException;
18-
import build.buf.protovalidate.internal.errors.ConstraintViolation;
19-
import build.buf.protovalidate.internal.errors.FieldPathUtils;
2017
import build.buf.validate.FieldConstraints;
2118
import build.buf.validate.FieldPath;
2219
import com.google.protobuf.Descriptors.FieldDescriptor;

src/main/java/build/buf/protovalidate/internal/errors/FieldPathUtils.java renamed to src/main/java/build/buf/protovalidate/FieldPathUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.errors;
15+
package build.buf.protovalidate;
1616

1717
import build.buf.validate.FieldPath;
1818
import build.buf.validate.FieldPathElement;
@@ -21,7 +21,7 @@
2121
import javax.annotation.Nullable;
2222

2323
/** Utility class for manipulating error paths in violations. */
24-
public final class FieldPathUtils {
24+
final class FieldPathUtils {
2525
private FieldPathUtils() {}
2626

2727
/**

src/main/java/build/buf/protovalidate/internal/celext/Format.java renamed to src/main/java/build/buf/protovalidate/Format.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.celext;
15+
package build.buf.protovalidate;
1616

1717
import static java.time.format.DateTimeFormatter.ISO_INSTANT;
1818

src/main/java/build/buf/protovalidate/internal/evaluator/ListEvaluator.java renamed to src/main/java/build/buf/protovalidate/ListEvaluator.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.evaluator;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.exceptions.ExecutionException;
18-
import build.buf.protovalidate.internal.errors.ConstraintViolation;
19-
import build.buf.protovalidate.internal.errors.FieldPathUtils;
2017
import build.buf.validate.FieldConstraints;
2118
import build.buf.validate.FieldPath;
2219
import build.buf.validate.FieldPathElement;

src/main/java/build/buf/protovalidate/internal/evaluator/MapEvaluator.java renamed to src/main/java/build/buf/protovalidate/MapEvaluator.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.evaluator;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.exceptions.ExecutionException;
18-
import build.buf.protovalidate.internal.errors.ConstraintViolation;
19-
import build.buf.protovalidate.internal.errors.FieldPathUtils;
2017
import build.buf.validate.FieldConstraints;
2118
import build.buf.validate.FieldPath;
2219
import build.buf.validate.FieldPathElement;

src/main/java/build/buf/protovalidate/internal/evaluator/MessageEvaluator.java renamed to src/main/java/build/buf/protovalidate/MessageEvaluator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package build.buf.protovalidate.internal.evaluator;
15+
package build.buf.protovalidate;
1616

17-
import build.buf.protovalidate.exceptions.ExecutionException;
18-
import build.buf.protovalidate.internal.errors.ConstraintViolation;
1917
import java.util.ArrayList;
2018
import java.util.List;
2119

0 commit comments

Comments
 (0)