Skip to content
This repository was archived by the owner on Sep 4, 2020. It is now read-only.

Commit 2ca7d8f

Browse files
author
Peter Nied
committed
Fixing CheckStyle issues
Fixing a number of check style issues
1 parent 59ee5da commit 2ca7d8f

3 files changed

Lines changed: 30 additions & 31 deletions

File tree

graphsdk/src/main/java/com/microsoft/graph/model/DateOnly.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,35 @@
99
*/
1010
public class DateOnly {
1111

12-
private final int
13-
mYear,
14-
mMonth,
15-
mDay;
12+
/**
13+
* The year
14+
*/
15+
private final int mYear;
16+
17+
/**
18+
* The month
19+
*/
20+
private final int mMonth;
21+
22+
/**
23+
* The day
24+
*/
25+
private final int mDay;
1626

1727
/**
1828
* Constructs a timezone-nonspecific DateOnly
1929
*
2030
* @param dateStr date string of the form <code>yyyy-mm-dd</code>
31+
* @return the parsed DateOnly instance
32+
* @exception ParseException If there was a failure parsing the dateStr
2133
*/
22-
public static DateOnly parse(String dateStr) throws ParseException {
34+
public static DateOnly parse(final String dateStr) throws ParseException {
2335
// break the date up into its constituent parts
2436
String[] dateInfo = dateStr.split("-");
2537

26-
// validate our split datestring
27-
if (dateInfo.length != 3) {
38+
// validate the split date string
39+
final int expectedLength = 3;
40+
if (dateInfo.length != expectedLength) {
2841
throw new ParseException(
2942
"Expected datestring format 'yyyy-mm-dd' but found: " + dateStr, 0
3043
);
@@ -50,7 +63,7 @@ public static DateOnly parse(String dateStr) throws ParseException {
5063
* @param month 1-indexed month value (Jan == 1)
5164
* @param day day of the month
5265
*/
53-
public DateOnly(int year, int month, int day) {
66+
public DateOnly(final int year, final int month, final int day) {
5467
mYear = year;
5568
mMonth = month;
5669
mDay = day;

graphsdk/src/main/java/com/microsoft/graph/serializer/DateOnlySerializer.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

graphsdk/src/main/java/com/microsoft/graph/serializer/GsonFactory.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,26 +128,28 @@ public byte[] deserialize(final JsonElement json,
128128

129129
final JsonSerializer<DateOnly> dateJsonSerializer = new JsonSerializer<DateOnly>() {
130130
@Override
131-
public JsonElement serialize(DateOnly src, Type typeOfSrc, JsonSerializationContext context) {
131+
public JsonElement serialize(final DateOnly src,
132+
final Type typeOfSrc,
133+
final JsonSerializationContext context) {
132134
if (src == null) {
133135
return null;
134136
}
135-
return new JsonPrimitive(DateOnlySerializer.serialize(src));
137+
return new JsonPrimitive(src.toString());
136138
}
137139
};
138140

139141
final JsonDeserializer<DateOnly> dateJsonDeserializer = new JsonDeserializer<DateOnly>() {
140142
@Override
141-
public DateOnly deserialize(JsonElement json,
142-
Type typeOfT,
143-
JsonDeserializationContext context) throws JsonParseException {
143+
public DateOnly deserialize(final JsonElement json,
144+
final Type typeOfT,
145+
final JsonDeserializationContext context) throws JsonParseException {
144146
if (json == null) {
145147
return null;
146148
}
147149

148150
try {
149-
return DateOnlySerializer.deserialize(json.getAsString());
150-
} catch (ParseException e) {
151+
return DateOnly.parse(json.getAsString());
152+
} catch (final ParseException e) {
151153
logger.logError("Parsing issue on " + json.getAsString(), e);
152154
return null;
153155
}

0 commit comments

Comments
 (0)