mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-13 02:32:09 +10:00
The AI component catalog no longer offers the deprecated inner layers, and lists the new 'Board Side' property
This commit is contained in:
+4
-1
@@ -54,6 +54,7 @@ import org.diylc.presenter.ComparatorFactory;
|
||||
import org.diylc.presenter.ComponentProcessor;
|
||||
import org.diylc.presenter.DatasheetService;
|
||||
import org.diylc.presenter.ReleaseHistory;
|
||||
import org.diylc.utils.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Standalone tool that generates component catalog JSON files from the current codebase.
|
||||
@@ -227,9 +228,11 @@ public class ComponentCatalogGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
// Include enum possible values (using name() instead of toString())
|
||||
// Include enum possible values (using name() instead of toString()), leaving out the
|
||||
// deprecated ones the editor does not offer either
|
||||
if (propType.isEnum()) {
|
||||
List<String> possibleValues = Arrays.stream(propType.getEnumConstants())
|
||||
.filter(e -> !ReflectionUtils.isDeprecated((Enum<?>) e))
|
||||
.map(e -> ((Enum<?>) e).name())
|
||||
.collect(Collectors.toList());
|
||||
prop.put("possibleValues", possibleValues);
|
||||
|
||||
@@ -148,4 +148,16 @@ public class ReflectionUtils {
|
||||
}
|
||||
return result.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when the enum constant is marked {@link Deprecated}; such values are kept only so
|
||||
* that old files load, and are not offered for new choices
|
||||
*/
|
||||
public static boolean isDeprecated(Enum<?> value) {
|
||||
try {
|
||||
return value.getDeclaringClass().getField(value.name()).isAnnotationPresent(Deprecated.class);
|
||||
} catch (NoSuchFieldException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user