Class TextualObjects


  • public class TextualObjects
    extends Object
    Utilities related to TextualObjects
    Since:
    5.1
    Author:
    Michiel Meeuwissen
    • Method Detail

      • expandTitles

        public static <OT extends OwnedTextSortedSet<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.
      • expandTitlesMajorOwnerTypes

        public static <T extends OwnedTextSortedSet<T> expandTitlesMajorOwnerTypes​(TextualObject<T,​?,​?> textualObject)
      • expandDescriptions

        public static <OT extends OwnedTextSortedSet<OT> expandDescriptions​(Collection<OT> texts,
                                                                              org.meeuw.functional.TriFunction<String,​nl.vpro.domain.media.support.OwnerType,​TextualType,​OT> creator)
      • getComparator

        protected static <OT extends OwnedTextComparator<OT> getComparator​(Comparator<nl.vpro.domain.media.support.OwnerType> ownerTypeComparator)
      • findOwnersForTextFields

        public static <T extends OwnedText,​D extends OwnedText,​TO extends TextualObject<T,​D,​TO>> nl.vpro.domain.media.support.OwnerType[] findOwnersForTextFields​(TO media)
      • getDescription

        public static <T extends OwnedText,​D extends OwnedText,​TO extends TextualObject<T,​D,​TO>> String getDescription​(@NonNull TO media,
                                                                                                                                               @NonNull nl.vpro.domain.media.support.OwnerType owner,
                                                                                                                                               @NonNull TextualType type)
      • forOwner

        public static <T extends OwnedText,​D extends OwnedText,​TO extends TextualObject<T,​D,​TO>> void forOwner​(@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)
      • expand

        public static <OT extends OwnedTextOptional<OT> expand​(@NonNull Collection<OT> titles,
                                                                 @NonNull TextualType textualType,
                                                                 @NonNull nl.vpro.domain.media.support.OwnerType ownerType)
        Returns the value for a certain TextualType and OwnerType. 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.

      • addOrUpdate

        public static <OT extends TypedText> boolean addOrUpdate​(Collection<OT> titles,
                                                                 OT add)
        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 - Collection
        add - the object to add or update.
      • updateTitlesForOwner

        public 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>> void updateTitlesForOwner​(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 consider
        similarOwnerTypes - 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>,​TO1 extends TextualObject<T1,​D,​TO1>,​T2 extends AbstractOwnedText<T2>,​TO2 extends TextualObject<T2,​D,​TO2>> void updateDescriptionsForOwner​(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
      • copyAndRemove

        public 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>> void copyAndRemove​(TO1 from,
                                                                                                                                                                                                                                                                     TO2 to,
                                                                                                                                                                                                                                                                     nl.vpro.domain.media.support.OwnerType owner)
        Copies all titles and descriptions from one TextualObjectUpdate to a TextualObject. 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 of OwnedText's remove all all elements with certain owner, which are not in the source collection of TypedText's.
        Parameters:
        collection - The collection to remove objects from
        toRetain - 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 from
        toRetain - The collection of texts which are to be retained in collection
        Since:
        5.3
      • 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,​TO extends TextualObject<T,​D,​TO>> void removeEmptyValues​(@NonNull TO textualObject)