javax.ws.rs.core
Class Variant.VariantListBuilder

java.lang.Object
  extended by javax.ws.rs.core.Variant.VariantListBuilder
Enclosing class:
Variant

public abstract static class Variant.VariantListBuilder
extends java.lang.Object

A builder for a list of representation variants.


Constructor Summary
protected Variant.VariantListBuilder()
          Protected constructor, use the static newInstance method to obtain an instance.
 
Method Summary
abstract  Variant.VariantListBuilder add()
          Add the current combination of metadata to the list of supported variants, after this method is called the current combination of metadata is emptied.
abstract  java.util.List<Variant> build()
          Build a list of representation variants from the current state of the builder.
abstract  Variant.VariantListBuilder encodings(java.lang.String... encodings)
          Set the encoding[s] for this variant.
abstract  Variant.VariantListBuilder languages(java.util.Locale... languages)
          Set the language[s] for this variant.
abstract  Variant.VariantListBuilder mediaTypes(MediaType... mediaTypes)
          Set the media type[s] for this variant.
static Variant.VariantListBuilder newInstance()
          Create a new builder instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Variant.VariantListBuilder

protected Variant.VariantListBuilder()
Protected constructor, use the static newInstance method to obtain an instance.

Method Detail

newInstance

public static Variant.VariantListBuilder newInstance()
Create a new builder instance.

Returns:
a new Builder

build

public abstract java.util.List<Variant> build()
Build a list of representation variants from the current state of the builder. After this method is called the builder is reset to an empty state.

Returns:
a list of representation variants

add

public abstract Variant.VariantListBuilder add()
Add the current combination of metadata to the list of supported variants, after this method is called the current combination of metadata is emptied. If more than one value is supplied for one or more of the variant properties then a variant will be generated for each possible combination. E.g. in the following list would have four members:

List list = VariantListBuilder.newInstance().languages("en","fr")
   .encodings("zip", "identity").add().build()

Returns:
the updated builder
Throws:
java.lang.IllegalStateException - if there is not at least one mediaType, language or encoding set for the current variant.

languages

public abstract Variant.VariantListBuilder languages(java.util.Locale... languages)
Set the language[s] for this variant.

Parameters:
languages - the available languages
Returns:
the updated builder

encodings

public abstract Variant.VariantListBuilder encodings(java.lang.String... encodings)
Set the encoding[s] for this variant.

Parameters:
encodings - the available encodings
Returns:
the updated builder

mediaTypes

public abstract Variant.VariantListBuilder mediaTypes(MediaType... mediaTypes)
Set the media type[s] for this variant.

Parameters:
mediaTypes - the available mediaTypes. If specific charsets are supported they should be included as parameters of the respective media type.
Returns:
the updated builder


Submit a bug or feature

Copyright © 2009-2011, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms.

Generated on 10-February-2011 12:41