Skip to content

Commit

Permalink
Move and rename converters into com.vaadin.legacy.data.util.converter…
Browse files Browse the repository at this point in the history
….Legacy*

Change-Id: I75fd33e66c8c5c265bc60cce58ff639a5d5642ab
  • Loading branch information
Artur- committed Aug 10, 2016
1 parent 314eb37 commit 192e93a
Show file tree
Hide file tree
Showing 80 changed files with 480 additions and 480 deletions.
Expand Up @@ -16,7 +16,7 @@
package com.vaadin.data.util;

import com.vaadin.data.Property;
import com.vaadin.data.util.converter.Converter;
import com.vaadin.legacy.data.util.converter.LegacyConverter;

/**
* Formatting proxy for a {@link Property}.
Expand Down Expand Up @@ -46,7 +46,7 @@ public Object parse(String formattedValue) throws Exception {
* type of the underlying property (a PropertyFormatter is always a
* Property<String>)
*
* @deprecated As of 7.0, replaced by {@link Converter}
* @deprecated As of 7.0, replaced by {@link LegacyConverter}
* @author Vaadin Ltd.
* @since 5.3.0
*/
Expand Down
Expand Up @@ -22,7 +22,7 @@

import com.vaadin.data.Property;
import com.vaadin.data.util.LegacyPropertyHelper;
import com.vaadin.data.util.converter.Converter.ConversionException;
import com.vaadin.legacy.data.util.converter.LegacyConverter.ConversionException;

/**
* ColumnProperty represents the value of one column in a RowItem. In addition
Expand Down
Expand Up @@ -14,7 +14,7 @@
* the License.
*/

package com.vaadin.data.util.converter;
package com.vaadin.legacy.data.util.converter;

import java.text.NumberFormat;
import java.text.ParsePosition;
Expand All @@ -32,8 +32,8 @@
* @author Vaadin Ltd
* @since 7.1
*/
public abstract class AbstractStringToNumberConverter<T> implements
Converter<String, T> {
public abstract class LegacyAbstractStringToNumberConverter<T> implements
LegacyConverter<String, T> {

/**
* Returns the format used by {@link #convertToPresentation(Object, Locale)}
Expand Down
Expand Up @@ -14,7 +14,7 @@
* the License.
*/

package com.vaadin.data.util.converter;
package com.vaadin.legacy.data.util.converter;

import java.io.Serializable;
import java.util.Locale;
Expand Down Expand Up @@ -47,7 +47,7 @@
* @author Vaadin Ltd.
* @since 7.0
*/
public interface Converter<PRESENTATION, MODEL> extends Serializable {
public interface LegacyConverter<PRESENTATION, MODEL> extends Serializable {

/**
* Converts the given value from target type to source type.
Expand Down Expand Up @@ -121,8 +121,8 @@ public PRESENTATION convertToPresentation(MODEL value,

/**
* An exception that signals that the value passed to
* {@link Converter#convertToPresentation(Object, Class, Locale)} or
* {@link Converter#convertToModel(Object, Class, Locale)} could not be
* {@link LegacyConverter#convertToPresentation(Object, Class, Locale)} or
* {@link LegacyConverter#convertToModel(Object, Class, Locale)} could not be
* converted.
*
* @author Vaadin Ltd
Expand Down
Expand Up @@ -14,7 +14,7 @@
* the License.
*/

package com.vaadin.data.util.converter;
package com.vaadin.legacy.data.util.converter;

import java.io.Serializable;

Expand All @@ -26,8 +26,8 @@
* @since 7.0
*
*/
public interface ConverterFactory extends Serializable {
public <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL> createConverter(
public interface LegacyConverterFactory extends Serializable {
public <PRESENTATION, MODEL> LegacyConverter<PRESENTATION, MODEL> createConverter(
Class<PRESENTATION> presentationType, Class<MODEL> modelType);

}
Expand Up @@ -13,19 +13,19 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.data.util.converter;
package com.vaadin.legacy.data.util.converter;

import java.io.Serializable;
import java.util.Locale;

import com.vaadin.server.VaadinSession;

public class ConverterUtil implements Serializable {
public class LegacyConverterUtil implements Serializable {

/**
* Finds a converter that can convert from the given presentation type to
* the given model type and back. Uses the given application to find a
* {@link ConverterFactory} or, if application is null, uses the
* {@link LegacyConverterFactory} or, if application is null, uses the
* {@link VaadinSession#getCurrent()}.
*
* @param <PRESENTATIONTYPE>
Expand All @@ -42,16 +42,16 @@ public class ConverterUtil implements Serializable {
* @return a Converter capable of converting between the given types or null
* if no converter was found
*/
public static <PRESENTATIONTYPE, MODELTYPE> Converter<PRESENTATIONTYPE, MODELTYPE> getConverter(
public static <PRESENTATIONTYPE, MODELTYPE> LegacyConverter<PRESENTATIONTYPE, MODELTYPE> getConverter(
Class<PRESENTATIONTYPE> presentationType,
Class<MODELTYPE> modelType, VaadinSession session) {
Converter<PRESENTATIONTYPE, MODELTYPE> converter = null;
LegacyConverter<PRESENTATIONTYPE, MODELTYPE> converter = null;
if (session == null) {
session = VaadinSession.getCurrent();
}

if (session != null) {
ConverterFactory factory = session.getConverterFactory();
LegacyConverterFactory factory = session.getConverterFactory();
converter = factory.createConverter(presentationType, modelType);
}
return converter;
Expand All @@ -77,15 +77,15 @@ public static <PRESENTATIONTYPE, MODELTYPE> Converter<PRESENTATIONTYPE, MODELTYP
* @return the converted value, compatible with the presentation type, or
* the original value if its type is compatible and no converter is
* set.
* @throws Converter.ConversionException
* @throws LegacyConverter.ConversionException
* if there was a problem converting the value
*/
@SuppressWarnings("unchecked")
public static <PRESENTATIONTYPE, MODELTYPE> PRESENTATIONTYPE convertFromModel(
MODELTYPE modelValue,
Class<? extends PRESENTATIONTYPE> presentationType,
Converter<PRESENTATIONTYPE, MODELTYPE> converter, Locale locale)
throws Converter.ConversionException {
LegacyConverter<PRESENTATIONTYPE, MODELTYPE> converter, Locale locale)
throws LegacyConverter.ConversionException {
if (converter != null) {
/*
* If there is a converter, always use it. It must convert or throw
Expand All @@ -95,7 +95,7 @@ public static <PRESENTATIONTYPE, MODELTYPE> PRESENTATIONTYPE convertFromModel(
modelValue, presentationType, locale);
if (presentation != null
&& !presentationType.isInstance(presentation)) {
throw new Converter.ConversionException(
throw new LegacyConverter.ConversionException(
"Converter returned an object of type "
+ presentation.getClass().getName()
+ " when expecting "
Expand All @@ -113,7 +113,7 @@ public static <PRESENTATIONTYPE, MODELTYPE> PRESENTATIONTYPE convertFromModel(
if (presentationType.isAssignableFrom(modelValue.getClass())) {
return (PRESENTATIONTYPE) modelValue;
} else {
throw new Converter.ConversionException(
throw new LegacyConverter.ConversionException(
"Unable to convert value of type "
+ modelValue.getClass().getName()
+ " to presentation type "
Expand Down Expand Up @@ -141,13 +141,13 @@ public static <PRESENTATIONTYPE, MODELTYPE> PRESENTATIONTYPE convertFromModel(
*
* @return the converted value, compatible with the model type, or the
* original value if its type is compatible and no converter is set.
* @throws Converter.ConversionException
* @throws LegacyConverter.ConversionException
* if there was a problem converting the value
*/
public static <MODELTYPE, PRESENTATIONTYPE> MODELTYPE convertToModel(
PRESENTATIONTYPE presentationValue, Class<MODELTYPE> modelType,
Converter<PRESENTATIONTYPE, MODELTYPE> converter, Locale locale)
throws Converter.ConversionException {
LegacyConverter<PRESENTATIONTYPE, MODELTYPE> converter, Locale locale)
throws LegacyConverter.ConversionException {
if (converter != null) {
/*
* If there is a converter, always use it. It must convert or throw
Expand All @@ -156,7 +156,7 @@ public static <MODELTYPE, PRESENTATIONTYPE> MODELTYPE convertToModel(
MODELTYPE model = converter.convertToModel(presentationValue,
modelType, locale);
if (model != null && !modelType.isInstance(model)) {
throw new Converter.ConversionException(
throw new LegacyConverter.ConversionException(
"Converter returned an object of type "
+ model.getClass().getName()
+ " when expecting " + modelType.getName());
Expand All @@ -178,7 +178,7 @@ public static <MODELTYPE, PRESENTATIONTYPE> MODELTYPE convertToModel(
// presentation type directly compatible with model type
return modelType.cast(presentationValue);
} else {
throw new Converter.ConversionException(
throw new LegacyConverter.ConversionException(
"Unable to convert value of type "
+ presentationValue.getClass().getName()
+ " to model type "
Expand All @@ -193,7 +193,7 @@ public static <MODELTYPE, PRESENTATIONTYPE> MODELTYPE convertToModel(
* presentation and model type. Does strict type checking and only returns
* true if the converter claims it can handle exactly the given types.
*
* @see #canConverterPossiblyHandle(Converter, Class, Class)
* @see #canConverterPossiblyHandle(LegacyConverter, Class, Class)
*
* @param converter
* The converter to check. If this is null the result is always
Expand All @@ -205,7 +205,7 @@ public static <MODELTYPE, PRESENTATIONTYPE> MODELTYPE convertToModel(
* @return true if the converter supports conversion between the given
* presentation and model type, false otherwise
*/
public static boolean canConverterHandle(Converter<?, ?> converter,
public static boolean canConverterHandle(LegacyConverter<?, ?> converter,
Class<?> presentationType, Class<?> modelType) {
if (converter == null) {
return false;
Expand Down Expand Up @@ -235,7 +235,7 @@ public static boolean canConverterHandle(Converter<?, ?> converter,
* @return true if the converter possibly support conversion between the
* given presentation and model type, false otherwise
*/
public static boolean canConverterPossiblyHandle(Converter<?, ?> converter,
public static boolean canConverterPossiblyHandle(LegacyConverter<?, ?> converter,
Class<?> presentationType, Class<?> modelType) {
if (converter == null) {
return false;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* the License.
*/

package com.vaadin.data.util.converter;
package com.vaadin.legacy.data.util.converter;

import java.util.Date;
import java.util.Locale;
Expand All @@ -25,7 +25,7 @@
* @author Vaadin Ltd
* @since 7.0
*/
public class DateToLongConverter implements Converter<Date, Long> {
public class LegacyDateToLongConverter implements LegacyConverter<Date, Long> {

/*
* (non-Javadoc)
Expand Down
Expand Up @@ -17,7 +17,7 @@
/**
*
*/
package com.vaadin.data.util.converter;
package com.vaadin.legacy.data.util.converter;

import java.util.Date;
import java.util.Locale;
Expand All @@ -32,7 +32,7 @@
* @since 7.1
* @author Vaadin Ltd
*/
public class DateToSqlDateConverter implements Converter<Date, java.sql.Date> {
public class LegacyDateToSqlDateConverter implements LegacyConverter<Date, java.sql.Date> {

@Override
public java.sql.Date convertToModel(Date value,
Expand Down

0 comments on commit 192e93a

Please sign in to comment.