Skip to content

Commit

Permalink
Bravely allow any class type to be registered for search by simpleName
Browse files Browse the repository at this point in the history
  • Loading branch information
hugithordarson committed Mar 17, 2024
1 parent a585ca5 commit cb3e024
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ng.appserver.NGElement;
import ng.appserver.elements.NGActionURL;
import ng.appserver.elements.NGBrowser;
import ng.appserver.elements.NGComponentContent;
Expand Down Expand Up @@ -49,7 +48,7 @@ public class NGElementUtils {
/**
* Classes registered to be searchable by classWithName()
*/
private static final List<Class<? extends NGElement>> _classes = new ArrayList<>();
private static final List<Class<?>> _classes = new ArrayList<>();

/**
* A mapping of shortcuts to element classes. For example, mapping of <wo:str /> to <wo:NGString />
Expand Down Expand Up @@ -84,7 +83,7 @@ public class NGElementUtils {
/**
* Add a class to make searchable by it's simpleName, full class name or any of the given shortcuts (for tags)
*/
public static void addClass( final Class<? extends NGElement> clazz, final String... shortcuts ) {
public static void addClass( final Class<?> clazz, final String... shortcuts ) {
_classes.add( clazz );

for( String shortcut : shortcuts ) {
Expand All @@ -99,12 +98,12 @@ public static void addPackage( final String packageName ) {
/**
* @return A class matching classNameToSearch for. Searches by fully qualified class name and simpleName.
*/
private static Class classWithName( String classNameToSearchFor ) {
private static Class<?> classWithName( String classNameToSearchFor ) {
Objects.requireNonNull( classNameToSearchFor );

logger.debug( "Searching for class '{}'", classNameToSearchFor );

for( Class c : _classes ) {
for( Class<?> c : _classes ) {
if( c.getName().equals( classNameToSearchFor ) || c.getSimpleName().equals( classNameToSearchFor ) ) {
return c;
}
Expand Down

0 comments on commit cb3e024

Please sign in to comment.