Add withValues(Pair...) and iconAndColorValues

This commit is contained in:
2022-11-11 16:20:50 -06:00
parent 8b31cee890
commit a2da8c4127
2 changed files with 31 additions and 0 deletions

View File

@ -23,6 +23,7 @@ package com.kingsrook.qqq.backend.core.model.metadata.fields;
import java.io.Serializable; import java.io.Serializable;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.PossibleValueEnum;
import com.kingsrook.qqq.backend.core.utils.Pair; import com.kingsrook.qqq.backend.core.utils.Pair;
@ -81,6 +82,20 @@ public enum AdornmentType
{ {
return (new Pair<>("icon." + value, iconName)); return (new Pair<>("icon." + value, iconName));
} }
/*******************************************************************************
**
*******************************************************************************/
@SuppressWarnings("unchecked")
static Pair<String, Serializable>[] iconAndColorValues(Serializable value, String iconName, String colorName)
{
if(value instanceof PossibleValueEnum<?> possibleValueEnum)
{
value = (Serializable) possibleValueEnum.getPossibleValueId();
}
return (new Pair[] { iconValue(value, iconName), colorValue(value, colorName) });
}
} }

View File

@ -164,4 +164,20 @@ public class FieldAdornment
return (withValue(value.getA(), value.getB())); return (withValue(value.getA(), value.getB()));
} }
/*******************************************************************************
** Fluent setter for values
**
*******************************************************************************/
public FieldAdornment withValues(Pair<String, Serializable>... values)
{
for(Pair<String, Serializable> value : values)
{
withValue(value);
}
return (this);
}
} }