Fixing some of the issues necessitated the use of generic/raw types.
Removed version from assertj in pom.
Removed trailing spaces.
Change-Id: I76e0a05ca06c103ccc876675be04a4ab5e4de5ea
Issue-ID: POLICY-1428
Signed-off-by: Jim Hahn <jrh3@att.com>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
- <version>3.11.1</version>
<scope>test</scope>
</dependency>
<dependency>
@Override
public void writeTo(Object object, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
- throws IOException, WebApplicationException {
+ throws IOException {
try (OutputStreamWriter writer = new OutputStreamWriter(entityStream, StandardCharsets.UTF_8)) {
Type jsonType = (type.equals(genericType) ? type : genericType);
String subtype = mediaType.getSubtype();
- return "json".equalsIgnoreCase(subtype) || subtype.endsWith("+json") || "javascript".equals(subtype)
- || "x-javascript".equals(subtype) || "x-json".equals(subtype);
+ if ("json".equalsIgnoreCase(subtype) || "javascript".equals(subtype)) {
+ return true;
+ }
+
+ return subtype.endsWith("+json") || "x-json".equals(subtype) || "x-javascript".equals(subtype);
}
@Override
}
ConvInfo wtr = writer;
- TypeAdapter<Object> conv =
- (TypeAdapter<Object>) (wtr.clazz == clazz ? wtr.getConverter() : gson.getAdapter(clazz));
+
+ @SuppressWarnings("rawtypes")
+ TypeAdapter conv = (wtr.clazz == clazz ? wtr.getConverter() : gson.getAdapter(clazz));
return conv.toJsonTree(object);
}
/**
* Type on which the converter works.
*/
- private TypeToken<?> type;
+ @SuppressWarnings("rawtypes")
+ private TypeToken type;
/**
* Class of object on which the converter works.
*/
- private Class<?> clazz;
+ @SuppressWarnings("rawtypes")
+ private Class clazz;
/**
* Converter to use, initialized lazily.
*/
- private volatile TypeAdapter<?> conv = null;
+ @SuppressWarnings("rawtypes")
+ private volatile TypeAdapter conv = null;
/**
* Constructs the object.
*
* @param type type of object to be converted
*/
- public ConvInfo(TypeToken<?> type) {
+ public ConvInfo(@SuppressWarnings("rawtypes") TypeToken type) {
this.type = type;
this.clazz = type.getRawType();
}
- public final TypeAdapter<?> getConverter() {
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public final TypeAdapter getConverter() {
if (conv == null) {
// race condition here, but it's ok to overwrite a previous value
this.conv = gson.getAdapter(type);
* @return the property names having a non-null value
*/
private List<String> getNonNull(Map<String, Object> props) {
- List<String> lst = new ArrayList<String>(props.size());
+ List<String> lst = new ArrayList<>(props.size());
for (Entry<String, Object> ent : props.entrySet()) {
if (ent.getValue() != null) {
*/
@SuppressWarnings("unchecked")
private <T> List<T> getProps(Class<T> clazz, Collection<Object> values) {
- List<T> lst = new ArrayList<T>(values.size());
+ List<T> lst = new ArrayList<>(values.size());
for (Object val : values) {
if (val != null && val.getClass() == clazz) {
/**
* Super class of all de-serializers.
*/
+@FunctionalInterface
public interface Deserializer {
- String INVOKE_ERR = "cannot invoke method to deserialize: ";
-
/**
* Gets an value from a tree, converts it, and puts it into a target object.
*
/**
* Super class of all serializers.
*/
+@FunctionalInterface
public interface Serializer {
/**