mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
change sorting to put apps after everything else, since that's often what one would want, so you don't always have to set sortOrder yourself
This commit is contained in:
@ -30,6 +30,7 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.google.common.reflect.ClassPath;
|
import com.google.common.reflect.ClassPath;
|
||||||
import com.kingsrook.qqq.backend.core.logging.QLogger;
|
import com.kingsrook.qqq.backend.core.logging.QLogger;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppMetaData;
|
||||||
import static com.kingsrook.qqq.backend.core.logging.LogUtils.logPair;
|
import static com.kingsrook.qqq.backend.core.logging.LogUtils.logPair;
|
||||||
|
|
||||||
|
|
||||||
@ -50,9 +51,9 @@ public class MetaDataProducerHelper
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public static void processAllMetaDataProducersInPackage(QInstance instance, String packageName) throws IOException
|
public static void processAllMetaDataProducersInPackage(QInstance instance, String packageName) throws IOException
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// find all the meta data producer classes in the package //
|
// find all the meta data producer classes in (and under) the package //
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
List<Class<?>> classesInPackage = getClassesInPackage(packageName);
|
List<Class<?>> classesInPackage = getClassesInPackage(packageName);
|
||||||
List<MetaDataProducer<?>> producers = new ArrayList<>();
|
List<MetaDataProducer<?>> producers = new ArrayList<>();
|
||||||
for(Class<?> aClass : classesInPackage)
|
for(Class<?> aClass : classesInPackage)
|
||||||
@ -83,10 +84,31 @@ public class MetaDataProducerHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// sort them by sort order //
|
// sort them by sort order, then by the type that they return - specifically - doing apps //
|
||||||
/////////////////////////////
|
// after all other types (as apps often try to get other types from the instance) //
|
||||||
producers.sort(Comparator.comparing(p -> p.getSortOrder()));
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
producers.sort(Comparator
|
||||||
|
.comparing((MetaDataProducer<?> p) -> p.getSortOrder())
|
||||||
|
.thenComparing((MetaDataProducer<?> p) ->
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Class<?> outputType = p.getClass().getMethod("produce", QInstance.class).getReturnType();
|
||||||
|
if(outputType.equals(QAppMetaData.class))
|
||||||
|
{
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
// execute each one, adding their meta data to the instance //
|
// execute each one, adding their meta data to the instance //
|
||||||
|
Reference in New Issue
Block a user