Skip to content

Commit caa1218

Browse files
committed
Polishing
1 parent c664010 commit caa1218

File tree

5 files changed

+67
-61
lines changed

5 files changed

+67
-61
lines changed

spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContext.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,31 @@ public class JodaTimeContext {
3838

3939

4040
/**
41-
* Set the user's chronology.
41+
* Set the user's chronology (calendar system).
4242
*/
4343
public void setChronology(Chronology chronology) {
4444
this.chronology = chronology;
4545
}
4646

4747
/**
48-
* The user's chronology (calendar system), if any.
48+
* Return the user's chronology (calendar system), if any.
4949
*/
5050
public Chronology getChronology() {
5151
return this.chronology;
5252
}
5353

5454
/**
55-
* Set the user's timezone.
55+
* Set the user's time zone.
5656
*/
5757
public void setTimeZone(DateTimeZone timeZone) {
5858
this.timeZone = timeZone;
5959
}
6060

6161
/**
62-
* The user's timezone, if any.
62+
* Return the user's time zone, if any.
6363
*/
6464
public DateTimeZone getTimeZone() {
65-
return timeZone;
65+
return this.timeZone;
6666
}
6767

6868

spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContext.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,31 @@ public class DateTimeContext {
3737

3838

3939
/**
40-
* Set the user's chronology.
40+
* Set the user's chronology (calendar system).
4141
*/
4242
public void setChronology(Chronology chronology) {
4343
this.chronology = chronology;
4444
}
4545

4646
/**
47-
* The user's chronology (calendar system), if any.
47+
* Return the user's chronology (calendar system), if any.
4848
*/
4949
public Chronology getChronology() {
5050
return this.chronology;
5151
}
5252

5353
/**
54-
* Set the user's timezone.
54+
* Set the user's time zone.
5555
*/
5656
public void setTimeZone(ZoneId timeZone) {
5757
this.timeZone = timeZone;
5858
}
5959

6060
/**
61-
* The user's timezone, if any.
61+
* Return the user's time zone, if any.
6262
*/
6363
public ZoneId getTimeZone() {
64-
return timeZone;
64+
return this.timeZone;
6565
}
6666

6767

spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@
4949
import org.springframework.util.StopWatch;
5050
import org.springframework.util.StringUtils;
5151

52-
import static org.hamcrest.Matchers.greaterThan;
52+
import static org.hamcrest.Matchers.*;
5353
import static org.junit.Assert.*;
5454

5555
/**
@@ -81,14 +81,14 @@ public void canConvertIllegalArgumentNullTargetType() {
8181
try {
8282
assertFalse(conversionService.canConvert(String.class, null));
8383
fail("Should have failed");
84-
} catch (IllegalArgumentException e) {
85-
84+
}
85+
catch (IllegalArgumentException ex) {
8686
}
8787
try {
8888
assertFalse(conversionService.canConvert(TypeDescriptor.valueOf(String.class), null));
8989
fail("Should have failed");
90-
} catch (IllegalArgumentException e) {
91-
90+
}
91+
catch (IllegalArgumentException ex) {
9292
}
9393
}
9494

@@ -151,8 +151,8 @@ public Object convert(Object source) {
151151
}
152152
});
153153
fail("Should have failed");
154-
} catch (IllegalArgumentException e) {
155-
154+
}
155+
catch (IllegalArgumentException ex) {
156156
}
157157
}
158158

@@ -254,7 +254,8 @@ public void genericConverterDelegatingBackToConversionServiceConverterNotFound()
254254
try {
255255
conversionService.convert("3,4,5", Integer[].class);
256256
fail("should have failed");
257-
} catch (ConverterNotFoundException e) {
257+
}
258+
catch (ConverterNotFoundException ex) {
258259
}
259260
}
260261

@@ -389,7 +390,7 @@ public void testIgnoreCopyConstructor() {
389390
}
390391

391392
@Test
392-
public void testConvertUUID() throws Exception {
393+
public void testConvertUUID() {
393394
GenericConversionService service = new DefaultConversionService();
394395
UUID uuid = UUID.randomUUID();
395396
String convertToString = service.convert(uuid, String.class);
@@ -472,7 +473,7 @@ public void testPerformance3() throws Exception {
472473
public static Map<String, Integer> map;
473474

474475
@Test
475-
public void emptyListToArray() throws Exception {
476+
public void emptyListToArray() {
476477
conversionService.addConverter(new CollectionToArrayConverter(conversionService));
477478
conversionService.addConverterFactory(new StringToNumberConverterFactory());
478479
List<String> list = new ArrayList<String>();
@@ -483,7 +484,7 @@ public void emptyListToArray() throws Exception {
483484
}
484485

485486
@Test
486-
public void emptyListToObject() throws Exception {
487+
public void emptyListToObject() {
487488
conversionService.addConverter(new CollectionToObjectConverter(conversionService));
488489
conversionService.addConverterFactory(new StringToNumberConverterFactory());
489490
List<String> list = new ArrayList<String>();
@@ -590,30 +591,30 @@ public void stringToCollectionCanConvert() throws Exception {
590591
public Collection<Integer> stringToCollection;
591592

592593
@Test
593-
public void testConvertiblePairsInSet() throws Exception {
594+
public void testConvertiblePairsInSet() {
594595
Set<GenericConverter.ConvertiblePair> set = new HashSet<GenericConverter.ConvertiblePair>();
595596
set.add(new GenericConverter.ConvertiblePair(Number.class, String.class));
596597
assert set.contains(new GenericConverter.ConvertiblePair(Number.class, String.class));
597598
}
598599

599600
@Test
600-
public void testConvertiblePairEqualsAndHash() throws Exception {
601+
public void testConvertiblePairEqualsAndHash() {
601602
GenericConverter.ConvertiblePair pair = new GenericConverter.ConvertiblePair(Number.class, String.class);
602603
GenericConverter.ConvertiblePair pairEqual = new GenericConverter.ConvertiblePair(Number.class, String.class);
603604
assertEquals(pair, pairEqual);
604605
assertEquals(pair.hashCode(), pairEqual.hashCode());
605606
}
606607

607608
@Test
608-
public void testConvertiblePairDifferentEqualsAndHash() throws Exception {
609+
public void testConvertiblePairDifferentEqualsAndHash() {
609610
GenericConverter.ConvertiblePair pair = new GenericConverter.ConvertiblePair(Number.class, String.class);
610611
GenericConverter.ConvertiblePair pairOpposite = new GenericConverter.ConvertiblePair(String.class, Number.class);
611612
assertFalse(pair.equals(pairOpposite));
612613
assertFalse(pair.hashCode() == pairOpposite.hashCode());
613614
}
614615

615616
@Test
616-
public void convertPrimitiveArray() throws Exception {
617+
public void convertPrimitiveArray() {
617618
GenericConversionService conversionService = new DefaultConversionService();
618619
byte[] byteArray = new byte[] { 1, 2, 3 };
619620
Byte[] converted = conversionService.convert(byteArray, Byte[].class);
@@ -625,7 +626,8 @@ public void canConvertIllegalArgumentNullTargetTypeFromClass() {
625626
try {
626627
conversionService.canConvert(String.class, null);
627628
fail("Did not thow IllegalArgumentException");
628-
} catch(IllegalArgumentException e) {
629+
}
630+
catch (IllegalArgumentException ex) {
629631
}
630632
}
631633

@@ -634,13 +636,14 @@ public void canConvertIllegalArgumentNullTargetTypeFromTypeDescriptor() {
634636
try {
635637
conversionService.canConvert(TypeDescriptor.valueOf(String.class), null);
636638
fail("Did not thow IllegalArgumentException");
637-
} catch(IllegalArgumentException e) {
639+
}
640+
catch(IllegalArgumentException ex) {
638641
}
639642
}
640643

641644
@Test
642645
@SuppressWarnings({ "rawtypes" })
643-
public void convertHashMapValuesToList() throws Exception {
646+
public void convertHashMapValuesToList() {
644647
GenericConversionService conversionService = new DefaultConversionService();
645648
Map<String, Integer> hashMap = new LinkedHashMap<String, Integer>();
646649
hashMap.put("1", 1);
@@ -650,15 +653,15 @@ public void convertHashMapValuesToList() throws Exception {
650653
}
651654

652655
@Test
653-
public void removeConvertible() throws Exception {
656+
public void removeConvertible() {
654657
conversionService.addConverter(new ColorConverter());
655658
assertTrue(conversionService.canConvert(String.class, Color.class));
656659
conversionService.removeConvertible(String.class, Color.class);
657660
assertFalse(conversionService.canConvert(String.class, Color.class));
658661
}
659662

660663
@Test
661-
public void conditionalConverter() throws Exception {
664+
public void conditionalConverter() {
662665
GenericConversionService conversionService = new GenericConversionService();
663666
MyConditionalConverter converter = new MyConditionalConverter();
664667
conversionService.addConverter(new ColorConverter());
@@ -668,7 +671,7 @@ public void conditionalConverter() throws Exception {
668671
}
669672

670673
@Test
671-
public void conditionalConverterFactory() throws Exception {
674+
public void conditionalConverterFactory() {
672675
GenericConversionService conversionService = new GenericConversionService();
673676
MyConditionalConverterFactory converter = new MyConditionalConverterFactory();
674677
conversionService.addConverter(new ColorConverter());
@@ -679,32 +682,29 @@ public void conditionalConverterFactory() throws Exception {
679682
}
680683

681684
@Test
682-
public void shouldNotSuportNullConvertibleTypesFromNonConditionalGenericConverter()
683-
throws Exception {
685+
public void shouldNotSuportNullConvertibleTypesFromNonConditionalGenericConverter() {
684686
GenericConversionService conversionService = new GenericConversionService();
685687
GenericConverter converter = new GenericConverter() {
686-
687688
@Override
688689
public Set<ConvertiblePair> getConvertibleTypes() {
689690
return null;
690691
}
691-
692692
@Override
693-
public Object convert(Object source, TypeDescriptor sourceType,
694-
TypeDescriptor targetType) {
693+
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
695694
return null;
696695
}
697696
};
698697
try {
699698
conversionService.addConverter(converter);
700699
fail("Did not throw");
701-
} catch (IllegalStateException e) {
702-
assertEquals("Only conditional converters may return null convertible types", e.getMessage());
700+
}
701+
catch (IllegalStateException ex) {
702+
assertEquals("Only conditional converters may return null convertible types", ex.getMessage());
703703
}
704704
}
705705

706706
@Test
707-
public void conditionalConversionForAllTypes() throws Exception {
707+
public void conditionalConversionForAllTypes() {
708708
GenericConversionService conversionService = new GenericConversionService();
709709
MyConditionalGenericConverter converter = new MyConditionalGenericConverter();
710710
conversionService.addConverter(converter);
@@ -717,7 +717,7 @@ public void conditionalConversionForAllTypes() throws Exception {
717717
}
718718

719719
@Test
720-
public void convertOptimizeArray() throws Exception {
720+
public void convertOptimizeArray() {
721721
// SPR-9566
722722
GenericConversionService conversionService = new DefaultConversionService();
723723
byte[] byteArray = new byte[] { 1, 2, 3 };
@@ -726,7 +726,7 @@ public void convertOptimizeArray() throws Exception {
726726
}
727727

728728
@Test
729-
public void convertCannotOptimizeArray() throws Exception {
729+
public void convertCannotOptimizeArray() {
730730
GenericConversionService conversionService = new GenericConversionService();
731731
conversionService.addConverter(new Converter<Byte, Byte>() {
732732
@Override
@@ -766,15 +766,15 @@ public void convertNullAnnotatedStringToString() throws Exception {
766766
conversionService.convert(source, sourceType, targetType);
767767
}
768768

769+
769770
@ExampleAnnotation
770771
public String annotatedString;
771772

772773
@Retention(RetentionPolicy.RUNTIME)
773774
public static @interface ExampleAnnotation {
774775
}
775776

776-
private static class MyConditionalConverter implements Converter<String, Color>,
777-
ConditionalConverter {
777+
private static class MyConditionalConverter implements Converter<String, Color>, ConditionalConverter {
778778

779779
private int matchAttempts = 0;
780780

@@ -850,23 +850,26 @@ public int getNestedMatchAttempts() {
850850
}
851851

852852
interface MyEnumInterface {
853+
853854
String getCode();
854855
}
855856

856857
public static enum MyEnum implements MyEnumInterface {
858+
857859
A {
858860
@Override
859861
public String getCode() {
860862
return "1";
861863
}
862-
};
864+
}
863865
}
864866

865-
private static class MyEnumInterfaceToStringConverter<T extends MyEnumInterface>
866-
implements Converter<T, String> {
867+
private static class MyEnumInterfaceToStringConverter<T extends MyEnumInterface> implements Converter<T, String> {
868+
867869
@Override
868870
public String convert(T source) {
869871
return source.getCode();
870872
}
871873
}
874+
872875
}

spring-webmvc/src/main/java/org/springframework/web/servlet/support/JstlUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -141,6 +141,6 @@ public Locale getLocale() {
141141
}
142142
return RequestContextUtils.getLocale(this.request);
143143
}
144-
};
144+
}
145145

146146
}

0 commit comments

Comments
 (0)