Skip to content

Commit

Permalink
More changes to default content type
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Kruger <[email protected]>
  • Loading branch information
phillip-kruger committed Oct 18, 2023
1 parent 4c92823 commit 5a2bbae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.OptionalInt;
import java.util.OptionalLong;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;

import org.jboss.jandex.DotName;
Expand All @@ -27,6 +28,7 @@ public class JDKConstants {
public static final DotName DOTNAME_OPTIONAL_INT = DotName.createSimple(OptionalInt.class.getName());
public static final DotName DOTNAME_OPTIONAL_LONG = DotName.createSimple(OptionalLong.class.getName());
public static final DotName COMPLETION_STAGE_NAME = DotName.createSimple(CompletionStage.class.getName());
public static final DotName COMPLETABLE_STAGE_NAME = DotName.createSimple(CompletableFuture.class.getName());

public static final Set<DotName> DOTNAME_OPTIONALS = Collections
.unmodifiableSet(new HashSet<>(Arrays.asList(DOTNAME_OPTIONAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,19 @@ public String[] getDefaultProduces(AnnotationScannerContext context, MethodInfo
}

private boolean isPrimimive(Type type) {
return type.kind().equals(Type.Kind.PRIMITIVE)
|| type.name().equals(DotName.createSimple(String.class))
|| (TypeUtil.isWrappedType(type) && isPrimimive(TypeUtil.unwrapType(type)));
if (type != null) {
return type.kind().equals(Type.Kind.PRIMITIVE)
|| type.name().equals(DotName.createSimple(String.class))
|| type.name().equals(DotName.createSimple(Integer.class))
|| type.name().equals(DotName.createSimple(Short.class))
|| type.name().equals(DotName.createSimple(Long.class))
|| type.name().equals(DotName.createSimple(Float.class))
|| type.name().equals(DotName.createSimple(Double.class))
|| type.name().equals(DotName.createSimple(Boolean.class))
|| type.name().equals(DotName.createSimple(Character.class))
|| (isWrapperType(type) && isPrimimive(unwrapType(type)))
|| (TypeUtil.isWrappedType(type) && isPrimimive(TypeUtil.unwrapType(type)));
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ public class TypeUtil {

wrapperTypes.addAll(JaxbConstants.JAXB_ELEMENT);
wrapperTypes.add(MutinyConstants.UNI_TYPE.name());
wrapperTypes.add(JDKConstants.COMPLETION_STAGE_NAME);
wrapperTypes.add(JDKConstants.COMPLETABLE_STAGE_NAME);
}

private static void indexOptional(Indexer indexer, String className, ClassLoader contextLoader) {
Expand Down

0 comments on commit 5a2bbae

Please sign in to comment.