Skip to content

Commit

Permalink
[#7076] ForcedType enum with no matching value being converted
Browse files Browse the repository at this point in the history
to last enum value
  • Loading branch information
lukaseder committed Nov 24, 2022
1 parent de14554 commit a59e85c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions jOOQ/src/main/java/org/jooq/impl/EnumConverter.java
Expand Up @@ -72,13 +72,20 @@ public EnumConverter(Class<T> fromType, Class<U> toType, Function<? super U, ? e
this.to = to;
this.lookup = new LinkedHashMap<>();

for (U u : toType.getEnumConstants())
this.lookup.put(to(u), u);
for (U u : toType.getEnumConstants()) {
T key = to(u);

if (key != null)
this.lookup.put(key, u);
}
}

@Override
public final U from(T databaseObject) {
return lookup.get(databaseObject);
if (databaseObject == null)
return null;
else
return lookup.get(databaseObject);
}

/**
Expand Down

0 comments on commit a59e85c

Please sign in to comment.