Skip to content

Commit

Permalink
Apply @OverRide annotation to editors/formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Jul 25, 2017
1 parent ca862e4 commit d4431f6
Show file tree
Hide file tree
Showing 65 changed files with 139 additions and 3 deletions.
Expand Up @@ -36,10 +36,12 @@ public abstract class AbstractPropertyEditor extends PropertyEditorSupport imple
private String format;

@Nullable
@Override
public String getFormat() {
return format;
}

@Override
public void setFormat(@Nullable String format) {
this.format = format;
}
Expand Down Expand Up @@ -83,6 +85,7 @@ protected String getAsTextInternal() {
return super.getAsText();
}

@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public String getFormattedValue() {
Object value = getValueInternal();
Expand All @@ -93,6 +96,7 @@ public String getFormattedValue() {
return value != null ? value.toString() : null;
}

@Override
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void setFormattedValue(String value) {
Formatter<?> formatter = resolveFormatter();
Expand Down
Expand Up @@ -28,6 +28,7 @@
* @since 2.0.0
*/
public class BigDecimalPropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand Down Expand Up @@ -58,6 +59,7 @@ protected void handleAsNumber(Number number) {
}
}

@Override
protected Formatter<BigDecimal> resolveFormatter() {
return isBlank(getFormat()) ? null : new BigDecimalFormatter(getFormat());
}
Expand Down
Expand Up @@ -28,6 +28,7 @@
* @since 2.0.0
*/
public class BigIntegerPropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand Down Expand Up @@ -58,6 +59,7 @@ protected void handleAsNumber(Number number) {
}
}

@Override
protected Formatter<BigInteger> resolveFormatter() {
return isBlank(getFormat()) ? null : new BigIntegerFormatter(getFormat());
}
Expand Down
Expand Up @@ -25,6 +25,7 @@
* @since 2.0.0
*/
public class BooleanPropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand All @@ -45,6 +46,7 @@ protected void handleAsBoolean(Boolean bool) {
super.setValueInternal(bool);
}

@Override
protected Formatter<Boolean> resolveFormatter() {
return isBlank(getFormat()) ? null : BooleanFormatter.getInstance(getFormat());
}
Expand Down
Expand Up @@ -25,6 +25,7 @@
* @since 2.0.0
*/
public class BytePropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand All @@ -49,6 +50,7 @@ protected void handleAsNumber(Number number) {
super.setValueInternal(number.byteValue());
}

@Override
protected Formatter<Byte> resolveFormatter() {
return isBlank(getFormat()) ? null : new ByteFormatter(getFormat());
}
Expand Down
Expand Up @@ -30,6 +30,7 @@
* @since 2.0.0
*/
public class CalendarPropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand Down Expand Up @@ -73,6 +74,7 @@ protected void handleAsString(String str) {
}
}

@Override
protected Formatter<Calendar> resolveFormatter() {
return isBlank(getFormat()) ? null : new CalendarFormatter(getFormat());
}
Expand Down
Expand Up @@ -30,6 +30,7 @@
* @since 2.0.0
*/
public class DatePropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand Down Expand Up @@ -66,6 +67,7 @@ protected void handleAsString(String str) {
}
}

@Override
protected Formatter<Date> resolveFormatter() {
return isBlank(getFormat()) ? null : new DateFormatter(getFormat());
}
Expand Down
Expand Up @@ -25,6 +25,7 @@
* @since 2.0.0
*/
public class DoublePropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand All @@ -49,6 +50,7 @@ protected void handleAsNumber(Number number) {
super.setValueInternal(number.doubleValue());
}

@Override
protected Formatter<Double> resolveFormatter() {
return isBlank(getFormat()) ? null : new DoubleFormatter(getFormat());
}
Expand Down
Expand Up @@ -33,6 +33,7 @@ public void setEnumType(Class<? extends Enum> enumType) {
this.enumType = enumType;
}

@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand Down
Expand Up @@ -24,6 +24,7 @@
* @since 2.0.0
*/
public class FilePropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand Down
Expand Up @@ -25,6 +25,7 @@
* @since 2.0.0
*/
public class FloatPropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand All @@ -49,6 +50,7 @@ protected void handleAsNumber(Number number) {
super.setValueInternal(number.floatValue());
}

@Override
protected Formatter<Float> resolveFormatter() {
return isBlank(getFormat()) ? null : new FloatFormatter(getFormat());
}
Expand Down
Expand Up @@ -25,6 +25,7 @@
* @since 2.0.0
*/
public class IntegerPropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand All @@ -49,6 +50,7 @@ protected void handleAsNumber(Number number) {
super.setValueInternal(number.intValue());
}

@Override
protected Formatter<Integer> resolveFormatter() {
return isBlank(getFormat()) ? null : new IntegerFormatter(getFormat());
}
Expand Down
Expand Up @@ -25,6 +25,7 @@
* @since 2.0.0
*/
public class LocalePropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand All @@ -37,6 +38,7 @@ protected void setValueInternal(Object value) {
}
}

@Override
protected Formatter<Locale> resolveFormatter() {
return new LocaleFormatter();
}
Expand Down
Expand Up @@ -25,6 +25,7 @@
* @since 2.0.0
*/
public class LongPropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand All @@ -49,6 +50,7 @@ protected void handleAsNumber(Number number) {
super.setValueInternal(number.longValue());
}

@Override
protected Formatter<Long> resolveFormatter() {
return isBlank(getFormat()) ? null : new LongFormatter(getFormat());
}
Expand Down
Expand Up @@ -58,11 +58,13 @@ public PropertyEditorChain(@Nonnull Class<?> targetClass, @Nonnull Class<? exten
}
}

@Override
@Nullable
public String getFormat() {
return format;
}

@Override
public void setFormat(@Nullable String format) {
this.format = format;
}
Expand Down Expand Up @@ -127,6 +129,7 @@ public void setValue(Object value) {
}
}

@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public String getFormattedValue() {
initPropertyEditors();
Expand All @@ -149,6 +152,7 @@ public String getFormattedValue() {
throw illegalValue(value, targetClass);
}

@Override
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void setFormattedValue(String value) {
initPropertyEditors();
Expand Down
Expand Up @@ -25,6 +25,7 @@
* @since 2.0.0
*/
public class ShortPropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand All @@ -49,6 +50,7 @@ protected void handleAsNumber(Number number) {
super.setValueInternal(number.shortValue());
}

@Override
protected Formatter<Short> resolveFormatter() {
return isBlank(getFormat()) ? null : new ShortFormatter(getFormat());
}
Expand Down
Expand Up @@ -20,6 +20,7 @@
* @since 2.0.0
*/
public class StringPropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand Down
Expand Up @@ -26,6 +26,7 @@
* @since 2.0.0
*/
public class URIPropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand Down
Expand Up @@ -26,6 +26,7 @@
* @since 2.0.0
*/
public class URLPropertyEditor extends AbstractPropertyEditor {
@Override
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
Expand Down
Expand Up @@ -15,14 +15,17 @@
*/
package griffon.core.editors;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
* @author Andres Almiray
* @since 2.0.0
*/
public class ValueConversionException extends IllegalArgumentException {
private static final long serialVersionUID = 6344566641106178891L;

private Object value;
private final Object value;
private Class<?> type;

public ValueConversionException(Object value) {
Expand All @@ -44,10 +47,12 @@ public ValueConversionException(Object value, Exception cause) {
this.value = value;
}

@Nonnull
public Object getValue() {
return value;
}

@Nullable
public Class<?> getType() {
return type;
}
Expand Down
Expand Up @@ -51,6 +51,7 @@ public BigDecimalFormatter(@Nullable String pattern) {
}

@Nullable
@Override
public String format(@Nullable BigDecimal number) {
return number == null ? null : numberFormat.format(number);
}
Expand Down
Expand Up @@ -52,6 +52,7 @@ public BigIntegerFormatter(@Nullable String pattern) {
}

@Nullable
@Override
public String format(@Nullable BigInteger number) {
return number == null ? null : numberFormat.format(number);
}
Expand Down
Expand Up @@ -104,7 +104,7 @@ public Boolean parse(@Nullable String str) throws ParseException {
return isBlank(str) ? null : delegate.parse(str);
}

private static interface BooleanFormatterDelegate {
private interface BooleanFormatterDelegate {
@Nonnull
String getPattern();

Expand All @@ -125,17 +125,20 @@ private AbstractBooleanFormatterDelegate(String pattern, String[] tokens) {
}

@Nonnull
@Override
public String getPattern() {
return pattern;
}

@Nonnull
@Override
public String format(@Nonnull Boolean bool) {
requireNonNull(bool, "Can't format given Boolean because it's null");
return bool ? tokens[1] : tokens[0];
}

@Nonnull
@Override
public Boolean parse(@Nonnull String str) throws ParseException {
if (tokens[0].equalsIgnoreCase(str)) {
return Boolean.FALSE;
Expand Down
Expand Up @@ -49,6 +49,7 @@ public ByteFormatter(@Nullable String pattern) {
}

@Nullable
@Override
public String format(@Nullable Byte number) {
return number == null ? null : numberFormat.format(number);
}
Expand Down
Expand Up @@ -47,6 +47,7 @@ public String getPattern() {
}

@Nullable
@Override
public String format(@Nullable Calendar date) {
return date == null ? null : dateFormat.format(date.getTime());
}
Expand Down
Expand Up @@ -47,6 +47,7 @@ public String getPattern() {
}

@Nullable
@Override
public String format(@Nullable Date date) {
return date == null ? null : dateFormat.format(date);
}
Expand Down

0 comments on commit d4431f6

Please sign in to comment.