Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2014-2015 Philip Helger (www.helger.com) philip[at]helger[dot]com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package com.helger.webbasics.resource;
 
 import java.util.List;
 
 
This is a bundle of 1-n WebSiteResource objects that share the same conditional comment and can be bundled with each other.

Author(s):
Philip Helger
 
 public class WebSiteResourceBundle
 {
   private final List <WebSiteResourcem_aResources;
   private final String m_sConditionalComment;
   private final CSSMediaList m_aMediaList;
   // Status vars
   private final EWebSiteResourceType m_eResourceType;
   private Integer m_aHashCode;
 
   public WebSiteResourceBundle (@Nonnull @Nonempty final List <WebSiteResourceaResources,
                                 @Nullable final String sConditionalComment,
                                 @Nullable final CSSMediaList aMediaList)
   {
      = ContainerHelper.newList (ValueEnforcer.notEmptyNoNullValue (aResources"Resources"));
      = sConditionalComment;
      = aMediaList == null || aMediaList.isEmpty () ? null : aMediaList;
      = aResources.get (0).getResourceType ();
 
     // Consistency check
     for (final WebSiteResource aResource : aResources)
       if (!aResource.getResourceType ().equals ())
         throw new IllegalArgumentException ("The passed resources are mixed of different resource types: " + aResources);
   }

  

Returns:
A list of all bundled resources. Neither null nor empty.
 
   @Nonnull
   @Nonempty
   public List <WebSiteResourcegetAllResources ()
   {
     return ContainerHelper.newList ();
   }
 
   @Nonnull
   @Nonempty
   public List <StringgetAllResourcePaths ()
   {
     final List <Stringret = new ArrayList <String> ();
     for (final WebSiteResource aResource : )
       ret.add (aResource.getPath ());
     return ret;
   }

  

Returns:
true if a conditional comment is present, false if not.
 
   public boolean hasConditionalComment ()
   {
     return StringHelper.hasText ();
  }

  

Returns:
The conditional comment to use or null if no such conditional comment is present.
  {
    return ;
  }
  public CSSMediaList getMediaList ()
  {
    return ;
  }
  {
    return ;
  }
  public IMimeType getMimeType ()
  {
    return .getMimeType ();
  }
  public IHCNode getWrapped (@Nonnull final IHCNode aNode)
  {
    if (hasConditionalComment ())
      return new HCConditionalCommentNode (aNode);
    // Return as-is
    return aNode;
  }
  public boolean equals (final Object o)
  {
    if (o == this)
      return true;
    if (o == null || !getClass ().equals (o.getClass ()))
      return false;
    final WebSiteResourceBundle rhs = (WebSiteResourceBundleo;
    return .equals (rhs.m_aResources) &&
           EqualsUtils.equals (rhs.m_sConditionalComment) &&
           EqualsUtils.equals (rhs.m_aMediaList);
  }
  public int hashCode ()
  {
    if ( == null)
       = new HashCodeGenerator (this).append ()
                                                .append ()
                                                .append ()
                                                .getHashCodeObj ();
    return .intValue ();
  }
  public String toString ()
  {
    return new ToStringGenerator (this).append ("resources")
                                       .appendIfNotNull ("conditionalComment")
                                       .toString ();
  }
New to GrepCode? Check out our FAQ X