[xml] Reduce amount of raw type warnings around GenericDomValueConvertersRegistry

GitOrigin-RevId: a51bcb93728fba4e3b3fc051c0077c41f0e96533
This commit is contained in:
Tagir Valeev
2024-09-13 10:11:02 +02:00
committed by intellij-monorepo-bot
parent 5cc7875bbc
commit 1b516a359f

View File

@@ -19,11 +19,11 @@ import java.util.Objects;
public class GenericDomValueConvertersRegistry {
public interface Provider {
Converter getConverter();
Condition<Pair<PsiType, GenericDomValue>> getCondition();
Converter<?> getConverter();
Condition<Pair<PsiType, GenericDomValue<?>>> getCondition();
}
private final Map<Condition<Pair<PsiType, GenericDomValue>>, Converter<?>> myConditionConverters =
private final Map<Condition<Pair<PsiType, GenericDomValue<?>>>, Converter<?>> myConditionConverters =
new LinkedHashMap<>();
public void registerDefaultConverters() {
@@ -61,51 +61,51 @@ public class GenericDomValueConvertersRegistry {
}
public void registerNumberValueConverters() {
registerConverter(new NumberValueConverter(byte.class, false), PsiTypes.byteType());
registerConverter(new NumberValueConverter(Byte.class, true), Byte.class);
registerConverter(new NumberValueConverter<>(byte.class, false), PsiTypes.byteType());
registerConverter(new NumberValueConverter<>(Byte.class, true), Byte.class);
registerConverter(new NumberValueConverter(short.class, false), PsiTypes.shortType());
registerConverter(new NumberValueConverter(Short.class, true), Short.class);
registerConverter(new NumberValueConverter<>(short.class, false), PsiTypes.shortType());
registerConverter(new NumberValueConverter<>(Short.class, true), Short.class);
registerConverter(new NumberValueConverter(int.class, false), PsiTypes.intType());
registerConverter(new NumberValueConverter(Integer.class, true), Integer.class);
registerConverter(new NumberValueConverter<>(int.class, false), PsiTypes.intType());
registerConverter(new NumberValueConverter<>(Integer.class, true), Integer.class);
registerConverter(new NumberValueConverter(long.class, false), PsiTypes.longType());
registerConverter(new NumberValueConverter(Long.class, true), Long.class);
registerConverter(new NumberValueConverter<>(long.class, false), PsiTypes.longType());
registerConverter(new NumberValueConverter<>(Long.class, true), Long.class);
registerConverter(new NumberValueConverter(float.class, false), PsiTypes.floatType());
registerConverter(new NumberValueConverter(Float.class, true), Float.class);
registerConverter(new NumberValueConverter<>(float.class, false), PsiTypes.floatType());
registerConverter(new NumberValueConverter<>(Float.class, true), Float.class);
registerConverter(new NumberValueConverter(double.class, false), PsiTypes.doubleType());
registerConverter(new NumberValueConverter(Double.class, true), Double.class);
registerConverter(new NumberValueConverter<>(double.class, false), PsiTypes.doubleType());
registerConverter(new NumberValueConverter<>(Double.class, true), Double.class);
registerConverter(new NumberValueConverter(BigDecimal.class, true), BigDecimal.class);
registerConverter(new NumberValueConverter(BigInteger.class, true), BigInteger.class);
registerConverter(new NumberValueConverter<>(BigDecimal.class, true), BigDecimal.class);
registerConverter(new NumberValueConverter<>(BigInteger.class, true), BigInteger.class);
}
public void registerConverter(@NotNull Converter<?> provider, @NotNull final PsiType type) {
registerConverter(provider, pair -> Comparing.equal(pair.getFirst(), type));
}
public void registerConverter(@NotNull Converter<?> provider, @NotNull Condition<Pair<PsiType, GenericDomValue>> condition) {
public void registerConverter(@NotNull Converter<?> provider, @NotNull Condition<Pair<PsiType, GenericDomValue<?>>> condition) {
myConditionConverters.put(condition, provider);
}
@Nullable
public final Converter<?> getConverter(@NotNull GenericDomValue domValue, @Nullable PsiType type) {
final Pair<PsiType, GenericDomValue> pair = Pair.create(type, domValue);
public final Converter<?> getConverter(@NotNull GenericDomValue<?> domValue, @Nullable PsiType type) {
final Pair<PsiType, GenericDomValue<?>> pair = Pair.create(type, domValue);
final Converter<?> converter = getRegisteredConverter(pair);
return converter != null? converter : getCustomConverter(pair);
}
@Nullable
protected Converter<?> getCustomConverter(Pair<PsiType, GenericDomValue> pair) {
protected Converter<?> getCustomConverter(Pair<PsiType, GenericDomValue<?>> pair) {
return null;
}
@Nullable
protected Converter<?> getRegisteredConverter(Pair<PsiType, GenericDomValue> pair) {
for (@NotNull Condition<Pair<PsiType, GenericDomValue>> condition : myConditionConverters.keySet()) {
protected Converter<?> getRegisteredConverter(Pair<PsiType, GenericDomValue<?>> pair) {
for (@NotNull Condition<Pair<PsiType, GenericDomValue<?>>> condition : myConditionConverters.keySet()) {
if (condition.value(pair)) {
return myConditionConverters.get(condition);
}
@@ -113,7 +113,7 @@ public class GenericDomValueConvertersRegistry {
return null;
}
public void registerConverter(@NotNull Converter<?> provider, @NotNull Class type) {
public void registerConverter(@NotNull Converter<?> provider, @NotNull Class<?> type) {
final String name = type.getCanonicalName();
registerConverter(provider, pair -> pair.first != null && Objects.equals(name, pair.first.getCanonicalText()));
}