Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
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 org.cdlflex.ui.util;
 
 import java.util.List;
 import java.util.Set;
 
Utility class for ResourceReference related operations (e.g. convert ResourceReferences into HeaderItems)
 
 public final class ResourceReferences {
 
     private ResourceReferences() {
         // utility class
     }

    
Converts the given ResourceReferences to HeaderItems and joins them with the given Iterable of header items. This is useful for the org.apache.wicket.request.resource.ResourceReference#getDependencies() method.

Parameters:
dependencies the result of super.getDependencies()
references the references to add as new dependencies
Returns:
a new set of header items
 
     public static Iterable<? extends HeaderItemjoin(Iterable<? extends HeaderItemdependencies,
         ResourceReference... references) {
         Set<HeaderItemjoined = new HashSet<>();
 
         joined.addAll(Collections.asList(dependencies));
         joined.addAll(ResourceReferences.asHeaderItems(references));
 
         return joined;
     }

    
Converts the given ResourceReference items in the list to HeaderItems.

Parameters:
referenceList the ResourceReferences to convert
Returns:
a list of HeaderItems
 
     public static List<HeaderItemasHeaderItems(List<ResourceReferencereferenceList) {
         return Collections.map(referenceListnew Collections.Callback<ResourceReferenceHeaderItem>() {
             @Override
             public HeaderItem call(ResourceReference object) {
                 return asHeaderItem(object);
             }
         });
     }

    
Converts the given ResourceReference items in the list to HeaderItems.

Parameters:
referenceList the ResourceReferences to convert
Returns:
a list of HeaderItems
 
     public static List<HeaderItemasHeaderItems(ResourceReference... referenceList) {
         return asHeaderItems(Arrays.asList(referenceList));
     }

    
Converts the given ResourceReference to an appropriate HeaderItem.

Parameters:
reference the ResourceReferences to convert
Returns:
a HeaderItem
 
     public static HeaderItem asHeaderItem(ResourceReference reference) {
         if (reference instanceof JavaScriptResourceReference) {
             return asHeaderItem((JavaScriptResourceReferencereference);
         } else if (reference instanceof CssResourceReference) {
             return asHeaderItem((CssResourceReferencereference);
         } else {
             throw new IllegalArgumentException("Can not convert resource reference " + reference);
         }
     }

    
Returns the given CssResourceReference as CssReferenceHeaderItem.

Parameters:
reference the reference to convert
Returns:
a header item representing the reference
    public static HeaderItem asHeaderItem(CssResourceReference reference) {
        return CssReferenceHeaderItem.forReference(reference);
    }

    
Returns the given JavaScriptResourceReference as JavaScriptHeaderItem.

Parameters:
reference the reference to convert
Returns:
a header item representing the reference
    public static HeaderItem asHeaderItem(JavaScriptResourceReference reference) {
        return JavaScriptHeaderItem.forReference(reference);
    }
New to GrepCode? Check out our FAQ X