Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wilds committed Oct 2, 2020
1 parent 311da05 commit 9806626
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 12 deletions.
8 changes: 6 additions & 2 deletions src/main/java/com/poiji/bind/mapping/HSSFPropertyFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public <T> T returnFromExcelFile(Class<T> type) {
try (OPCPackage open = OPCPackage.open(file, PackageAccess.READ)) {
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(open);
PropertyHandler propertyHandler = new PropertyHandler();
return propertyHandler.unmarshal(type, xssfWorkbook.getProperties());
T ret = propertyHandler.unmarshal(type, xssfWorkbook.getProperties());
xssfWorkbook.close();
return ret;
} catch (IOException | OpenXML4JException e) {
throw new PoijiException("Problem occurred while reading data", e);
}
Expand All @@ -54,7 +56,9 @@ public <T> T returnFromEncryptedFile(Class<T> type) {
try (OPCPackage open = OPCPackage.open(stream)) {
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(open);
PropertyHandler propertyHandler = new PropertyHandler();
return propertyHandler.unmarshal(type, xssfWorkbook.getProperties());
T ret = propertyHandler.unmarshal(type, xssfWorkbook.getProperties());
xssfWorkbook.close();
return ret;
} catch (IOException | OpenXML4JException e) {
IOUtils.closeQuietly(fs);
throw new PoijiException("Problem occurred while reading data", e);
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/poiji/bind/mapping/HSSFPropertyStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public <T> T returnFromExcelFile(Class<T> type) {
try (OPCPackage open = OPCPackage.open(inputStream)) {
PropertyHandler propertyHandler = new PropertyHandler();
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(open);
return propertyHandler.unmarshal(type, xssfWorkbook.getProperties());
T ret = propertyHandler.unmarshal(type, xssfWorkbook.getProperties());
xssfWorkbook.close();
return ret;
} catch (IOException | OpenXML4JException e) {
throw new PoijiException("Problem occurred while reading data", e);
}
Expand All @@ -52,7 +54,9 @@ public <T> T returnFromEncryptedFile(Class<T> type) {
try (OPCPackage open = OPCPackage.open(stream)) {
PropertyHandler propertyHandler = new PropertyHandler();
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(open);
return propertyHandler.unmarshal(type, xssfWorkbook.getProperties());
T ret = propertyHandler.unmarshal(type, xssfWorkbook.getProperties());
xssfWorkbook.close();
return ret;
} catch (IOException | OpenXML4JException e) {
IOUtils.closeQuietly(fs);
throw new PoijiException("Problem occurred while reading data", e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.poiji.bind.mapping;

import com.poiji.bind.PoijiFile;
import com.poiji.bind.Unmarshaller;
import com.poiji.exception.PoijiException;
import com.poiji.option.PoijiOptions;
import org.apache.poi.ss.usermodel.Workbook;
Expand All @@ -13,7 +12,7 @@
*
* Created by hakan on 16/01/2017.
*/
final class HSSFUnmarshallerFile extends HSSFUnmarshaller implements Unmarshaller {
final class HSSFUnmarshallerFile extends HSSFUnmarshaller {

private final PoijiFile<?> poijiFile;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.poiji.bind.mapping;

import com.poiji.bind.PoijiInputStream;
import com.poiji.bind.Unmarshaller;
import com.poiji.exception.PoijiException;
import com.poiji.option.PoijiOptions;
import org.apache.poi.ss.usermodel.Workbook;
Expand All @@ -12,7 +11,7 @@
/**
* Created by hakan on 08/03/2018.
*/
final class HSSFUnmarshallerStream extends HSSFUnmarshaller implements Unmarshaller {
final class HSSFUnmarshallerStream extends HSSFUnmarshaller {

private final PoijiInputStream<?> poijiInputStream;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/poiji/bind/mapping/PoijiHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private Object getInstance(Field field) {
return ins;
}

@SuppressWarnings("unchecked")
private boolean setValue(String content, Class<? super T> type, int column) {
Stream.of(type.getDeclaredFields())
.filter(field -> field.getAnnotation(ExcelUnknownCells.class) == null)
Expand Down Expand Up @@ -122,7 +123,7 @@ private boolean setValue(String content, Class<? super T> type, int column) {
excelUnknownCellsMap = new HashMap<>();
ReflectUtil.setFieldData(field, excelUnknownCellsMap, instance);
} else {
excelUnknownCellsMap = (Map) field.get(instance);
excelUnknownCellsMap = (Map<String, String>) field.get(instance);
}
excelUnknownCellsMap.put(titlePerColumnIndex.get(column), content);
} catch (IllegalAccessException e) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/poiji/config/DefaultCasting.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private LocalDateTime localDateTimeValue(String value, String sheetName, int row
}


private Object enumValue(String value, String sheetName, int row, int col, Class type) {
private Object enumValue(String value, String sheetName, int row, int col, Class<?> type) {
return Arrays.stream(type.getEnumConstants())
.filter(o -> ((Enum<?>) o).name().equals(value))
.findFirst()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Exception thrown if namedHeaderMandatory is set in the options, but a header specified in an @ExcelCellName
* is missing in the sheet.
*/
@SuppressWarnings("serial")
public class HeaderMissingException extends PoijiException {
public HeaderMissingException(String message) {
super(message);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/poiji/parser/BooleanParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Boolean parse(String value) {

throw new BooleanParseException(value);
}

@SuppressWarnings("serial")
public static class BooleanParseException extends RuntimeException {
public BooleanParseException(String value) {
super("Can't parse value to Boolean: " + value);
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/poiji/deserialize/IllegalAcessTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.File;
import java.util.List;

@SuppressWarnings("unused")
public class IllegalAcessTest {

@Test(expected = IllegalCastException.class)
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/poiji/deserialize/PoijiOptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* Created by hakan on 19.07.2020
*/
@SuppressWarnings("unused")
public class PoijiOptionsTest {

@Test(expected = PoijiException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class DecimalSeparatorParseTest {

private static class Row {

@SuppressWarnings("unused")
@ExcelCellName("decimalNumber")
private double decimalNumber;

Expand Down

0 comments on commit 9806626

Please sign in to comment.