org.ehcache.config.builders
Class ResourcePoolsBuilder

java.lang.Object
  extended by org.ehcache.config.builders.ResourcePoolsBuilder
All Implemented Interfaces:
Builder<ResourcePools>

public class ResourcePoolsBuilder
extends java.lang.Object
implements Builder<ResourcePools>

The ResourcePoolsBuilder enables building ResourcePools configurations using a fluent style.

As with all Ehcache builders, all instances are immutable and calling any method on the builder will return a new instance without modifying the one on which the method was called. This enables the sharing of builder instances without any risk of seeing them modified by code elsewhere.


Method Summary
 ResourcePools build()
          Builds the ResourcePools based on this builder's configuration.
 ResourcePoolsBuilder disk(long size, MemoryUnit unit)
          Convenience method to add a non persistent ResourceType.Core.DISK pool.
 ResourcePoolsBuilder disk(long size, MemoryUnit unit, boolean persistent)
          Convenience method to add a ResourceType.Core.DISK pool specifying persistence.
 ResourcePoolsBuilder heap(long size, ResourceUnit unit)
          Convenience method to add a ResourceType.Core.HEAP pool.
static ResourcePoolsBuilder newResourcePoolsBuilder()
          Creates a new ResourcePoolsBuilder.
static ResourcePoolsBuilder newResourcePoolsBuilder(ResourcePools pools)
          Convenience method to get a builder from an existing ResourcePools.
 ResourcePoolsBuilder offheap(long size, MemoryUnit unit)
          Convenience method to add a ResourceType.Core.OFFHEAP pool.
 ResourcePoolsBuilder with(ResourceType type, long size, ResourceUnit unit, boolean persistent)
          Adds or replace the ResourcePool of ResourceType in the returned builder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newResourcePoolsBuilder

public static ResourcePoolsBuilder newResourcePoolsBuilder()
Creates a new ResourcePoolsBuilder.

Returns:
the new builder

newResourcePoolsBuilder

public static ResourcePoolsBuilder newResourcePoolsBuilder(ResourcePools pools)
Convenience method to get a builder from an existing ResourcePools.

Parameters:
pools - the resource pools to build from
Returns:
a new builder with configuration matching the provided resource pools

with

public ResourcePoolsBuilder with(ResourceType type,
                                 long size,
                                 ResourceUnit unit,
                                 boolean persistent)
Adds or replace the ResourcePool of ResourceType in the returned builder.

Parameters:
type - the resource type
size - the pool size
unit - the pool size unit
persistent - if the pool is to be persistent
Returns:
a new builder with the added pool

heap

public ResourcePoolsBuilder heap(long size,
                                 ResourceUnit unit)
Convenience method to add a ResourceType.Core.HEAP pool.

Parameters:
size - the pool size
unit - the pool size unit
Returns:
a new builder with the added pool

offheap

public ResourcePoolsBuilder offheap(long size,
                                    MemoryUnit unit)
Convenience method to add a ResourceType.Core.OFFHEAP pool.

Parameters:
size - the pool size
unit - the pool size unit
Returns:
a new builder with the added pool

disk

public ResourcePoolsBuilder disk(long size,
                                 MemoryUnit unit)
Convenience method to add a non persistent ResourceType.Core.DISK pool.

Parameters:
size - the pool size
unit - the pool size unit
Returns:
a new builder with the added pool

disk

public ResourcePoolsBuilder disk(long size,
                                 MemoryUnit unit,
                                 boolean persistent)
Convenience method to add a ResourceType.Core.DISK pool specifying persistence.

Parameters:
size - the pool size
unit - the pool size unit
persistent - if the pool is persistent or not
Returns:
a new builder with the added pool

build

public ResourcePools build()
Builds the ResourcePools based on this builder's configuration.

Specified by:
build in interface Builder<ResourcePools>
Returns:
the resource pools