Skip to content

Commit

Permalink
HV-2043 Remove deprecated PropertyTarget#property
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta committed Sep 4, 2024
1 parent fa306c9 commit 5a6d58f
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*/
package org.hibernate.validator.cfg.context;

import java.lang.annotation.ElementType;

/**
* Facet of a constraint mapping creational context which allows to select the bean
* property to which the next operations shall apply.
Expand All @@ -16,24 +14,6 @@
* @author Gunnar Morling
*/
public interface PropertyTarget {
/**
* Selects a property to which the next operations shall apply.
* <p>
* Until this method is called constraints apply on class level. After calling this method constraints
* apply on the specified property with the given access type.
* <p>
* A given property may only be configured once.
*
* @param property The property on which to apply the following constraints (Java Bean notation).
* @param type The access type (field/property).
*
* @return A creational context representing the selected property.
*
* @deprecated Since 6.1. Planned for removal. Use either {@link PropertyTarget#field(String)} or
* {@link PropertyTarget#getter(String)} instead.
*/
@Deprecated
PropertyConstraintMappingContext property(String property, ElementType type);

/**
* Selects a field to which the next operations shall apply.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*/
package org.hibernate.validator.internal.cfg.context;

import java.lang.annotation.ElementType;

import org.hibernate.validator.cfg.context.ConstructorConstraintMappingContext;
import org.hibernate.validator.cfg.context.ContainerElementConstraintMappingContext;
import org.hibernate.validator.cfg.context.MethodConstraintMappingContext;
Expand Down Expand Up @@ -54,12 +52,6 @@ public PropertyConstraintMappingContext ignoreAnnotations(boolean ignoreAnnotati
return this;
}

@Override
@SuppressWarnings("deprecation")
public PropertyConstraintMappingContext property(String property, ElementType elementType) {
return typeContext.property( property, elementType );
}

@Override
public PropertyConstraintMappingContext field(String property) {
return typeContext.field( property );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package org.hibernate.validator.internal.cfg.context;

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -117,12 +116,6 @@ protected ContainerElementConstraintMappingContext getThis() {
return this;
}

@Override
@Deprecated
public PropertyConstraintMappingContext property(String property, ElementType elementType) {
return typeContext.property( property, elementType );
}

@Override
public PropertyConstraintMappingContext field(String property) {
return typeContext.field( property );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,6 @@ public TypeConstraintMappingContext<C> defaultGroupSequenceProviderClass(Class<?
return this;
}

@Override
@Deprecated
public PropertyConstraintMappingContext property(String property, ElementType elementType) {
Contracts.assertNotNull( elementType, "The element type must not be null." );

if ( !( ElementType.FIELD.equals( elementType ) || ElementType.METHOD.equals( elementType ) ) ) {
throw LOG.getElementTypeHasToBeFieldOrMethodException();
}

if ( ElementType.FIELD == elementType ) {
return field( property );
}
else {
return getter( property );
}
}

@Override
public PropertyConstraintMappingContext field(String property) {
Contracts.assertNotEmpty( property, MESSAGES.propertyNameMustNotBeEmpty() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,6 @@ RuntimeException getTryingToInstantiateAnnotationWithUnknownAttributesException(
@Message(id = 87, value = "Property name cannot be null or empty.")
IllegalArgumentException getPropertyNameCannotBeNullOrEmptyException();

@Message(id = 88, value = "Element type has to be FIELD or METHOD.")
IllegalArgumentException getElementTypeHasToBeFieldOrMethodException();

@Message(id = 89, value = "Member %s is neither a field nor a method.")
IllegalArgumentException getMemberIsNeitherAFieldNorAMethodException(Member member);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;

import java.lang.annotation.ElementType;
import java.util.Arrays;
import java.util.Calendar;
import java.util.GregorianCalendar;
Expand Down Expand Up @@ -528,13 +527,12 @@ public void testProgrammaticAndAnnotationPropertyConstraintsAddUp() {
}

@Test
@SuppressWarnings("deprecation")
public void testDeprecatedPropertyMethodForFieldAndGetterProgrammaticConstraintDefinition() {
mapping.type( Marathon.class )
.property( "name", ElementType.METHOD )
.getter( "name" )
.constraint( new SizeDef().min( 5 ) )
.constraint( new SizeDef().min( 10 ) )
.property( "runners", ElementType.FIELD )
.field( "runners" )
.constraint( new SizeDef().max( 10 ).min( 1 ) );
config.addMapping( mapping );
Validator validator = config.buildValidatorFactory().getValidator();
Expand Down

0 comments on commit 5a6d58f

Please sign in to comment.