Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace the use of Gson's internal newParametrizedTypeWithOwner #312

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/main/java/com/suse/salt/netapi/utils/ClientUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import java.lang.reflect.Type;
import java.util.Scanner;

import static com.google.gson.internal.$Gson$Types.newParameterizedTypeWithOwner;

import com.suse.salt.netapi.client.SaltClient;

/**
Expand Down Expand Up @@ -61,11 +59,9 @@ public static String streamToString(InputStream inputStream) {
* @param rawType the raw type
* @param typeArguments the type arguments
* @return the parameterized type object
* @see com.google.gson.internal.$Gson$Types#newParameterizedTypeWithOwner
*/
public static ParameterizedType parameterizedType(Type ownerType, Type rawType,
Type... typeArguments) {
return newParameterizedTypeWithOwner(ownerType, rawType, typeArguments);
public static ParameterizedType parameterizedType(Type ownerType, Type rawType, Type... typeArguments) {
return new ParameterizedTypeImpl(ownerType, rawType, typeArguments);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.suse.salt.netapi.utils;

import java.lang.reflect.Type;

/** Implementation of Java's ParametrizedType for internal use */
public class ParameterizedTypeImpl implements java.lang.reflect.ParameterizedType {

private final Type owner;
private final Type raw;
private final Type[] argumentsTypes;

/**
* Construct a parametrized type
*
* @param ownerIn the ownerIn type
* @param rawTypeIn the raw type
* @param argumentsTypesIn the arguments actual types
*/
public ParameterizedTypeImpl(Type ownerIn, Type rawTypeIn, Type[] argumentsTypesIn) {
owner = ownerIn;
raw = rawTypeIn;
argumentsTypes = argumentsTypesIn;
}

/**
* Construct a parametrized type for a single argument
*
* @param ownerIn the ownerIn type
* @param rawTypeIn the raw type
* @param argumentTypeIn the argument actual types
*/
public ParameterizedTypeImpl(Type ownerIn, Type rawTypeIn, Type argumentTypeIn) {
this(ownerIn, rawTypeIn, new Type[]{argumentTypeIn});
}

@Override
public Type[] getActualTypeArguments() {
return argumentsTypes;
}

@Override
public Type getRawType() {
return raw;
}

@Override
public Type getOwnerType() {
return owner;
}
}
Loading