ro.isdc.wro.model.resource
Class Resource

java.lang.Object
  extended by ro.isdc.wro.model.resource.Resource

public class Resource
extends Object

Encapsulates information about a resource. This class is not final because we need to mock it in unit tests.

Author:
Alex Objelean

Constructor Summary
Resource()
          Empty constructor.
 
Method Summary
static Resource create(String uri)
          Creates a resource and set the correct ResourceType based on uri extension.
static Resource create(String uri, ResourceType type)
          Factory method for Resource creation.
 boolean equals(Object obj)
          
 ResourceType getType()
           
 String getUri()
           
 int hashCode()
          
 boolean isMinimize()
           
 void setMinimize(boolean minimize)
           
 void setType(ResourceType type)
           
 void setUri(String uri)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Resource

public Resource()
Empty constructor. Used by json deserializer.

Method Detail

create

public static Resource create(String uri,
                              ResourceType type)
Factory method for Resource creation. A factory method is preferred instead of public constructor, in order to avoid possibilities for clients to extend Resource class.

Returns:
an instance of Resource object.

create

public static Resource create(String uri)
Creates a resource and set the correct ResourceType based on uri extension. If resourceType cannot be identified an exception is thrown.

Parameters:
uri - of the resource to create.
Returns:
Resource with the provided uri and correct type.

setType

public void setType(ResourceType type)
Parameters:
type - the type to set

setUri

public void setUri(String uri)
Parameters:
uri - the uri to set

getType

public ResourceType getType()
Returns:
the type

getUri

public String getUri()
Returns:
the uri associated with this resource.

isMinimize

public boolean isMinimize()
Returns:
the minimize

setMinimize

public void setMinimize(boolean minimize)
Parameters:
minimize - the minimize to set

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2008-2013. All Rights Reserved.