Package nl.vpro.domain
Class TextualObjects
java.lang.Object
nl.vpro.domain.TextualObjects
Utilities related to
TextualObject
s- Since:
- 5.1
- Author:
- Michiel Meeuwissen
-
Method Summary
Modifier and TypeMethodDescriptionstatic <OT extends TypedText>
booleanaddOrUpdate
(Collection<OT> titles, OT add) Give a collection, find the first object which equals the object we want to be in it.static <T1 extends OwnedText,
D1 extends OwnedText, TO1 extends TextualObject<T1, D1, TO1>, T2 extends OwnedText, D2 extends OwnedText, TO2 extends TextualObject<T2, D2, TO2>>
voidcopy
(TO1 from, TO2 to) Copies all titles and descriptions from oneTextualObject
to another.static <T1 extends TypedText,
D1 extends TypedText, TO1 extends TextualObjectUpdate<T1, D1, TO1>, T2 extends OwnedText, D2 extends OwnedText, TO2 extends TextualObject<T2, D2, TO2>>
voidcopy
(TO1 from, TO2 to, nl.vpro.domain.media.support.OwnerType owner) Copies all titles and descriptions from oneTextualObjectUpdate
to aTextualObject
.static <T1 extends TypedText,
D1 extends TypedText, TO1 extends TextualObjectUpdate<T1, D1, TO1>, T2 extends OwnedText, D2 extends OwnedText, TO2 extends TextualObject<T2, D2, TO2>>
voidcopyAndRemove
(TO1 from, TO2 to, nl.vpro.domain.media.support.OwnerType owner) Copies all titles and descriptions from oneTextualObjectUpdate
to aTextualObject
.static <T1 extends TypedText,
D1 extends TypedText, TO1 extends TextualObjectUpdate<T1, D1, TO1>, T2 extends TypedText, D2 extends TypedText, TO2 extends TextualObjectUpdate<T2, D2, TO2>>
voidcopyToUpdate
(@NonNull TO1 from, @NonNull TO2 to) Copy all texts from one collection ofTextualObjectUpdate
to another.static <OT1 extends OwnedText,
OD1 extends OwnedText, TO1 extends TextualObject<OT1, OD1, TO1>, T2 extends TypedText, D2 extends TypedText, TO2 extends TextualObjectUpdate<T2, D2, TO2>>
voidcopyToUpdate
(@NonNull TO1 from, @NonNull TO2 to, @NonNull nl.vpro.domain.media.support.OwnerType owner) Copy all texts from aTextualObject
to aTextualObjectUpdate
.expand
(@NonNull Collection<OT> titles, @NonNull TextualType textualType, @NonNull nl.vpro.domain.media.support.OwnerType ownerType) Returns the value for a certainTextualType
andOwnerType
.expand
(Collection<OT> titles, TextualType textualType) expand
(Collection<OT> texts, org.meeuw.functional.TriFunction<String, nl.vpro.domain.media.support.OwnerType, TextualType, OT> creator, List<TextualType> types, List<nl.vpro.domain.media.support.OwnerType> owners) expandDescriptions
(Collection<OT> texts, org.meeuw.functional.TriFunction<String, nl.vpro.domain.media.support.OwnerType, TextualType, OT> creator) expandDescriptions
(TextualObject<?, D, ?> textualObject) expandTitles
(Collection<OT> texts, org.meeuw.functional.TriFunction<String, nl.vpro.domain.media.support.OwnerType, TextualType, OT> creator) Creates a new sorted set of titles where: All Textual Types fromTextualType.TITLES
are filled according to the business logic of POMs.expandTitles
(TextualObject<T, ?, ?> textualObject) static <T extends OwnedText>
Map<nl.vpro.domain.media.support.OwnerType,SortedSet<BasicTypedText>> expandTitlesAsMap
(TextualObject<T, ?, ?> textualObject) expandTitlesMajorOwnerTypes
(TextualObject<T, ?, ?> textualObject) static <T extends nl.vpro.domain.media.support.MutableOwnable>
List<T>filter
(Collection<T> ownables, nl.vpro.domain.media.support.OwnerType owner) static <T extends OwnedText,
D extends OwnedText, TO extends TextualObject<T, D, TO>>
nl.vpro.domain.media.support.OwnerType[]findOwnersForTextFields
(TO media) static <T extends OwnedText,
D extends OwnedText, TO extends TextualObject<T, D, TO>>
voidforOwner
(@NonNull TO media, @NonNull nl.vpro.domain.media.support.OwnerType owner) Sets the owner of all titles, descriptions, locations and images found in given MediaObjectprotected static <T extends TypedText>
voidforUpdate
(Collection<T> collection, Consumer<T> consumer, Runnable ifNull) protected static <T extends OwnedText>
voidforUpdate
(Collection<T> collection, Consumer<T> consumer, Runnable ifNull, nl.vpro.domain.media.support.OwnerType owner) get
(Collection<? extends OT> titles, String defaultValue, TextualType... types) get
(Collection<OT> titles, Comparator<nl.vpro.domain.media.support.OwnerType> ownerType, TextualType... type) get
(Collection<OT> titles, TextualType... work) protected static <OT extends OwnedText>
Comparator<OT>getComparator
(Comparator<nl.vpro.domain.media.support.OwnerType> ownerTypeComparator) static <T extends OwnedText,
D extends OwnedText, TO extends TextualObject<T, D, TO>>
StringgetDescription
(@NonNull TO media, @NonNull nl.vpro.domain.media.support.OwnerType owner, @NonNull TextualType type) static <T extends OwnedText,
D extends OwnedText, TO extends TextualObject<T, D, TO>>
StringgetDescription
(@NonNull TO media, @NonNull TextualType... types) static <OT extends TypedText>
OTgetObject
(Collection<OT> titles, TextualType... types) static Collection<? extends OwnedText>
getObjects
(Collection<? extends OwnedText> titles, TextualType... types) static <OT extends OwnedText>
Collection<? extends OwnedText>getObjects
(Collection<? extends OT> titles, Comparator<nl.vpro.domain.media.support.OwnerType> ownerTypeComparator, TextualType... types) getOptional
(Collection<OT> titles, nl.vpro.domain.media.support.OwnerType owner, TextualType type) getOptional
(Collection<OT> titles, TextualType... types) Finds the first text in a collection ofTypedText
s with one of the given types.static <T extends OwnedText,
D extends OwnedText, TO extends TextualObject<T, D, TO>>
StringgetTitle
(@NonNull TO media, @NonNull nl.vpro.domain.media.support.OwnerType owner, @NonNull TextualType type) static <T extends OwnedText,
D extends OwnedText, TO extends TextualObject<T, D, TO>>
voidremoveEmptyValues
(@NonNull TO textualObject) retainAll
(Collection<TO2> collection, Collection<TO> toRetain) retainAll
(Collection<TO2> collection, Collection<TO> toRetain, nl.vpro.domain.media.support.OwnerType owner) static <S extends Comparable<?>>
SortedSet<@NonNull S>static <T1 extends AbstractOwnedText<T1>,
D extends AbstractOwnedText<D>, TO1 extends TextualObject<T1, D, TO1>, T2 extends AbstractOwnedText<T2>, TO2 extends TextualObject<T2, D, TO2>>
voidupdateDescriptionsForOwner
(TO1 incomingMedia, TO2 mediaToUpdate, nl.vpro.domain.media.support.OwnerType owner, nl.vpro.domain.media.support.OwnerType... similarOwnerTypes) Copies all descriptions from one object to another.static <T extends AbstractOwnedText<T>,
D1 extends AbstractOwnedText<D1>, TO1 extends TextualObject<T, D1, TO1>, D2 extends AbstractOwnedText<D2>, TO2 extends TextualObject<T, D2, TO2>>
voidupdateTitlesForOwner
(TO1 incomingMedia, TO2 mediaToUpdate, nl.vpro.domain.media.support.OwnerType owner, nl.vpro.domain.media.support.OwnerType... similarOwnerTypes) Copies all titles from one object to another.
-
Method Details
-
getOptional
public static <OT extends TypedText> Optional<String> getOptional(Collection<OT> titles, TextualType... types) Finds the first text in a collection ofTypedText
s with one of the given types. Wrapped in an optional, so never returnsnull
-
get
public static <OT extends TypedText> String get(Collection<? extends OT> titles, String defaultValue, TextualType... types) -
expand
public static <OT extends OwnedText> SortedSet<OT> expand(Collection<OT> texts, org.meeuw.functional.TriFunction<String, nl.vpro.domain.media.support.OwnerType, TextualType, OT> creator, List<TextualType> types, List<nl.vpro.domain.media.support.OwnerType> owners) -
expandTitles
public static <OT extends OwnedText> SortedSet<OT> expandTitles(Collection<OT> texts, org.meeuw.functional.TriFunction<String, nl.vpro.domain.media.support.OwnerType, TextualType, OT> creator) Creates a new sorted set of titles where:- All Textual Types from
TextualType.TITLES
are filled according to the business logic of POMs. This means mainly that the value for LEXICO is filled with MAIN if empty otherwise - For all those fields it is assured that values with owner types
OwnerType.ENTRIES
are added if they are not present yet, according to the business logic of POMS. This means that if there is title of a certain type, than at least it is present for owners BROADCASTER and NPO too.
- All Textual Types from
-
expandTitles
-
expandTitlesMajorOwnerTypes
public static <T extends OwnedText> SortedSet<T> expandTitlesMajorOwnerTypes(TextualObject<T, ?, ?> textualObject) -
expandTitlesAsMap
public static <T extends OwnedText> Map<nl.vpro.domain.media.support.OwnerType,SortedSet<BasicTypedText>> expandTitlesAsMap(TextualObject<T, ?, ?> textualObject) -
expandDescriptions
public static <OT extends OwnedText> SortedSet<OT> expandDescriptions(Collection<OT> texts, org.meeuw.functional.TriFunction<String, nl.vpro.domain.media.support.OwnerType, TextualType, OT> creator) -
expandDescriptions
public static <D extends OwnedText> SortedSet<D> expandDescriptions(TextualObject<?, D, ?> textualObject) -
getOptional
public static <OT extends OwnedText> Optional<String> getOptional(Collection<OT> titles, nl.vpro.domain.media.support.OwnerType owner, TextualType type) -
get
public static <OT extends OwnedText> Optional<String> get(Collection<OT> titles, Comparator<nl.vpro.domain.media.support.OwnerType> ownerType, TextualType... type) -
getObject
-
getObjects
public static Collection<? extends OwnedText> getObjects(Collection<? extends OwnedText> titles, TextualType... types) -
getComparator
protected static <OT extends OwnedText> Comparator<OT> getComparator(Comparator<nl.vpro.domain.media.support.OwnerType> ownerTypeComparator) -
getObjects
public static <OT extends OwnedText> Collection<? extends OwnedText> getObjects(Collection<? extends OT> titles, Comparator<nl.vpro.domain.media.support.OwnerType> ownerTypeComparator, TextualType... types) -
findOwnersForTextFields
public static <T extends OwnedText,D extends OwnedText, nl.vpro.domain.media.support.OwnerType[] findOwnersForTextFieldsTO extends TextualObject<T, D, TO>> (TO media) -
getTitle
public static <T extends OwnedText,D extends OwnedText, String getTitleTO extends TextualObject<T, D, TO>> (@NonNull TO media, @NonNull nl.vpro.domain.media.support.OwnerType owner, @NonNull TextualType type) -
getDescription
public static <T extends OwnedText,D extends OwnedText, String getDescriptionTO extends TextualObject<T, D, TO>> (@NonNull TO media, @NonNull nl.vpro.domain.media.support.OwnerType owner, @NonNull TextualType type) -
getDescription
public static <T extends OwnedText,D extends OwnedText, String getDescriptionTO extends TextualObject<T, D, TO>> (@NonNull TO media, @NonNull TextualType... types) -
forOwner
public static <T extends OwnedText,D extends OwnedText, void forOwnerTO extends TextualObject<T, D, TO>> (@NonNull TO media, @NonNull nl.vpro.domain.media.support.OwnerType owner) Sets the owner of all titles, descriptions, locations and images found in given MediaObject -
filter
public static <T extends nl.vpro.domain.media.support.MutableOwnable> List<T> filter(Collection<T> ownables, nl.vpro.domain.media.support.OwnerType owner) -
sorted
-
get
-
expand
public static <OT extends OwnedText> Optional<OT> expand(@NonNull Collection<OT> titles, @NonNull TextualType textualType, @NonNull nl.vpro.domain.media.support.OwnerType ownerType) Returns the value for a certainTextualType
andOwnerType
. This implements a fall back mechanism. It takes the first value with matching owner and type. If none found, it will fall back to the highest OwnerType (OwnerType.BROADCASTER
and degrades until one is found.Furthermore if no 'LEXICO' typed values if found, the value for 'MAIN' will be used.
-
expand
public static <OT extends OwnedText> Optional<OT> expand(Collection<OT> titles, TextualType textualType) -
addOrUpdate
Give a collection, find the first object which equals the object we want to be in it. If one found, the 'value' is copied to it. If not, then the object is added to the collection.TypedText's are commonly stored in SortedSet's, where equals matches only owner and type, not the value itself.
- Parameters:
titles
- Collectionadd
- the object to add or update.
-
copy
public static <T1 extends OwnedText,D1 extends OwnedText, void copyTO1 extends TextualObject<T1, D1, TO1>, T2 extends OwnedText, D2 extends OwnedText, TO2 extends TextualObject<T2, D2, TO2>> (TO1 from, TO2 to) Copies all titles and descriptions from oneTextualObject
to another.- Since:
- 5.3
-
updateTitlesForOwner
public static <T extends AbstractOwnedText<T>,D1 extends AbstractOwnedText<D1>, void updateTitlesForOwnerTO1 extends TextualObject<T, D1, TO1>, D2 extends AbstractOwnedText<D2>, TO2 extends TextualObject<T, D2, TO2>> (TO1 incomingMedia, TO2 mediaToUpdate, nl.vpro.domain.media.support.OwnerType owner, nl.vpro.domain.media.support.OwnerType... similarOwnerTypes) Copies all titles from one object to another.Moved from ImportUtil, SecureUpdateImpl, MediaUpdaterImpl
- Parameters:
owner
- The owner type of the titles to considersimilarOwnerTypes
- If this array is given, a new title is not created if there is no title with the given owner, but there _is_ one with one of these owner types (and it has the same value)*- Since:
- 5.6
-
updateDescriptionsForOwner
public static <T1 extends AbstractOwnedText<T1>,D extends AbstractOwnedText<D>, void updateDescriptionsForOwnerTO1 extends TextualObject<T1, D, TO1>, T2 extends AbstractOwnedText<T2>, TO2 extends TextualObject<T2, D, TO2>> (TO1 incomingMedia, TO2 mediaToUpdate, nl.vpro.domain.media.support.OwnerType owner, nl.vpro.domain.media.support.OwnerType... similarOwnerTypes) Copies all descriptions from one object to another.Moved from ImportUtil, SecureUpdateImpl, MediaUpdaterImpl
- Since:
- 5.6
-
copy
public static <T1 extends TypedText,D1 extends TypedText, void copyTO1 extends TextualObjectUpdate<T1, D1, TO1>, T2 extends OwnedText, D2 extends OwnedText, TO2 extends TextualObject<T2, D2, TO2>> (TO1 from, TO2 to, nl.vpro.domain.media.support.OwnerType owner) Copies all titles and descriptions from oneTextualObjectUpdate
to aTextualObject
.- Parameters:
owner
- The owner of the fields in the destination- Since:
- 5.3
-
copy
public static <T1 extends TypedText,D1 extends TypedText, void copyTO1 extends TextualObjectUpdate<T1, D1, TO1>, T2 extends TypedText, D2 extends TypedText, TO2 extends TextualObjectUpdate<T2, D2, TO2>> (TO1 from, TO2 to) Copies all titles and descriptions from oneTextualObjectUpdate
to aTextualObject
.- Since:
- 5.11
-
copyAndRemove
public static <T1 extends TypedText,D1 extends TypedText, void copyAndRemoveTO1 extends TextualObjectUpdate<T1, D1, TO1>, T2 extends OwnedText, D2 extends OwnedText, TO2 extends TextualObject<T2, D2, TO2>> (TO1 from, TO2 to, nl.vpro.domain.media.support.OwnerType owner) Copies all titles and descriptions from oneTextualObjectUpdate
to aTextualObject
. Then, remove all titles and descriptions (of the given owner) which were not in the source object.- Parameters:
owner
- The owner of the fields in the destination- Since:
- 5.3
-
retainAll
public static <TO extends TypedText,TO2 extends OwnedText> void retainAll(Collection<TO2> collection, Collection<TO> toRetain, nl.vpro.domain.media.support.OwnerType owner) From a collection ofOwnedText
's remove all all elements with certain owner, which are not in the source collection ofTypedText
's.- Parameters:
collection
- The collection to remove objects fromtoRetain
- The collection of texts which are to be retained in collection- Since:
- 5.3
-
retainAll
public static <TO extends TypedText,TO2 extends TypedText> void retainAll(Collection<TO2> collection, Collection<TO> toRetain) - Parameters:
collection
- The collection to remove objects fromtoRetain
- The collection of texts which are to be retained in collection- Since:
- 5.3
-
copyToUpdate
public static <T1 extends TypedText,D1 extends TypedText, void copyToUpdateTO1 extends TextualObjectUpdate<T1, D1, TO1>, T2 extends TypedText, D2 extends TypedText, TO2 extends TextualObjectUpdate<T2, D2, TO2>> (@NonNull TO1 from, @NonNull TO2 to) Copy all texts from one collection ofTextualObjectUpdate
to another. If the target collection is aTextualObject
then you want to usecopy(TextualObjectUpdate, TextualObject, OwnerType)
- Since:
- 5.3
-
copyToUpdate
public static <OT1 extends OwnedText,OD1 extends OwnedText, void copyToUpdateTO1 extends TextualObject<OT1, OD1, TO1>, T2 extends TypedText, D2 extends TypedText, TO2 extends TextualObjectUpdate<T2, D2, TO2>> (@NonNull TO1 from, @NonNull TO2 to, @NonNull nl.vpro.domain.media.support.OwnerType owner) Copy all texts from aTextualObject
to aTextualObjectUpdate
. You can to specify an owner. Preferred are then values with owners equals or lower then this given owner, or if there are none, it will fall back from the top again.In principal if the owner is
OwnerType.BROADCASTER
youu could also usecopyToUpdate(TextualObjectUpdate, TextualObjectUpdate)
- Since:
- 5.9
-
forUpdate
protected static <T extends TypedText> void forUpdate(Collection<T> collection, Consumer<T> consumer, Runnable ifNull) - Since:
- 5.8
-
forUpdate
protected static <T extends OwnedText> void forUpdate(Collection<T> collection, Consumer<T> consumer, Runnable ifNull, nl.vpro.domain.media.support.OwnerType owner) - Since:
- 5.9
-
removeEmptyValues
public static <T extends OwnedText,D extends OwnedText, void removeEmptyValuesTO extends TextualObject<T, D, TO>> (@NonNull TO textualObject)
-