Skip to content

Commit

Permalink
Fixing compiler warnings and rearranging a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwcarman committed Sep 29, 2011
1 parent 95a4786 commit 54e138a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
Expand Up @@ -54,12 +54,12 @@ public JodaTextField(String id, IModel<T> model, JodaFormatSupport<T> formatSupp
//----------------------------------------------------------------------------------------------------------------------

@Override
// public IConverter getConverter(Class<?> type)
@SuppressWarnings("unchecked")
public <C> IConverter<C> getConverter(Class<C> type)
{
if (type.equals(getType()))
{
return new DateTimeFormatSupportConverter<T>(formatSupport);
return new DateTimeFormatSupportConverter<C>((JodaFormatSupport<C>)formatSupport);
}
return super.getConverter(type);
}
Expand Down
Expand Up @@ -24,25 +24,36 @@
/**
* @since 1.0
*/
public class DateTimeFormatSupportConverter<T> implements IConverter
public class DateTimeFormatSupportConverter<T> implements IConverter<T>
{
//----------------------------------------------------------------------------------------------------------------------
// Fields
//----------------------------------------------------------------------------------------------------------------------

private final JodaFormatSupport<T> formatSupport;

//----------------------------------------------------------------------------------------------------------------------
// Constructors
//----------------------------------------------------------------------------------------------------------------------

public DateTimeFormatSupportConverter(JodaFormatSupport<T> formatSupport)
{
this.formatSupport = formatSupport;
}

//----------------------------------------------------------------------------------------------------------------------
// IConverter Implementation
//----------------------------------------------------------------------------------------------------------------------

@Override
public Object convertToObject(String value, Locale locale)
public T convertToObject(String value, Locale locale)
{
return formatSupport.convertToObject(value, locale);
}

@Override
@SuppressWarnings("unchecked")
public String convertToString(Object value, Locale locale)
public String convertToString(T value, Locale locale)
{
return formatSupport.convertToString((T)value, locale);
return formatSupport.convertToString(value, locale);
}
}
Expand Up @@ -36,7 +36,6 @@ public class JodaTextFieldProvider<T> implements PropertyEditorProvider

private JodaFormatSupport<T> formatSupport;


//----------------------------------------------------------------------------------------------------------------------
// Constructors
//----------------------------------------------------------------------------------------------------------------------
Expand Down
Expand Up @@ -56,6 +56,4 @@ public ViewerBuilder createPropertyViewer(String componentId, PropertyMetaData p
final FormatProvider specifiedFormatProvider = propertyMetadata.getFacet(FormatProvider.FACET_KEY);
return new JodaLabel<T>(componentId, (IModel<T>) propertyModel, specifiedFormatProvider == null ? formatSupport : formatSupport.withProvider(specifiedFormatProvider));
}


}
Expand Up @@ -24,6 +24,10 @@
*/
public interface DateTimeTranslator<T> extends IClusterable
{
DateTime toDateTime(T object);
//----------------------------------------------------------------------------------------------------------------------
// Other Methods
//----------------------------------------------------------------------------------------------------------------------

T fromDateTime(DateTime dateTime);
DateTime toDateTime(T object);
}
Expand Up @@ -24,6 +24,7 @@
*/
public abstract class AbstractTextComponentPropertyEditor extends AbstractFormComponentPropertyEditor
{
@SuppressWarnings("unchecked")
protected AbstractTextComponentPropertyEditor(String id, PropertyMetaData propertyMetaData, AbstractTextComponent formComponent)
{
super(id, propertyMetaData, formComponent);
Expand Down

0 comments on commit 54e138a

Please sign in to comment.