public class ModelHelper
extends java.lang.Object
CurrencyAmountDTOs| Constructor and Description |
|---|
ModelHelper() |
| Modifier and Type | Method and Description |
|---|---|
static AccountOwnerLocator |
accountOwnerLocator(java.lang.String principal)
Creates a new
AccountOwnerLocator. |
static AmountSummaryVO |
amountSummary(java.math.BigDecimal sum,
java.math.BigDecimal average,
int count,
CurrencyVO currency)
Creates an amount summary
|
static void |
clearIds(java.lang.Iterable<? extends EntityModel> models)
Sets the ids of all models to null
|
static <S extends Bean,T extends Bean> |
copyProperties(S source,
T target)
It copies from source to target (apply a bean over another bean) traversing all source's properties.
If a property is not found in the target bean or has a different type then it's ignored. |
static CurrencyAmountDTO |
currencyAmount(CurrencyVO currency,
java.math.BigDecimal amount)
Creates a new
CurrencyAmountDTO. |
static CurrencyAmountRangeDTO |
currencyRange(CurrencyVO currency,
java.math.BigDecimal min,
java.math.BigDecimal max)
Creates a new
CurrencyAmountRangeDTO. |
static DatePeriodDTO |
datePeriod(DateTime begin,
DateTime end)
Creates a new
DatePeriodDTO |
static DecimalRangeDTO |
decimalRange(java.math.BigDecimal min,
java.math.BigDecimal max)
Creates a new
DecimalRangeDTO |
static DictionaryVO |
dictionary(java.lang.String dictionary,
java.lang.String label)
Creates a new
DictionaryVO. |
static DimensionsDTO |
dimensions(int width,
int height)
Creates a new
DimensionsDTO |
static boolean |
equals(LatLongDTO first,
LatLongDTO second)
Check if both coordinates are the same
|
static java.lang.String |
escapeIdentifierIfNeeded(java.lang.String value)
When the given value is a valid Long, return it escaped with a trailing '.
|
static java.lang.String |
getActualInternalNameOrId(EntityVO vo)
Returns the internal name of the given VO if it is valid (no nested paths contains a null part).
|
static java.util.Set<java.lang.String> |
getAllowedMimeTypes(java.util.Collection<FileMimeType> allowedMimeTypes,
java.util.Collection<java.lang.String> otherMimeTypes)
Expand the list of allowed mime types into the actual mime types as string
|
static java.lang.String |
getEmailValidationMesssage(UserValidationResult result,
MessageProducer mProducer) |
static java.util.List<java.lang.String> |
getFriendlyMimeTypes(java.util.Collection<FileMimeType> mimes,
java.util.Collection<java.lang.String> otherTypes,
MessageProducer messageProducer)
Returns a list of user-friendly displayed mime types
|
static java.util.List<java.lang.String> |
getFriendlyMimeTypes(java.util.Collection<java.lang.String> mimeTypes,
MessageProducer messageProducer)
Returns a list of user-friendly displayed mime types
|
static <T extends Bean> |
getHierarchyPath(T bean,
Property<T,T> parentProperty)
Returns a list with the path from the hierarchy root up to the given object, having the given parent property to
resolve an object's parent.
|
static <T extends Bean> |
getLevel(T bean,
Property<T,T> parentProperty)
Returns the level of a given hierarchical bean.
|
static java.lang.String |
getPublicRegistrationMesssage(UserRegistrationResult result,
MessageProducer mProducer) |
static java.util.Comparator<UserLocatorVO> |
getUserLocatorComparator() |
static IntegerRangeDTO |
integerRange(java.lang.Integer min,
java.lang.Integer max)
Creates a new
IntegerRangeDTO |
static java.lang.String |
internalNameOrId(IEntity entity)
For a given entity model, returns the internal name, if available, otherwise the id
|
static <T extends Bean> |
isEmpty(T bean,
Property<?,? super T>... properties) |
static boolean |
isValid(DistanceDTO distance)
Returns whether the given latitude / longitude is valid
|
static boolean |
isValid(LatLongDTO latLong)
Returns whether the given latitude / longitude is valid
|
static boolean |
isValid(UserLocatorVO user)
Returns whether the given user locator is valid
|
static LatLongDTO |
latLong(java.math.BigDecimal latitude,
java.math.BigDecimal longitude)
Creates a new
LatLongDTO |
static LatLongDTO |
latLong(double latitude,
double longitude)
Creates a new
LatLongDTO |
static java.lang.String |
locatorText(java.lang.String text)
Prepares the given text to be used as locator.
|
static Property<?,? super OperatorWithFieldsVO> |
operatorWithFieldsProperty(BasicProfileField profileField)
Returns the property from
OperatorWithFieldsVO which matches the given profile field, or null if not
applicable |
static ImageNature |
resolveImageNature(ImageVO image)
Returns the image nature for the given
ImageVO |
static java.lang.String |
stringFromVO(EntityVO vo)
Returns the locator string from the given
EntityVO. |
static java.lang.String |
stringOrIdFromVO(EntityVO vo)
Same as
stringFromVO(EntityVO), however, if no string can be resolved, returns the id |
static TimeIntervalDTO |
timeInterval(int amount,
TimeField field)
Creates a new
TimeIntervalDTO |
static java.lang.String |
unqualifiedInternalNameOrId(IEntity entity)
For a given entity model, returns the internal name, if available, otherwise the id
|
static java.lang.String |
unqualifyInternalName(IInternalNamedEntity entity)
Returns the unqualified internal name of the given entity.
|
static java.lang.String |
unqualifyInternalName(java.lang.String internalName)
Returns the unqualified internal name, for example, "a.b.c" returns "c".
|
static Property<?,? super UserWithFieldsVO> |
userWithFieldsProperty(BasicProfileField profileField)
Returns the property from
UserWithFieldsVO which matches the given profile field, or null if not
applicable |
static <VO extends EntityVO> |
voFromString(java.lang.Class<VO> voClass,
java.lang.String value)
Converts a textual value to a VO.
|
static <VO extends EntityVO> |
voListFromString(java.lang.Class<VO> voClass,
java.util.Collection<java.lang.String> values)
Returns each string element as a VO in a new set.
|
static <VO extends EntityVO> |
vosFromString(java.lang.Class<VO> voClass,
java.util.Collection<java.lang.String> values)
Returns each string element as a VO in a new set.
|
public static AccountOwnerLocator accountOwnerLocator(java.lang.String principal)
AccountOwnerLocator.public static AmountSummaryVO amountSummary(java.math.BigDecimal sum, java.math.BigDecimal average, int count, CurrencyVO currency)
public static void clearIds(java.lang.Iterable<? extends EntityModel> models)
public static <S extends Bean,T extends Bean> void copyProperties(S source, T target)
java.lang.IllegalArgumentException - if source, target or both are null.public static CurrencyAmountDTO currencyAmount(CurrencyVO currency, java.math.BigDecimal amount)
CurrencyAmountDTO.public static CurrencyAmountRangeDTO currencyRange(CurrencyVO currency, java.math.BigDecimal min, java.math.BigDecimal max)
CurrencyAmountRangeDTO.public static DatePeriodDTO datePeriod(DateTime begin, DateTime end)
DatePeriodDTOpublic static DecimalRangeDTO decimalRange(java.math.BigDecimal min, java.math.BigDecimal max)
DecimalRangeDTOpublic static DictionaryVO dictionary(java.lang.String dictionary, java.lang.String label)
DictionaryVO.public static DimensionsDTO dimensions(int width, int height)
DimensionsDTOpublic static boolean equals(LatLongDTO first, LatLongDTO second)
public static java.lang.String escapeIdentifierIfNeeded(java.lang.String value)
public static java.lang.String getActualInternalNameOrId(EntityVO vo)
public static java.util.Set<java.lang.String> getAllowedMimeTypes(java.util.Collection<FileMimeType> allowedMimeTypes, java.util.Collection<java.lang.String> otherMimeTypes)
public static java.lang.String getEmailValidationMesssage(UserValidationResult result, MessageProducer mProducer)
public static java.util.List<java.lang.String> getFriendlyMimeTypes(java.util.Collection<FileMimeType> mimes, java.util.Collection<java.lang.String> otherTypes, MessageProducer messageProducer)
public static java.util.List<java.lang.String> getFriendlyMimeTypes(java.util.Collection<java.lang.String> mimeTypes,
MessageProducer messageProducer)
public static <T extends Bean> java.util.List<T> getHierarchyPath(T bean, Property<T,T> parentProperty)
public static <T extends Bean> int getLevel(T bean, Property<T,T> parentProperty)
public static java.lang.String getPublicRegistrationMesssage(UserRegistrationResult result, MessageProducer mProducer)
public static java.util.Comparator<UserLocatorVO> getUserLocatorComparator()
public static IntegerRangeDTO integerRange(java.lang.Integer min, java.lang.Integer max)
IntegerRangeDTOpublic static java.lang.String internalNameOrId(IEntity entity)
@SafeVarargs public static <T extends Bean> boolean isEmpty(T bean, Property<?,? super T>... properties)
properties - list of Properties to be checked for empty/null#isEmpty(Object)).public static boolean isValid(DistanceDTO distance)
public static boolean isValid(LatLongDTO latLong)
public static boolean isValid(UserLocatorVO user)
public static LatLongDTO latLong(java.math.BigDecimal latitude, java.math.BigDecimal longitude)
LatLongDTOpublic static LatLongDTO latLong(double latitude, double longitude)
LatLongDTOpublic static java.lang.String locatorText(java.lang.String text)
public static Property<?,? super OperatorWithFieldsVO> operatorWithFieldsProperty(BasicProfileField profileField)
OperatorWithFieldsVO which matches the given profile field, or null if not
applicablepublic static ImageNature resolveImageNature(ImageVO image)
ImageVOpublic static java.lang.String stringFromVO(EntityVO vo)
EntityVO.
For example, for UserLocatorVO, returns the principal.
Will never return the id. If the VO has no representing string, returns null.public static java.lang.String stringOrIdFromVO(EntityVO vo)
stringFromVO(EntityVO), however, if no string can be resolved, returns the idpublic static TimeIntervalDTO timeInterval(int amount, TimeField field)
TimeIntervalDTOpublic static java.lang.String unqualifiedInternalNameOrId(IEntity entity)
public static java.lang.String unqualifyInternalName(IInternalNamedEntity entity)
unqualifyInternalName(String)public static java.lang.String unqualifyInternalName(java.lang.String internalName)
public static Property<?,? super UserWithFieldsVO> userWithFieldsProperty(BasicProfileField profileField)
UserWithFieldsVO which matches the given profile field, or null if not
applicablepublic static <VO extends EntityVO> VO voFromString(java.lang.Class<VO> voClass, java.lang.String value)
public static <VO extends EntityVO> java.util.List<VO> voListFromString(java.lang.Class<VO> voClass, java.util.Collection<java.lang.String> values)
voFromString(Class, String)public static <VO extends EntityVO> java.util.Set<VO> vosFromString(java.lang.Class<VO> voClass, java.util.Collection<java.lang.String> values)
voFromString(Class, String)