Class CSSMediaList

java.lang.Object
com.helger.css.media.CSSMediaList
All Implemented Interfaces:
com.helger.commons.lang.ICloneable<CSSMediaList>, ICSSMediaList

@NotThreadSafe public class CSSMediaList extends Object implements ICSSMediaList, com.helger.commons.lang.ICloneable<CSSMediaList>
Manages an ordered set of ECSSMedium objects.
Author:
Philip Helger
  • Field Details

  • Constructor Details

    • CSSMediaList

      public CSSMediaList()
      Constructor
    • CSSMediaList

      public CSSMediaList(@Nonnull ECSSMedium eMedium)
      Constructor with a single medium
      Parameters:
      eMedium - The medium to be added. May not be null.
    • CSSMediaList

      public CSSMediaList(@Nullable ECSSMedium... aMedia)
      Constructor with an array of media.
      Parameters:
      aMedia - The array of media to be added. The array may be null but it may not contain null elements.
    • CSSMediaList

      public CSSMediaList(@Nullable Iterable<ECSSMedium> aMedia)
      Constructor with a collection of media.
      Parameters:
      aMedia - The collection of media to be added. The collection may be null but it may not contain null elements.
    • CSSMediaList

      public CSSMediaList(@Nonnull ICSSMediaList aOther)
      Constructor using another media list.
      Parameters:
      aOther - The object to copy from. May not be null.
      Since:
      3.8.3
    • CSSMediaList

      public CSSMediaList(@Nonnull CSSMediaList aOther)
      Copy constructor.
      Parameters:
      aOther - The object to copy from. May not be null.
  • Method Details

    • addMedium

      @Nonnull public CSSMediaList addMedium(@Nonnull ECSSMedium eMedium)
      Add a new medium to the list
      Parameters:
      eMedium - The medium to be added. May not be null.
      Returns:
      this
    • addMedia

      @Nonnull public CSSMediaList addMedia(@Nonnull ECSSMedium... aMediaList)
      Add a media list to the list
      Parameters:
      aMediaList - The media list to be added. May not be null.
      Returns:
      this
      Since:
      3.8.3
    • addMedia

      @Nonnull public CSSMediaList addMedia(@Nonnull ICSSMediaList aMediaList)
      Add a media list to the list
      Parameters:
      aMediaList - The media list to be added. May not be null.
      Returns:
      this
      Since:
      3.8.3
    • addMedia

      @Nonnull public CSSMediaList addMedia(@Nonnull Iterable<ECSSMedium> aMediaList)
      Add a media list to the list
      Parameters:
      aMediaList - The media list to be added. May not be null.
      Returns:
      this
      Since:
      3.8.3
    • removeMedium

      @Nonnull public com.helger.commons.state.EChange removeMedium(@Nullable ECSSMedium eMedium)
      Remove the passed medium
      Parameters:
      eMedium - The medium to be removed. May be null.
      Returns:
      EChange.CHANGED if the medium was removed, EChange.UNCHANGED otherwise.
    • removeAllMedia

      @Nonnull public com.helger.commons.state.EChange removeAllMedia()
      Remove all media.
      Returns:
      EChange.CHANGED if any medium was removed, EChange.UNCHANGED otherwise. Never null.
      Since:
      3.7.3
    • getMediaCount

      @Nonnegative public int getMediaCount()
      Specified by:
      getMediaCount in interface ICSSMediaList
      Returns:
      The number of contained media. Always ≥ 0.
    • hasNoMedia

      public boolean hasNoMedia()
      Specified by:
      hasNoMedia in interface ICSSMediaList
      Returns:
      true if no explicit media is defined, false if a media is defined.
    • containsMedium

      public boolean containsMedium(@Nullable ECSSMedium eMedium)
      Description copied from interface: ICSSMediaList
      Check if the passed medium is explicitly specified
      Specified by:
      containsMedium in interface ICSSMediaList
      Parameters:
      eMedium - The medium to be checked. May be null.
      Returns:
      true if it is contained, false otherwise
    • getAllMedia

      @Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<ECSSMedium> getAllMedia()
      Specified by:
      getAllMedia in interface ICSSMediaList
      Returns:
      A copy of all specified media in the order they were specified. Never null but maybe empty.
    • getMediaString

      @Nonnull public String getMediaString(@Nonnull String sSeparator)
      Specified by:
      getMediaString in interface ICSSMediaList
      Parameters:
      sSeparator - The separator to be used. May not be null.
      Returns:
      A non-null but maybe empty String with all media in the order they where inserted and separated by the specified separator
    • getClone

      @Nonnull @ReturnsMutableCopy public CSSMediaList getClone()
      Specified by:
      getClone in interface com.helger.commons.lang.ICloneable<CSSMediaList>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createOnDemand

      @Nonnull @ReturnsMutableCopy public static CSSMediaList createOnDemand(@Nullable ICSSMediaList aMediaList)